Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Dialog Question
#1
I know I am just missing something, but I cannot find the answer.

I have a dialog box that has 2 option buttons, 1 static text and 1 edit text. Option button1 is default and the 2 texts are disabled. I would like the 2 texts to be enabled if option button 2 is pressed. And then, disabled again if option button 1 is pressed again.

What am I missing?

Thank you.
#2
When creating new dialog, select "Smart dialog". This will create new function ("dialog procedure") that is called by Windows whenever the user clicks a button or does something else with the dialog. Use the "Events" button in the Dialog Editor to insert code that will be executed on click of that radio button. When you click Events, are shown mostly used messages (events) for the dialog or control that is active (with red dot). When you select a message and click OK, in the function is inserted case for that control/message. There you can write code that must be executed on that message. To enable/disable controls, use function EnableWindow, which can be inserted using the Window dialog from the floating toolbar.

Example function dialog_472:

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

str controls = "3 4 6"
str o3Opt o4Opt e6

o3Opt=1

if(!ShowDialog("dialog_472" &dialog_472 &controls)) ret

;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 0x54032009 0x0 8 8 48 12 "Option first"
;4 Button 0x54002009 0x0 8 22 48 12 "Option next"
;5 Static 0x5C000000 0x0 8 44 48 13 "Text"
;6 Edit 0x5C030080 0x200 58 44 96 14 ""
;END DIALOG
;DIALOG EDITOR: "" 0x2010800 "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [3,4] ;;when clicked option button whose id is 3 or 4
,EnableWindow(id(5 hDlg) wParam=4) ;;enable static 5 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(6 hDlg) wParam=4) ;;enable edit 6 if button 4 is clicked, disable if other button is clicked
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1

Here code used to show the dialog is in the same function, but it also can be in some other macro. Here "case [3,4]" is used instead of "case 3 ... case 4" to reduce code size.
#3
Thanks once again.
#4
I do not know what I am doing wrong. I used this example to create my dialog and everything seams to work ok but when I select a WebPage to go to and press the go to web page button it says that I need to select a WebPage. Can someone please help?

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

str controls = "3 4 7 8 9"
str o3Opt o4Opt o7Yah o8Goo o9MSN

o3Opt=1

if(!ShowDialog("dialog_473" &dialog_473 &controls)) ret


;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 0x54032009 0x0 8 8 48 12 "Option first"
;4 Button 0x54002009 0x0 8 22 48 12 "Option next"
;5 Static 0x5C000000 0x0 8 44 130 10 "What Web Page do you want to use?"
;7 Button 0x5C032009 0x0 8 58 48 12 "Yahoo"
;8 Button 0x5C002009 0x0 8 74 48 12 "Google"
;9 Button 0x5C002009 0x0 8 90 48 12 "MSN"
;6 Button 0x5C032000 0x0 82 70 50 22 "Go to Web Page"
;END DIALOG
;DIALOG EDITOR: "" 0x2030001 "" "" ""

ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case [3,4] ;;when clicked option button whose id is 3 or 4
,EnableWindow(id(5 hDlg) wParam=4) ;;enable static 5 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(6 hDlg) wParam=4) ;;enable button 109 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(7 hDlg) wParam=4) ;;enable option button 7 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(8 hDlg) wParam=4) ;;enable option button 8 if button 4 is clicked, disable if other button is clicked
,EnableWindow(id(9 hDlg) wParam=4) ;;enable option button 9 if button 4 is clicked, disable if other button is clicked
,
,case 6
,if(o7Yah!=1 and o8Goo!=1 and o8Goo!=1)
,,mes("You need to select a Web Page ")
,if(o7Yah=1)
,,run "http://www.yahoo.com"
,if(o8Goo=1)
,,run "http://www.google.com"
,if(o8Goo=1)
,,run "http://www.google.com"
,
,case IDOK DT_Ok hDlg
,case IDCANCEL DT_Cancel hDlg
ret 1
#5
Change case 6 to this and you'll be rockin'...

Function dialog_473
Code:
Copy      Help
case 6
,Acc Yah=acc("Yahoo" "RADIOBUTTON" win("Form" "#32770") "Button" "" 0x1001)
,int state1=Yah.State()
,Acc Goo=acc("Google" "RADIOBUTTON" win("Form" "#32770") "Button" "" 0x1001)
,int state2=Goo.State()
,Acc MSN=acc("MSN" "RADIOBUTTON" win("Form" "#32770") "Button" "" 0x1001)
,int state3=MSN.State()
,out state1
,out state2
,out state3
,if(state1=1048576 and state2=1048576 and state3=1048576)
,,mes("You need to select a Web Page ")
,if(state1=1048592)
,,run "http://www.yahoo.com"
,if(state2=1048592)
,,run "http://www.google.com"
,if(state3=1048592)
,,run "http://www.google.com"

This is how I would do it, don't know if there is a better way.
#6
I do not now how this works yet but thanks


Forum Jump:


Users browsing this thread: 1 Guest(s)