Jump to content

Recommended Posts

Posted

Good morning all! I was trying out the Managing Multiple GUI tutorial and I cant seem to get GUI2's Msgbox to fire. I renamed the variables so it is easier for me to follow but the code is all the same as the tutorial. Any help would be greatly appreciated since id love to use this feature. Thanks!

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Global $hGUI2 = 9999, $b_MBox2 ; Predeclare the variables with dummy values to prevent firing the Case statements, only for GUI this time

gui1()

Func gui1()
    Local $hGUI1 = GUICreate("Gui 1", 200, 200, 100, 100)
    Local $b_MBox1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30)
    Local $b_SGUI2 = GUICtrlCreateButton("Show Gui 2", 10, 60, 80, 30)
    GUISetState()

    Local $aMsg
    While 1
        $aMsg = GUIGetMsg(1) ; Use advanced parameter to get array
        Switch $aMsg[1] ; check which GUI sent the message
            Case $hGUI1
                Switch $aMsg[0] ; Now check for the messages for $hGUI1
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we exit <<<<<<<<<<<<<<<
                        ExitLoop
                    Case $b_MBox1
                        MsgBox($MB_OK, "MsgBox 1", "Test from Gui 1")
                    Case $b_SGUI2
                        GUICtrlSetState($b_SGUI2, $GUI_DISABLE)
                        gui2()
                EndSwitch
            Case $hGUI2
                Switch $aMsg[0] ; Now check for the messages for $g_hGUI2
                    Case $GUI_EVENT_CLOSE ; If we get the CLOSE message from this GUI - we just delete the GUI <<<<<<<<<<<<<<<
                        GUIDelete($hGUI2)
                        GUICtrlSetState($b_SGUI2, $GUI_ENABLE)
                    Case $b_MBox2
                        MsgBox($MB_OK, "MsgBox", "Test from Gui 2")

                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>gui1

Func gui2()
    $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
    Local $b_MBox2 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
    GUISetState()
EndFunc   ;==>gui2

 

Posted

Ok, I just copied the MessageLoop mode example from another post and it seems to work, while the copy from the Wiki/Tutorial didn't work...huh...

So im going to look at both and see what is different! 

Posted

ok, just on a quick glance, the only difference I found was that the Wiki/Tutorial shows this under Func gui2()

--> Local $g_idButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)

while the copy from the other post shows this under Func gui2()

--> $g_idButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)

Since in the tutorial it uses Local, does that make it unseen outside the Func gui2()? 

 

 

Posted

Hahaha!

Nice one @Nine! That's what I thought!! You commented before I could finish the post above!! That is how it was declared in the tutorial...just didn't catch it...wondering whom I let know so that can get fixed in the wiki/tutorial for us bumbling newbies!!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...