Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Option buttons in dialog
#1
Hi Gintaras,

Please can you assist me with returning what option button has been selected on the dialog and returned to the macro, when the start button is pressed.

Function Hot_Dialog
Code:
Copy      Help
/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 287 130 "The Project"
;3 Button 0x54032000 0x0 6 4 50 38 "Start"
;4 Button 0x54032000 0x0 6 46 50 38 "Stop"
;9 Edit 0x54200844 0x20000 62 20 222 104 ""
;5 Button 0x54032009 0x0 62 6 100 14 "Table 1"
;6 Button 0x54002009 0x0 164 6 120 14 "Table 2"
;2 Button 0x54030000 0x4 6 88 50 38 "Close"
;7 Button 0x54020007 0x0 0 30 108 100 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "9 5 6"
str e9 o5Dub o6Sma
if(!ShowDialog("Hot_Dialog" &Hot_Dialog &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,TO_Check win("The Project" "#32770") "5 -6" 1
,/GdiObject- brush=CreateSolidBrush(ColorFromRGB(0 176 255))
,/SetDlgItemText hDlg 6 ""
,case WM_DESTROY
,/case WM_CTLCOLORDLG ret brush
,case WM_COMMAND goto messages2
,case WM_APP
,int c=id(9 hDlg)
,SendMessage c EM_SETSEL 1000000000 1000000000
,SendMessage c EM_REPLACESEL 0 F"{lParam%%s}[]"


ret
;messages2
sel wParam
,case 3
,str toPlay
,if o5Dub=1
,,toPlay="table1"
,else
,,toPlay="table2"
,SetDlgItemText hDlg 3 "Running"
,EnableWindow id(3 hDlg) 0; EnableWindow id(4 hDlg) 1
,mac "Hot" " " hDlg toPlay ;;_s.getwintext(id(6 hDlg))

,
,case 4
,SetDlgItemText hDlg 3 "Start"
,shutdown -6 0 "Hot"
,EnableWindow id(3 hDlg) 1; EnableWindow id(4 hDlg) 0
,
,case IDCANCEL
ret 1

When start is clicked, either option 1 or 2 will be selected and I need to be able to send this to macro Hot.

Function Hot
Code:
Copy      Help
function hDlg toPlay

inpp "[*599214908CAEC73F02*]" "Password Required" "Please Enter Password  To Begin" 1 ;;show password input box. If Cancel or incorrect password, end macro.

ARRAY(str) number_locations;; co-ordinates of each number 0 - 36

Also is TO_Check the best way to set a default checked option?

Kind Regards
Matt
#2
you were close just had a couple mistakes

Function Hot_Dialog
Code:
Copy      Help
/Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 287 130 "The Project"
;3 Button 0x54032000 0x0 6 4 50 38 "Start"
;4 Button 0x54032000 0x0 6 46 50 38 "Stop"
;9 Edit 0x54200844 0x20000 62 20 222 104 ""
;5 Button 0x54032009 0x0 62 6 100 14 "Table 1"
;6 Button 0x54002009 0x0 164 6 120 14 "Table 2"
;2 Button 0x54030000 0x4 6 88 50 38 "Close"
;7 Button 0x54020007 0x0 0 30 108 100 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "" "" "" ""

str controls = "9 5 6"
str e9 o5Dub o6Sma
o5Dub=1
if(!ShowDialog("Hot_Dialog" &Hot_Dialog &controls)) ret
ret
;messages
sel message
,case WM_INITDIALOG
,/TO_Check win("The Project" "#32770") "5 -6" 1
,/GdiObject- brush=CreateSolidBrush(ColorFromRGB(0 176 255))
,/SetDlgItemText hDlg 6 ""
,EnableWindow id(4 hDlg) 0
,case WM_DESTROY
,/case WM_CTLCOLORDLG ret brush
,case WM_COMMAND goto messages2
,case WM_APP
,int c=id(9 hDlg)
,SendMessage c EM_SETSEL 1000000000 1000000000
,SendMessage c EM_REPLACESEL 0 F"{lParam%%s}[]"


ret
;messages2
sel wParam
,case 3
,str toPlay
,if but(id(5 hDlg)) ;;is checked?
,,out "checked"
,,toPlay="table1"
,else
,,out "unchecked"
,,toPlay="table2"
,SetDlgItemText hDlg 3 "Running"
,EnableWindow id(3 hDlg) 0; EnableWindow id(4 hDlg) 1
,mac "Hot" "" hDlg toPlay ;;_s.getwintext(id(6 hDlg))

,
,case 4
,SetDlgItemText hDlg 3 "Start"
,shutdown -6 0 "Hot"
,EnableWindow id(3 hDlg) 1; EnableWindow id(4 hDlg) 0
,
,case IDCANCEL
ret 1


Hot_Dialog the variable o5Dub is used only for ShowDialog function to passed a value to the control and or to receive a value when show dialog returns.Cant be used in dialog itself.
Do you always want to select table 1 button when showing dialog? or something else.u can set the value before calling ShowDialog and don't have to use ToCheck at all.
o5Dub=1 if u want table 1 to be default.
If you want table 2 to be default
o6Sma=1

your mac code was a little off as well
you had
mac "Hot" " " hDlg toPlay ;;_s.getwintext(id(6 hDlg))
should be
mac "Hot" "" hDlg toPlay ;;_s.getwintext(id(6 hDlg)) no space between quotes for command argument
in Function Hot you had toPlay variable as an int needed to be a string

Function Hot
Code:
Copy      Help
function hDlg ~toPlay
out hDlg
out toPlay
inpp "[*599214908CAEC73F02*]" "Password Required" "Please Enter Password To Begin" 1 ;;show password input box. If Cancel or incorrect password, end macro.

ARRAY(str) number_locations;; co-ordinates of each number 0 - 36
#3
Awesome Kevin, thank you so much for your help and explanation. It is very much appreciated Smile

Kind Regards


Forum Jump:


Users browsing this thread: 1 Guest(s)