Trainee
Date of registration: Jan 5th 2009
Location: Sesto Fiorentino, Florence (ITALY)
Occupation: design & development (HW, SW & FW)
Hobbies: chess, fly fishing, good wine and beautiful women!
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
..... Public Sub Command1_Click() CommandEx 1 End Sub Public Sub Command2_Click() CommandEx 2 End Sub Public Sub Command3_Click() CommandEx 3 End Sub ..... Sub CommandEx(Index As Integer) MsgBox "the button " & CStr(Index) & " has been pressed!" Select Case Index Case 1 ..... Case 2 ..... Case 3 ..... End Select End Sub |
Administrator
Date of registration: Jul 16th 2008
Location: Erlangen, Germany
Occupation: Software Developer
Hobbies: Jabaco, game theory, text-mining
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
Dim WithEvents myStateList As VBControlExtender(Me) Dim myStateItems() As PictureBox Public Sub Form_Load() Dim tmpStateItem As PictureBox Const maxX As Integer = 15 Const maxY As Integer = 10 Const offsetX As Integer = 10 Const offsetY As Integer = 10 Const itemWidth As Integer = 23 Const itemHeight As Integer = 10 Dim x As Integer, y As Integer, v As Integer ReDim myStateItems((maxX + 1) * (maxY + 1)) For x = 0 To maxX For y = 0 To maxY v = v + 1 tmpStateItem = New PictureBox() myStateItems(v) = tmpStateItem Call myStateList.AddControl("test" + x + "|" + y, tmpStateItem, x * itemWidth + offsetX, y * itemHeight + offsetY, itemWidth, itemHeight, True) Next Next v = 0 For x = 0 To maxX For y = 0 To maxY v = v + 1 myStateItems(v).BackColor = IIF(Rnd > 0.5, vbRed, vbGreen) Next Next End Sub Public Sub myStateList_Click(ControlID As String) MsgBox ControlID + " pressed!" End Sub |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
Option Explicit ' ' this Class overloads CommandButton to define a special event handler ' Public ownerForm As frmDynControl ' allows call back to common event handler Public row As Integer ' we remember row/col to handle events parameterized Public col As Integer ' a parameterized constructor Public Sub clsMyDynButton(frm As frmDynControl, c As Integer, r As Integer ) ownerForm = frm col = c row = r End Sub ' Jabaco was not able to find class "MouseEvent" ' before I explicitly selected this class in the Project/Classpath rt.jar tree Public Sub mouseClicked(e As MouseEvent) ownerForm.dynButtonClickHandler(Me, e) End Sub |
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 |
' "MouseEvent" was not visible in my Jabaco IDE before I explicitly ' selected it in the Project/Classpath rt.jar tree Public Sub dynButtonClickHandler(btn As clsMyDynButton, e As MouseEvent) ' common click event handler for all clsMyDynButton controls If Not e.isConsumed Then ' we react just once msgbox "col=" & btn.col & " row=" & btn.row & vbcrlf & e.toString ' here we might do something clever depending on the btn.Caption e.consume End If End Sub |
This post has been edited 1 times, last edit by "A1880" (Feb 15th 2009, 11:00pm)
Beginner
Date of registration: Jan 15th 2009
Location: In Sweden, 50 km outside Östersund
Occupation: HW, FW & Interface developer
Hobbies: Cars, and ofcause my job ;)