Travis Posted May 9, 2009 Share Posted May 9, 2009 I have a program that will open another window when a button is pressed. I manged to get it to close only that window if the X button is pressed, but whenever I create my own buttons on that Window it says the variable is not defined. Here is my example Case $msg[0] = $egg Global $lol MsgBox(0,"oh noes","you fund the egg!") $lol = GUICreate("Très bien!",310,400) GUISetState(@SW_SHOW,$lol) GUICtrlCreatePic(@ScriptDir & "\cake.GIF",1,1,307,370) $cegg = GUICtrlCreateButton("Ok, fun's over!",105,375,100,25) Case $msg[0] = $cegg GUIDelete($lol) EndSelect WEnd However, I get this error when trying to compile C:\Documents and Settings\Travis\My Documents\Google Suggest API.au3 (60) : ==> Variable used without being declared.: Case $msg[0] = $cegg Case $msg[0] = ^ ERROR Now my question is, how can I get the GUI to respond to those clicks? It seems the variable for the button is isolated to just that one Case, eventhough I manged to get the $GUI_EVENT_CLOSE to work for _both_ of my window, with this Case $msg[0] = $GUI_EVENT_CLOSE If $msg[1] = $main Then FileDelete(@ScriptDir & "\output.file") Exit Else GUIDelete($lol) EndIf Can anybody clear this up, I looked on the online documentation too. Thanks in advance. Link to comment Share on other sites More sharing options...
Valuater Posted May 9, 2009 Share Posted May 9, 2009 1 Place at the top of the Script Global $cegg this might not work correctly, but you can give it a try 2 Create the GUI before the Case statements and use the buttons to "hide" and "Show" the GUI rather than create and delete it 3 you can place a secondary while/wend loop when the GUI is created. then that loop will exit when the GUI is closed 8) Link to comment Share on other sites More sharing options...
Travis Posted May 9, 2009 Author Share Posted May 9, 2009 1Place at the top of the ScriptGlobal $ceggthis might not work correctly, but you can give it a try2Create the GUI before the Case statements and use the buttons to "hide" and "Show" the GUI rather than create and delete it3you can place a secondary while/wend loop when the GUI is created. then that loop will exit when the GUI is closed8)Thank you very much. I tried the first and third already, but did not think of the second and that is what got it to work. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now