Jump to content
Sign in to follow this  
autocomplex

Multiple GUI Display Problem

Recommended Posts

autocomplex

I am trying to get a script to work that allows the user to select which gui to display. It then hides the selection screen and displays the GUI, that the user has selected (ALL OF THIS WORKS ). However, when the user clicks a menu button to go back to the selection screen it supposed to hide the user-defined gui and once again display the selection gui, thus brining us back to the begining.

#include <GUIConstants.au3>

Global $selection = 0

;ROOT GUI
$SELECTGUI = GUICreate("", 301, 186, 359, 202)
GUISetBkColor(0x000000)

$AFRadio = GUICtrlCreateRadio("", 162, 130, 15, 15)
$AFLabel = GUICtrlCreateLabel("Option 1", 177, 130, 95, 15)

$NextButton = GUICtrlCreateButton(">> Next >>", 104, 160, 75, 17, 0)

;OPTION 1 GUI

$AFGUI = GUICreate("AF", 266, 351, 359, 202)
GUISetFont(8, 400, 0, "@Arial Unicode MS")
GUISetBkColor(0x000000)

$AFMenuFile = GUICtrlCreateMenu("&File")
$AFMenuStart = GUICtrlCreateMenuItem("Start!", $AFMenuFile)
$AFMenuStop = GUICtrlCreateMenuItem("Stop", $AFMenuFile)
$AFSelection = GUICtrlCreateMenuItem("Selection Menu", $AFMenuFile)
$AFMenuPreferences = GUICtrlCreateMenuItem("Preferences", $AFMenuFile)
$AFMenuExit = GUICtrlCreateMenuItem("Exit", $AFMenuFile)

;MAIN LOOP
While 1
   
    Selection()
    BackToSelection()
   
   
    $msg = GUIGetMsg()
    Select
       
    Case $msg = $AFSelection
        BackToSelection()

    EndSelect

Wend   

Func Selection()
    While $selection = 0

    $msg = GUIGetMsg()
    Select
         

         Case $msg = $AFRadio
            $selection = 1
           
        Case $msg = $PCRadio
            $selection = 2
           
        Case $msg = $PFRadio
            $selection = 3
           
        Case $msg = $HMRadio
            $selection = 4 

        Case $msg = $NextButton 

        If $selection = 1 Then
        GUISetState(@SW_HIDE, $SELECTGUI)
        GUISetState(@SW_SHOW, $AFGUI)
        EndIf

    EndSelect   
    Wend
EndFunc 

Func BackToSelection()
    If $selection = 0 Then
        GUISetState(@SW_HIDE, $AFGUI)
        GUISetState(@SW_SHOW, $SELECTGUI)
    EndIf   
EndFunc

I cant get it to close the OPTION 1 GUI and display the ROOT GUI again.

Note, I know it says 4, but i shortened it to one for example purposes.

Share this post


Link to post
Share on other sites
martin

Can you post some code which we could run?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
stampy

When looking at the code it seems the selection variable never gets reset to 0 thus the backtoselection function won't do anything. When I work with multiple gui's I usually prefer to work with just one loop if I can. Otherwise I tend to chase my tail a lot. I'd end up doing it something like this:

#include <GUIConstants.au3>

Global $selection = 0

;ROOT GUI
$SELECTGUI = GUICreate("", 301, 186, 359, 202)
GUISetBkColor(0x000000)

$AFRadio = GUICtrlCreateRadio("", 162, 130, 15, 15)
$AFLabel = GUICtrlCreateLabel("Option 1", 177, 130, 95, 15)

$NextButton = GUICtrlCreateButton(">> Next >>", 104, 160, 75, 17, 0)

;OPTION 1 GUI

$AFGUI = GUICreate("AF", 266, 351, 359, 202)
GUISetFont(8, 400, 0, "@Arial Unicode MS")
GUISetBkColor(0x000000)

$AFMenuFile         = GUICtrlCreateMenu("&File")
$AFMenuStart        = GUICtrlCreateMenuItem("Start!", $AFMenuFile)
$AFMenuStop         = GUICtrlCreateMenuItem("Stop", $AFMenuFile)
$AFSelection        = GUICtrlCreateMenuItem("Selection Menu", $AFMenuFile)
$AFMenuPreferences  = GUICtrlCreateMenuItem("Preferences", $AFMenuFile)
$AFMenuExit         = GUICtrlCreateMenuItem("Exit", $AFMenuFile)

GUISetState(@SW_SHOW,$SELECTGUI)
;MAIN LOOP

Do
    $msg = GUIGetMsg(1)
    Select
        Case $msg[0] = $AFRadio And $msg[1] = $SELECTGUI
            GUISetState(@SW_HIDE, $SELECTGUI)
            GUISetState(@SW_SHOW, $AFGUI)
        ;Case $msg[0] = $PCRadio
        ;Case $msg[0] = $PFRadio
        ;Case $msg[0] = $HMRadio
        ;Case $msg[0] = $NextButton
        Case $msg[0] = $AFSelection And $msg[1] = $AFGUI
            GUISetState(@SW_HIDE, $AFGUI)
            GUISetState(@SW_SHOW, $SELECTGUI)
    EndSelect
Until $msg[0] = $GUI_EVENT_CLOSE

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  

×