Lionheart008
17-11-2009, 19:30
hello.
how can I create a correct "control add combobox" feature in my example ?
I wanted also to see the array list with names in this box if I click the combobox.
'------------------------------------------------
'---- class+object example from c++ by lionheart with dialog experiment
'------------------------------------------------
uses "console", "UI"
%ButtonClose = 1001
%ButtonUnknown = 1002
%ButtonCombobx = 1003
%ControlID = 1004
%Text = 1005
' >> CLASS
Type Dog
age As Long
bone as long
End Type
Sub Dog_SetAge(object As Dog, newAge As Long)
object.age = newAge
End Sub
Sub Dog_SetBone(object As Dog, newBone As Long)
object.bone = newBone
End Sub
Function Dog_GetAge(object As Dog) As Long
Return object.age
End Function
Function Dog_GetBone(object As Dog) As Long
Return object.bone
End Function
' << CLASS
Function TBMain()
Local bello As Dog
Local waldi As Dog
Local pfiffi As Dog
Local rub as dog
Dog_SetAge(bello, 4)
Dog_SetAge(waldi, 3)
Dog_SetAge(pfiffi, 6)
Dog_SetAge(rub, 16)
Dog_SetBone(rub, 124)
MsgBox 0, "Age of bello "+Format$(Dog_GetAge(bello))
printl "Age of bello "+Format$(Dog_GetAge(bello))
MsgBox 0, "Age of waldi "+Format$(Dog_GetAge(waldi))
printl "Age of waldi "+Format$(Dog_GetAge(waldi))
MsgBox 0, "Age of pfiffi "+Format$(Dog_GetAge(pfiffi))
printl "Age of pfiffi "+Format$(Dog_GetAge(pfiffi))
MsgBox 0, "Age of rubber "+Format$(Dog_GetAge(rub))
printl "Age of rubber "+Format$(Dog_GetAge(rub))
MsgBox 0, "Bones to eat of rubber "+Format$(Dog_GetBone(rub))
printl "Bones to eat of rubber "+Format$(Dog_GetBone(rub))
call dialogName()
waitkey
End Function
function dialogName() as string
Dim hDlg As DWORD
dim myArraylist(5) as string
ARRAY ASSIGN myArraylist() = "paula", "josef", "tom", "inga", "tina"
DIALOG New 0, "myNewDialog ",-1,-1, 360, 380, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
CONTROL ADD BUTTON, hDlg, %ButtonClose, "Click to save the world", 90, 40, 140, 100
CONTROL ADD BUTTON, hDlg, %ButtonUnknown, "nobody will come", 90, 140, 80, 80
Control ADD Combobox, hDlg, %ButtonCombobx, myArraylist(), 260, 240, 80, 80, %CBS_SORT or %CBS_DROPDOWN ', %WS_EX_CLIENTEDGE Or %WS_EX_LEFT
CONTROL ADD TEXTBOX, hDlg, %Text, "hello Caesar", 240, 140, 80, 80, %ES_AUTOHSCROLL OR %ES_LEFT OR %WS_BORDER OR %WS_TABSTOP,%WS_EX_CLIENTEDGE OR %WS_EX_LEFT
DIALOG SHOW MODAL hDlg Call cbDialog
end function
'------------------------------------------------
' Callback function used to handle dialog events
'------------------------------------------------
CALLBACK Function cbDialog() As Long
Select Case CBMSG
Case %WM_Command
If CBWPARAM = %ButtonClose Then DIALOG End CBHNDL
Case %WM_DESTROY
MSGBOX 0, "Window is to be destroyed ", %MB_OK, "for one time"
End Select
End Function
last edit: corrected version with combobox
best regards, frank
how can I create a correct "control add combobox" feature in my example ?
I wanted also to see the array list with names in this box if I click the combobox.
'------------------------------------------------
'---- class+object example from c++ by lionheart with dialog experiment
'------------------------------------------------
uses "console", "UI"
%ButtonClose = 1001
%ButtonUnknown = 1002
%ButtonCombobx = 1003
%ControlID = 1004
%Text = 1005
' >> CLASS
Type Dog
age As Long
bone as long
End Type
Sub Dog_SetAge(object As Dog, newAge As Long)
object.age = newAge
End Sub
Sub Dog_SetBone(object As Dog, newBone As Long)
object.bone = newBone
End Sub
Function Dog_GetAge(object As Dog) As Long
Return object.age
End Function
Function Dog_GetBone(object As Dog) As Long
Return object.bone
End Function
' << CLASS
Function TBMain()
Local bello As Dog
Local waldi As Dog
Local pfiffi As Dog
Local rub as dog
Dog_SetAge(bello, 4)
Dog_SetAge(waldi, 3)
Dog_SetAge(pfiffi, 6)
Dog_SetAge(rub, 16)
Dog_SetBone(rub, 124)
MsgBox 0, "Age of bello "+Format$(Dog_GetAge(bello))
printl "Age of bello "+Format$(Dog_GetAge(bello))
MsgBox 0, "Age of waldi "+Format$(Dog_GetAge(waldi))
printl "Age of waldi "+Format$(Dog_GetAge(waldi))
MsgBox 0, "Age of pfiffi "+Format$(Dog_GetAge(pfiffi))
printl "Age of pfiffi "+Format$(Dog_GetAge(pfiffi))
MsgBox 0, "Age of rubber "+Format$(Dog_GetAge(rub))
printl "Age of rubber "+Format$(Dog_GetAge(rub))
MsgBox 0, "Bones to eat of rubber "+Format$(Dog_GetBone(rub))
printl "Bones to eat of rubber "+Format$(Dog_GetBone(rub))
call dialogName()
waitkey
End Function
function dialogName() as string
Dim hDlg As DWORD
dim myArraylist(5) as string
ARRAY ASSIGN myArraylist() = "paula", "josef", "tom", "inga", "tina"
DIALOG New 0, "myNewDialog ",-1,-1, 360, 380, _
%WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPCHILDREN Or _
%WS_CAPTION Or _
%WS_SYSMENU Or _
%WS_MINIMIZEBOX, _
0 To hDlg
CONTROL ADD BUTTON, hDlg, %ButtonClose, "Click to save the world", 90, 40, 140, 100
CONTROL ADD BUTTON, hDlg, %ButtonUnknown, "nobody will come", 90, 140, 80, 80
Control ADD Combobox, hDlg, %ButtonCombobx, myArraylist(), 260, 240, 80, 80, %CBS_SORT or %CBS_DROPDOWN ', %WS_EX_CLIENTEDGE Or %WS_EX_LEFT
CONTROL ADD TEXTBOX, hDlg, %Text, "hello Caesar", 240, 140, 80, 80, %ES_AUTOHSCROLL OR %ES_LEFT OR %WS_BORDER OR %WS_TABSTOP,%WS_EX_CLIENTEDGE OR %WS_EX_LEFT
DIALOG SHOW MODAL hDlg Call cbDialog
end function
'------------------------------------------------
' Callback function used to handle dialog events
'------------------------------------------------
CALLBACK Function cbDialog() As Long
Select Case CBMSG
Case %WM_Command
If CBWPARAM = %ButtonClose Then DIALOG End CBHNDL
Case %WM_DESTROY
MSGBOX 0, "Window is to be destroyed ", %MB_OK, "for one time"
End Select
End Function
last edit: corrected version with combobox
best regards, frank