Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting a default value in a dialog box
#5
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
Code:
Copy      Help
\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


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)