Posts: 37
Threads: 17
Joined: Mar 2005
I am sure I am just missing something in the focumentation or on this forum, but I cannot figure out how to set a checkbox to being checked when the dialog box opens. Also, I need a radio button to be defaulted.
Thanks for you help.
Posts: 12,074
Threads: 141
Joined: Dec 2002
Assign "1" to the variable. Example:
\Dialog_Editor
str controls = "3 4 5 6"
str c3Che o4Opt o5Opt o6Opt
c3Che=1
o4Opt=1
if(!ShowDialog("" 0 &controls)) ret
if(c3Che=1) out "checkbox checked"
if(o4Opt=1) out "option 1 checked"
else if(o5Opt=1) out "option 2 checked"
else if(o6Opt=1) out "option 3 checked"
;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 0x54012003 0x0 8 8 48 12 "Check"
;4 Button 0x54032009 0x0 8 40 48 12 "Option 1"
;5 Button 0x54002009 0x0 8 52 48 13 "Option 2"
;6 Button 0x54002009 0x0 8 64 48 12 "Option 3"
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""
Posts: 37
Threads: 17
Joined: Mar 2005
Thanks, works like a charm!
Posts: 12
Threads: 5
Joined: May 2006
Hello - this is my first forum posting. Thank you for all of the information that I have been able to find here, its great. Now along the lines of this thread, I have a question.
I have created a dialog box using the Dialog Editor. It has several radio buttons, and if one is selected, the others deselect, this is perfect. Now for the crux of the problem, I have a text entry box as well, that I want to tie a radio button to, so that if text is entered, or the cursor is placed in the text edit control, the radio button will automatically switch to that radio button.
Say I have a list of options
Option 1
Option 2
Option 3
Other Enter text
I want "Other" to be the fourth radio button and have a text box right next to it.
Question 2. I want to be able to have some buttons deactivated depending on security. Can I set the contols in such a way that a selection is deactivated or do I need 2 separate dialog boxes?
Thank you for your help and great information.
El Brooks
Posts: 12,074
Threads: 141
Joined: Dec 2002
You need dialog with dialog procedure (smart dialog).
1. Use EN_SETFOCUS event of the edit control. Use CheckRadioButton function.
2. Pass a security variable to ShowDialog as param. In the dialog procedure, get it using DT_GetParam, and depending on its value enable or disable some controls and the code that is associated with that controls.
Example, function Dialog5545
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str controls = "3 4 5 6 7"
str o3Opt o4Opt o5Opt o6Opt e7
o3Opt=1
int secure=1 ;;set to 0 if nonsecure
if(!ShowDialog("Dialog5545" &Dialog5545 &controls 0 0 0 0 secure)) ret
;BEGIN DIALOG
;0 "" 0x90C80A44 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 6 6 48 12 "Option first"
;4 Button 0x54002009 0x0 6 20 48 13 "Option next"
;5 Button 0x54002009 0x0 6 34 48 12 "Option next"
;6 Button 0x54002009 0x0 6 48 48 12 "Option next"
;7 Edit 0x54030080 0x200 58 48 96 14 ""
;8 Button 0x54032000 0x0 6 116 48 14 "Security"
;END DIALOG
;DIALOG EDITOR: "" 0x2010805 "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,int secure2=DT_GetParam(hDlg)
,if(secure2) EnableWindow(id(8 hDlg) 0)
,ret 1
,
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
secure2=DT_GetParam(hDlg)
sel wParam
,case 8 ;;Security clicked
,if(!secure2)
,,mes "nonsecure"
,,;...
,
,case EN_SETFOCUS<<16|7 ;;the text box focused
,CheckRadioButton hDlg 3 6 6
,;this also can be used: but id(6 hDlg); act lParam
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
Posts: 12
Threads: 5
Joined: May 2006
Thank you so much for your reply. If I do this, can I encrypt the dialog function? I have had some trouble with doing that already.
El Brooks
Posts: 12,074
Threads: 141
Joined: Dec 2002
If the macro with the dialog definition (text between BEGIN DIALOG and END DIALOG) is encrypted, you need to assign the dialog definition to a variable, pass the variable to ShowDialog as first argument, and include 2 in flags. Example:
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
lpstr dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 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 6 6 48 12 "Option first"
;4 Button 0x54002009 0x0 6 20 48 13 "Option next"
;5 Button 0x54002009 0x0 6 34 48 12 "Option next"
;6 Button 0x54002009 0x0 6 48 48 12 "Option next"
;7 Edit 0x54030080 0x200 58 48 96 14 ""
;8 Button 0x54032000 0x0 6 116 48 14 "Security"
;END DIALOG
;DIALOG EDITOR: "" 0x2010805 "" ""
str controls = "3 4 5 6 7"
str o3Opt o4Opt o5Opt o6Opt e7
o3Opt=1
int secure=1 ;;set to 0 if nonsecure
if(!ShowDialog(dd &Dialog5545 &controls 0 2 0 0 secure)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,DT_Init(hDlg lParam)
,int secure2=DT_GetParam(hDlg)
,if(secure2) EnableWindow(id(8 hDlg) 0)
,ret 1
,
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
secure2=DT_GetParam(hDlg)
sel wParam
,case 8 ;;Security clicked
,if(!secure2)
,,mes "nonsecure"
,,;...
,
,case EN_SETFOCUS<<16|7 ;;the text box focused
,CheckRadioButton hDlg 3 6 6
,;this also can be used: but id(6 hDlg); act lParam
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
|