Sign in to follow this  
Followers 0
DobraGolonka

GUI Problem with Variables

3 posts in this topic

I have two GUIs (Main Menu & Import Menu).

I can switch from the Main Menu to the Import Menu, and then return back to the Main Menu, but all button functionality seems to be 'lost' upon this return. I can't Exit or Close the window.

I have stuck in a few lines of debug here and there, but, the hex codes didn't really mean much to me :P

Can anyone give me any pointers on where I'm going wrong??? And, am I choosing the right approach in using individual functions for each GUI?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Global Const $ScriptName = "TV Episode Import and Update"

MainMenu()

; #FUNCTION# ==================================================================
; Name ..........: MainMenu()
;==============================================================================
;
Func MainMenu()
    
    Local $frmMainMenu, $btnImport, $btnUpdate, $btnExit
    Local $msg
    
    $frmMainMenu = GUICreate($ScriptName & ": Main Menu", 400, 200)
    $btnImport = GUICtrlCreateButton("Import", 50, 55, 120, 30)
    $btnUpdate = GUICtrlCreateButton("Update", 230, 55, 120, 30)
    $btnExit = GUICtrlCreateButton("Exit", 140, 100, 115, 30)
    GUICtrlSetState ($btnUpdate, $GUI_DISABLE)
    GUISetState(@SW_SHOW, $frmMainMenu)

    While 1
        $msg = GUIGetMsg(1)

        Select
            Case $msg[0] = $btnImport
                GUISetState(@SW_HIDE, $frmMainMenu)
                ImportMenu()

        ; Case $msg[0] = $btnUpdate

            Case $msg[0] = $btnExit
                dbg("The value of Variable 1 at this time is " & $msg[0] & " " & $msg[1] & " " & $msg[2])
                ExitLoop
                
            Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $frmMainMenu 
                ExitLoop
        EndSelect
    WEnd

EndFunc

; #FUNCTION# ==================================================================
; Name ..........: ImportMenu()
;==============================================================================
;
Func ImportMenu()

    Local $frmImportMenu, $radioIMDb, $radioTVRage, $radioTVcom, $radio4, _
          $radio5, $cmbSeriesName, $btnSubmit, $btnMainMenu
    Local $msg
    
    $frmImportMenu = GUICreate($ScriptName & ": Import Menu", 400, 200)
    GUICtrlCreateGroup("Source:", 10, 10, 140, 170)
    $radioIMDb =    GUICtrlCreateRadio("IMDb", 20, 30, 120, 20)
    $radioTVRage =  GUICtrlCreateRadio("TVRage", 20, 60, 120, 20)
    $radioTVcom =   GUICtrlCreateRadio("TV.com", 20, 90, 120, 20)
    $radio4 =       GUICtrlCreateRadio("<TBA>", 20, 120, 130, 20)
    $radio5 =       GUICtrlCreateRadio("<TBA>", 20, 150, 120, 20)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    GUICtrlSetState($radioIMDb, $GUI_CHECKED)
    GUICtrlSetState ($radio4, $GUI_DISABLE)
    GUICtrlSetState ($radio5, $GUI_DISABLE)
    GUICtrlCreateGroup("Series Name:", 160, 10, 230, 90)
    GUICtrlCreateLabel("Enter a Series Name:", 170, 30)
    $cmbSeriesName = GUICtrlCreateCombo ("", 170, 60, 210)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $btnSubmit = GUICtrlCreateButton("Submit", 175, 145, 90, 30)
    $btnMainMenu = GUICtrlCreateButton("Main Menu", 285, 145, 90, 30)
    GUISetState(@SW_SHOW, $frmImportMenu)

    While 1
        $msg = GUIGetMsg(1)

        Select
            Case $msg[0] = $btnMainMenu
                GUISetState(@SW_HIDE, $frmImportMenu)
                MainMenu()
                
            Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $frmImportMenu
                GUISetState(@SW_HIDE, $frmImportMenu)
                MainMenu()
        EndSelect
    WEnd
    Return
EndFunc

Func dbg($msg)
    DllCall("kernel32.dll", "none", "OutputDebugString", "str", $msg)
EndFunc

Regards

DG

Share this post


Link to post
Share on other sites



Hi,

Try looking up GUISwitch () in the helpfile.

Cheers,

Brett

:P - the answers to the hardest problems are always the simplest!

Thanks for that speedy response :-)

DG

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