KennethWalle

handling multiple gui

11 posts in this topic

Hi.
 
When i have multiple gui, how do i force close the old gui when open a new?

#include



Global $hButton3 = 9999

gui1()

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

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $hButton1
MsgBox("", "MsgBox 1", "Test from Gui 1")
Case $hButton2
GUICtrlSetState($hButton2, $GUI_DISABLE)
gui2()
Case $hButton3
MsgBox("", "MsgBox 2", "Test from Gui 2")
EndSwitch
WEnd
EndFunc ;==>gui1

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

Share this post


Link to post
Share on other sites



KW,

It looks like you took the code you posted directly out of the Wiki that JL pointed you to.  Did you read the entire article?  If so, what do you not understand?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

KW,

It looks like you took the code you posted directly out of the Wiki that JL pointed you to.  Did you read the entire article?  If so, what do you not understand?

kylomas

Yes i actually did, if you test the code, you will see when you open the 2nd gui, "gui1" doesnt close. That is what i want. 

So in the project im currently working on, i have alote more than 2 gui. Kinda anoying haveing 100 of windows open.

Share this post


Link to post
Share on other sites

when you open the 2nd gui, "gui1" doesnt close. That is what i want

So simply add the code to close it. ;)

#include <GUIConstantsEx.au3>

Global $hButton3 = 9999

gui1()

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

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton1
                MsgBox("", "MsgBox 1", "Test from Gui 1")
            Case $hButton2
                GUIDelete($hGUI1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                gui2()
            Case $hButton3
                MsgBox("", "MsgBox 2", "Test from Gui 2")
        EndSwitch
    WEnd
EndFunc   ;==>gui1

Func gui2()
    $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
    $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
    GUISetState()
EndFunc   ;==>gui2
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

So simply add the code to close it. ;)

#include <GUIConstantsEx.au3>

Global $hButton3 = 9999

gui1()

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

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
            Case $hButton1
                MsgBox("", "MsgBox 1", "Test from Gui 1")
            Case $hButton2
                GUIDelete($hGUI1) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                gui2()
            Case $hButton3
                MsgBox("", "MsgBox 2", "Test from Gui 2")
        EndSwitch
    WEnd
EndFunc   ;==>gui1

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

 

Awesome, thanks. it worked :)

Share this post


Link to post
Share on other sites

100 windows???

Give us the elevator version of what you are doing and maybe you will get some alternative ideas.


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

100 windows???

Give us the elevator version of what you are doing and maybe you will get some alternative ideas.

yeah that was just a random number as you would use it back and forth.

What im working on is an poker push/fold strategy

Nearly finish thou, but theres still some anoying bugs.

Share this post


Link to post
Share on other sites

KennethWalle,

 

What im working on is an poker push/fold strategy

You might not have read the Forum rules since your arrival. Please do read them - particularly the bit about not discussing game automation - before you post again. ;)

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

KennethWalle,

 

You might not have read the Forum rules since your arrival. Please do read them - particularly the bit about not discussing game automation - before you post again. ;)

M23

 

Sorry, ill shut it :P

in my defence, i havent posted anything regarding my script.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

KennethWalle,

Indeed you have not, which is why you got a friendly warning and nothing more. ;)

M23

Edited by Melba23
Typo
1 person likes this

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