Posts: 76
Threads: 37
Joined: Nov 2018
07-22-2020, 08:09 PM
(This post was last modified: 07-22-2020, 08:11 PM by ilcaa.)
i can initialize a control before the ShowDialog(), c3Che = 1
but
in a Dlg Procedure, i
cannot change the state of the checkbox with c3Che = 0
str c3Che e4 b5But
c3Che = 1 ;; initializes checkbox with a check
int hDlg=ShowDialog("" &sub.DlgProc &controls 0 1 1)
___________________________________________________
sel wParam
case IDOK
case IDCANCEL
case 5 ;;button
c3Che = 0 ;; doesnt work
can you explain why it doesnt work in the sub procedure? it recognizes that 3 is a control via the Case... does it not recognize the str variable? whats the better option for changing state of controls in sub-procedure. thanks
Posts: 1,338
Threads: 61
Joined: Jul 2006
var c3Che is not known inside the dialog procedure
you can however use it by adding the v attribute to #sub DlgProc and calling DT_GetControls later inside the dialog.Then can use DT_SetControl or DT_SetControls to change it's value
example
Function
Dialog9
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Button 0x54012003 0x0 16 48 48 10 "Check"
;4 Edit 0x54030080 0x200 72 48 96 12 ""
;5 Button 0x54032000 0x0 172 48 48 14 "Button"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""
str controls = "3 4"
str c3Che e4
c3Che=1
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc v;; must have v attribute here to use Option1
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 5 ;;Button
,;;Option1 using v attribute and calling DT_GETControls and DT_SetControl
,DT_GetControls(hDlg)
,c3Che=0
,DT_SetControl(hDlg 3 c3Che)
ret 1
even simpler without using v attribute and DT_GetControls
Function
Dialog9
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;3 Button 0x54012003 0x0 16 48 48 10 "Check"
;4 Edit 0x54030080 0x200 72 48 96 12 ""
;5 Button 0x54032000 0x0 172 48 48 14 "Button"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040A00 "*" "" "" ""
str controls = "3 4"
str c3Che e4
c3Che=1
if(!ShowDialog(dd &sub.DlgProc &controls)) ret
#sub DlgProc
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case 5 ;;Button
,DT_SetControl(hDlg 3 "0")
ret 1
Posts: 76
Threads: 37
Joined: Nov 2018
excellent, that works
i also figured out this works as well