Lionheart008
27-11-2009, 22:49
hi.
can anybody please check this ui callback example ? ;)
1) => I am wondering why this example starts with two dialogs at same time ?
2) the "extrahelp" (dialog one) button doesn't appear at the start, but should do it. After pushing "close myClassroom" button ("dialog two", you may try it two times to close it!) the "extrahelp" in main dialog appears again.
3) if you come with mouse over "extrahelp" button ("dialog one") the next dialog popup starts immediately and I cannot clear exit this new dialog. perhaps it's not very smart to include "dialog new" into callback function, but I wanted to do that one. - it's just an experiment. critics are welcome!
updated example:
Uses "UI"
'#include "%APP_INCLUDEPATH%\RichEdit32.inc"
' -- ID numbers of controls
Begin Const
%bClose = %WM_USER + 1
%tInput
%tInput2
%TextboxName
%ButtonOk
%ButtonCancel
%ButtonBrowse
%ButtonRep
%ButtonDel
%ButtonAdd
%LISTBOXFRANK
%TextboxPath
%LabelPath
%LabelName
%Help
%ButtonSave
%ButtonNewchil
%bOpenX
End Const
' -- Create dialog here
Function TBMAIN() as long
Local hDlg As DWord
Dialog NEW 0, "You can use only h,e,l,l,o, f,r,a,n,k",-1,-1, 220, 120, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control ADD TEXTBOX, hDlg, %tInput, "", 5, 5, 150, 14, Call bInputProc
Control ADD TEXTBOX, hDlg, %tInput2, "", 5, 25, 150, 14, Call bInputProx
Control ADD BUTTON , hDlg, %bClose, "Click to close", 5, 50, 150, 14, Call bCloseProc
Control ADD BUTTON , hDlg, %bOpenX, "OpenX", 5, 70, 150, 14 '-- , Call bCloseProc
Control ADD BUTTON , hDlg, %Help, "ExtraHelp", 5, 90, 150, 14, Call FranksClassroomEditorGet
Dialog SHOW MODAL hDlg, Call dlgProc
End Function
' -- Callback for dialog
CallBack Function dlgProc()
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
' -- Callbacks for controls
CallBack Function bCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
'xxx - one callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function bInputProc()
Local s As String, pos, selStart, selEnd As Long
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %EN_UPDATE Then
' -- Get the current text
Control GET TEXT CBHNDL, %tInput To s
' -- Is it longer than 0 characters
If Len(s) > 0 Then
' -- Store original cursor position
Control SEND CBHNDL, %tInput, %EM_GETSEL, VARPTR(selStart), VARPTR(selEnd)
' -- Does it contain something else than abc?
pos = Verify(s, "hello")
' -- If yes, trim it!
If pos Then s = LEFT$(s, pos-1)
' --Put text back
Control SET TEXT CBHNDL, %tInput, s
' -- Restore original cursor position
Control SEND CBHNDL, %tInput, %EM_SETSEL, selStart, selEnd
End If
End If
End If
End Function
'xxx - two callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function bInputProx()
Local t As String, pos2, selStart, selEnd As Long
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %EN_UPDATE Then
' -- Get the current text
Control GET TEXT CBHNDL, %tInput2 To t
' -- Is it longer than 0 characters
If Len(t) > 0 Then
' -- Store original cursor position
Control SEND CBHNDL, %tInput2, %EM_GETSEL, VARPTR(selStart), VARPTR(selEnd)
' -- Does it contain something else than abc?
pos2 = Verify(t, "frank")
' -- If yes, trim it!
If pos2 Then t = LEFT$(t, pos2-1)
' --Put text back
Control SET TEXT CBHNDL, %tInput2, t
' -- Restore original cursor position
Control SEND CBHNDL, %tInput2, %EM_SETSEL, selStart, selEnd
End If
End If
End If
End Function
'xxx - three callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function FranksClassroomEditorGet()
Local FranksEditorhDlg As Long
Local hDlg As Long
Local myTitle As ASCIIZ *60
$AppName = "Franks Classroom GUI EditorHelp"
myTitle = $AppName & " - Franks Classroom GUI Editor/Help file - Add"
Dialog NEW hDlg, $AppName & " - Franks Classroom GUI Editor/Help file", 0,0 , 195, 175, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %WS_CAPTION Or _
%WS_SYSMENU Or %DS_3DLOOK Or %DS_NOFAILCREATE Or %DS_SETFONT Or %WS_MINIMIZEBOX, _
%WS_EX_CONTROLPARENT To FranksEditorhDlg
Control ADD LABEL, FranksEditorhDlg, %LabelName, "Name of children to display", 3, 3, 96, 34, _
%WS_CHILD Or %WS_VISIBLE
Control ADD TEXTBOX, FranksEditorhDlg, %TextboxName, "ludwig van beethoven", 3, 15, 186, 12, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
Control ADD LABEL, FranksEditorhDlg, %LabelPath, ".doc, .exe, .txt, .hlp, .xls full path " & _
"?", 3, 30, 165, 12, %WS_CHILD Or %WS_VISIBLE
Control ADD TEXTBOX, FranksEditorhDlg, %TextboxPath, "teacher map1", 3, 42, 186, 12, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
Control ADD TEXTBOX, FranksEditorhDlg, %LISTBOXFRANK,"" , 3, 66, 96, 82, _
%WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_VSCROLL Or %WS_TABSTOP _
Or %LBS_NOTIFY Or %LBS_SORT Or %LBS_USETABSTOPS or %ES_MULTILINE or %ES_WANTRETURN OR %WS_EX_LEFT, %WS_EX_CLIENTEDGE
Control set Text FranksEditorhDlg, %LISTBOXFRANK, "type in here some silly things"
CONTROL set Focus FranksEditorhDlg, %LISTBOXFRANK
Control ADD BUTTON, FranksEditorhDlg, %ButtonAdd, "&Add", 111, 66, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonDel, "&Del", 111, 90, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonRep, "&Repl", 111, 114, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonBrowse, "&Browse", 153, 66, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonCancel, "&Cancel", 153, 90, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonOk, "&OK", 153, 114, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonNewchil, "&new", 153, 134, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonSave, "&save", 111, 134, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON,FranksEditorhDlg, %bClose, "Close myClassRoom", 5, 156, 150, 14, Call bCloseProx
Dialog SHOW MODAL FranksEditorhDlg, call dlgProbe', Call FranksChildrenGetProc
End Function
'------ callback for closing new dialog with Classroom
CallBack Function bCloseProx()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
' ------- dummy Callback for dialog
CallBack Function dlgProbe()
Select Case CBMSG
Case %WM_INITDIALOG
Case %WM_CLOSE
End Select
End Function
best regards, frank
can anybody please check this ui callback example ? ;)
1) => I am wondering why this example starts with two dialogs at same time ?
2) the "extrahelp" (dialog one) button doesn't appear at the start, but should do it. After pushing "close myClassroom" button ("dialog two", you may try it two times to close it!) the "extrahelp" in main dialog appears again.
3) if you come with mouse over "extrahelp" button ("dialog one") the next dialog popup starts immediately and I cannot clear exit this new dialog. perhaps it's not very smart to include "dialog new" into callback function, but I wanted to do that one. - it's just an experiment. critics are welcome!
updated example:
Uses "UI"
'#include "%APP_INCLUDEPATH%\RichEdit32.inc"
' -- ID numbers of controls
Begin Const
%bClose = %WM_USER + 1
%tInput
%tInput2
%TextboxName
%ButtonOk
%ButtonCancel
%ButtonBrowse
%ButtonRep
%ButtonDel
%ButtonAdd
%LISTBOXFRANK
%TextboxPath
%LabelPath
%LabelName
%Help
%ButtonSave
%ButtonNewchil
%bOpenX
End Const
' -- Create dialog here
Function TBMAIN() as long
Local hDlg As DWord
Dialog NEW 0, "You can use only h,e,l,l,o, f,r,a,n,k",-1,-1, 220, 120, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control ADD TEXTBOX, hDlg, %tInput, "", 5, 5, 150, 14, Call bInputProc
Control ADD TEXTBOX, hDlg, %tInput2, "", 5, 25, 150, 14, Call bInputProx
Control ADD BUTTON , hDlg, %bClose, "Click to close", 5, 50, 150, 14, Call bCloseProc
Control ADD BUTTON , hDlg, %bOpenX, "OpenX", 5, 70, 150, 14 '-- , Call bCloseProc
Control ADD BUTTON , hDlg, %Help, "ExtraHelp", 5, 90, 150, 14, Call FranksClassroomEditorGet
Dialog SHOW MODAL hDlg, Call dlgProc
End Function
' -- Callback for dialog
CallBack Function dlgProc()
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
' -- Callbacks for controls
CallBack Function bCloseProc()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
'xxx - one callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function bInputProc()
Local s As String, pos, selStart, selEnd As Long
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %EN_UPDATE Then
' -- Get the current text
Control GET TEXT CBHNDL, %tInput To s
' -- Is it longer than 0 characters
If Len(s) > 0 Then
' -- Store original cursor position
Control SEND CBHNDL, %tInput, %EM_GETSEL, VARPTR(selStart), VARPTR(selEnd)
' -- Does it contain something else than abc?
pos = Verify(s, "hello")
' -- If yes, trim it!
If pos Then s = LEFT$(s, pos-1)
' --Put text back
Control SET TEXT CBHNDL, %tInput, s
' -- Restore original cursor position
Control SEND CBHNDL, %tInput, %EM_SETSEL, selStart, selEnd
End If
End If
End If
End Function
'xxx - two callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function bInputProx()
Local t As String, pos2, selStart, selEnd As Long
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %EN_UPDATE Then
' -- Get the current text
Control GET TEXT CBHNDL, %tInput2 To t
' -- Is it longer than 0 characters
If Len(t) > 0 Then
' -- Store original cursor position
Control SEND CBHNDL, %tInput2, %EM_GETSEL, VARPTR(selStart), VARPTR(selEnd)
' -- Does it contain something else than abc?
pos2 = Verify(t, "frank")
' -- If yes, trim it!
If pos2 Then t = LEFT$(t, pos2-1)
' --Put text back
Control SET TEXT CBHNDL, %tInput2, t
' -- Restore original cursor position
Control SEND CBHNDL, %tInput2, %EM_SETSEL, selStart, selEnd
End If
End If
End If
End Function
'xxx - three callback -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CallBack Function FranksClassroomEditorGet()
Local FranksEditorhDlg As Long
Local hDlg As Long
Local myTitle As ASCIIZ *60
$AppName = "Franks Classroom GUI EditorHelp"
myTitle = $AppName & " - Franks Classroom GUI Editor/Help file - Add"
Dialog NEW hDlg, $AppName & " - Franks Classroom GUI Editor/Help file", 0,0 , 195, 175, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %WS_CAPTION Or _
%WS_SYSMENU Or %DS_3DLOOK Or %DS_NOFAILCREATE Or %DS_SETFONT Or %WS_MINIMIZEBOX, _
%WS_EX_CONTROLPARENT To FranksEditorhDlg
Control ADD LABEL, FranksEditorhDlg, %LabelName, "Name of children to display", 3, 3, 96, 34, _
%WS_CHILD Or %WS_VISIBLE
Control ADD TEXTBOX, FranksEditorhDlg, %TextboxName, "ludwig van beethoven", 3, 15, 186, 12, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
Control ADD LABEL, FranksEditorhDlg, %LabelPath, ".doc, .exe, .txt, .hlp, .xls full path " & _
"?", 3, 30, 165, 12, %WS_CHILD Or %WS_VISIBLE
Control ADD TEXTBOX, FranksEditorhDlg, %TextboxPath, "teacher map1", 3, 42, 186, 12, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %ES_AUTOHSCROLL, %WS_EX_CLIENTEDGE
Control ADD TEXTBOX, FranksEditorhDlg, %LISTBOXFRANK,"" , 3, 66, 96, 82, _
%WS_CHILD Or %WS_VISIBLE Or %WS_BORDER Or %WS_VSCROLL Or %WS_TABSTOP _
Or %LBS_NOTIFY Or %LBS_SORT Or %LBS_USETABSTOPS or %ES_MULTILINE or %ES_WANTRETURN OR %WS_EX_LEFT, %WS_EX_CLIENTEDGE
Control set Text FranksEditorhDlg, %LISTBOXFRANK, "type in here some silly things"
CONTROL set Focus FranksEditorhDlg, %LISTBOXFRANK
Control ADD BUTTON, FranksEditorhDlg, %ButtonAdd, "&Add", 111, 66, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonDel, "&Del", 111, 90, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonRep, "&Repl", 111, 114, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonBrowse, "&Browse", 153, 66, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonCancel, "&Cancel", 153, 90, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonOk, "&OK", 153, 114, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonNewchil, "&new", 153, 134, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON, FranksEditorhDlg, %ButtonSave, "&save", 111, 134, 33, 15, _
%WS_CHILD Or %WS_VISIBLE Or %WS_TABSTOP Or %BS_CENTER Or %BS_VCENTER
Control ADD BUTTON,FranksEditorhDlg, %bClose, "Close myClassRoom", 5, 156, 150, 14, Call bCloseProx
Dialog SHOW MODAL FranksEditorhDlg, call dlgProbe', Call FranksChildrenGetProc
End Function
'------ callback for closing new dialog with Classroom
CallBack Function bCloseProx()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
' ------- dummy Callback for dialog
CallBack Function dlgProbe()
Select Case CBMSG
Case %WM_INITDIALOG
Case %WM_CLOSE
End Select
End Function
best regards, frank