01-24-2006, 10:47 AM
When creating new dialog, select "Smart dialog". This will create new function ("dialog procedure") that is called by Windows whenever the user clicks a button or does something else with the dialog. Use the "Events" button in the Dialog Editor to insert code that will be executed on click of that radio button. When you click Events, are shown mostly used messages (events) for the dialog or control that is active (with red dot). When you select a message and click OK, in the function is inserted case for that control/message. There you can write code that must be executed on that message. To enable/disable controls, use function EnableWindow, which can be inserted using the Window dialog from the floating toolbar.
Example function dialog_472:
Here code used to show the dialog is in the same function, but it also can be in some other macro. Here "case [3,4]" is used instead of "case 3 ... case 4" to reduce code size.
Example function dialog_472:
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4 6"
str o3Opt o4Opt e6
o3Opt=1
if(!ShowDialog("dialog_472" &dialog_472 &controls)) ret
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 223 135 "Form"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032009 0x0 8 8 48 12 "Option first"
;4 Button 0x54002009 0x0 8 22 48 12 "Option next"
;5 Static 0x5C000000 0x0 8 44 48 13 "Text"
;6 Edit 0x5C030080 0x200 58 44 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""
ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [3,4] ;;when clicked option button whose id is 3 or 4
,EnableWindow(id(5 hDlg) wParam=4) ;;enable static 5 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(6 hDlg) wParam=4) ;;enable edit 6 if button 4 is clicked, disable if other button is clicked
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1Here code used to show the dialog is in the same function, but it also can be in some other macro. Here "case [3,4]" is used instead of "case 3 ... case 4" to reduce code size.
