Sign in to follow this  
Followers 0
Damein

How to close just one GUI, but not the other in a script

3 posts in this topic

So I have this script that I want to open up a 2nd GUI, and after logging in I want to close it and go back to the first GUI.

Here's my code:

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <IE.au3>

HotKeySet("{`}", "Show")

Global $PanTask, $PanGUI, $CreateWindow, $LoginButton, $TrainButton, $Gui2

Opt("GUIOnEventMode", 1)

$Gui = GuiCreate("Trainer",300,200)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreatePic("Background.jpg", 0, 0, 300, 200)
GUICtrlSetState(-1, $GUI_DISABLE)
$LoginButton = GuiCtrlCreateButton("Login", 10, 90, 62, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Users\***\Documents\Website\Training\Login.bmp", 22)
GUICtrlSetOnEvent($LoginButton, "Login")
$TrainButton = GuiCtrlCreateButton("Train", 200, 90, 62, 32, $BS_BITMAP)
GUICtrlSetImage(-1, "C:\Users\***\Documents\Website\Training\Train.bmp", 22)
GUICtrlSetOnEvent($TrainButton, "Train")


GUISwitch($Gui)
GUISetState(@SW_SHOW)

While 1
  Sleep(1000)  ; Idle around
WEnd

Func Login()
        $Gui2 = GuiCreate("Login", 200, 200)
        GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
        GUISwitch($Gui2)
        GuiSetState(@SW_SHOW)
    EndFunc
    
Func Train()
        MsgBox(0, "GUI Event", "You pressed train")
    EndFunc
    
Func Show()
    GuiSetState(@SW_SHOW)
EndFunc

Func CLOSEClicked()
      If @GUI_WINHANDLE = $Gui Then
          MsgBox(0, "Test", "You clicked on 1st window")
    Exit
    EndIf
If @GUI_WINHANDLE = $Gui2 Then
    MsgBox(0, "Test", "You clicked on 2nd window")
  EndIf 
EndFunc

So, when you click "Login" it will open a 2nd GUI, and when I click close I want it to only close this GUI, not exit like the first one.

Thanks!


MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Share this post


Link to post
Share on other sites



Damein,

Look at the Managing Multiple GUIs tutorial in the Wiki. :(

It shows you how you do what you want. :graduated:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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