Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get which option was pressed
#3
Function Option_Array_Dialog
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages

str controls = "3 4 5"
str o3Opt o4Opt o5Opt
if(!ShowDialog("Option_Array_Dialog" &Option_Array_Dialog &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 134 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Button 0x54032009 0x0 10 8 48 12 "Option 1"
;4 Button 0x54002009 0x0 10 26 48 12 "Option 2"
;5 Button 0x54002009 0x0 10 44 48 13 "Option 3"
;6 Button 0x54032000 0x0 112 8 76 32 "Check which Option"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 6
,Acc Option1=acc("Option 1" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt1=Option1.State()
,Acc Option2=acc("Option 2" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt2=Option2.State()
,Acc Option3=acc("Option 3" "RADIOBUTTON" win("Dialog" "#32770") "Button" "" 0x1001)
,int Opt3=Option3.State()
,ARRAY(int) a.create(3) ;;create array of integers
,a[0]=Opt1 ;;set option 0 element
,a[1]=Opt2 ;;set option 1 element
,a[2]=Opt3 ;;set option 2 element
,int el=a[0] ;;get element
,out a[0]
,out a[1]
,out a[2]
,if(a[0] = 1048592)
,,mes("Option 1 was selected")
,,ret
,if(a[1] = 1048592)
,,mes("Option 2 was selected")
,,ret
,if(a[2] = 1048592)
,,mes("Option 3 was selected")
,,ret
,if(a[0] and a[1] and a[2]=1048576)
,,mes "No options were selected" "Please Pick Something" "!"
,case IDOK
,case IDCANCEL
ret 1

I don't know exactly why the numbers are not 0 and 16 for the states of the checkboxes. I did some work a while ago and that's how I discovered the 1048592
and 1048576. I think I asked Gintaras about this but didn't get an answer. Anyways, that is probably why you can't get it to work when you put it in your dialog but can when it is a stand alone macro.

I really don't think you need to use arrays here...really arrays so far for me seem to be most useful to grab large amounts of data and then break it up. Don't give up on arrays though...you will need them!


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)