Sign in to follow this  
Followers 0
Travis

Responding to button clicks with multiple GUIs

3 posts in this topic

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.

Share this post


Link to post
Share on other sites



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)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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)

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0