Jump to content
Collins

How to delete a gui and run another gui

Recommended Posts

Collins

Hello all. How do i close a first gui and then call a function with a different gui..

 

Below is my code

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idOK
           Call("secondGui")
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example





Func secondGui()

    ; Create a GUI with various controls.
    Local $sGUI = GUICreate("SECONDGUI")
    Local $exit = GUICtrlCreateButton("EXIT", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $sGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $exit
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($sGUI)
    EndFunc

 

Share this post


Link to post
Share on other sites
mikell

You call secondGui() before the Exitloop, so you go into the 2nd While loop before exiting the 1st one... and the GuiDelete() currently works after exiting the While loop  ;)

Share this post


Link to post
Share on other sites
Collins

can you give me sample please

 

Share this post


Link to post
Share on other sites
JLogan3o13

@Collins why do you need an example, the explanation was very clear:

 

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idOK
           Call("secondGui")
                ExitLoop <=====You exit your Loop HERE, BEFORE calling GUIDelete|
                                                                                |
        EndSwitch                                                               |
    WEnd                                                                        |
                                                                                |
    ; Delete the previous GUI and all controls.                                 |
    GUIDelete($hGUI)<===========================================================| Here
EndFunc   ;==>Example

So if you want to close the first gui, where do you suppose you need to move the GuiDelete call?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
jchd

That, and you don't need to use Call(), just invoke your function.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Collins

Thank you guys

Share this post


Link to post
Share on other sites
Collins
2 hours ago, JLogan3o13 said:

@Collins why do you need an example, the explanation was very clear:

 

#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idOK
           Call("secondGui")
                ExitLoop <=====You exit your Loop HERE, BEFORE calling GUIDelete|
                                                                                |
        EndSwitch                                                               |
    WEnd                                                                        |
                                                                                |
    ; Delete the previous GUI and all controls.                                 |
    GUIDelete($hGUI)<===========================================================| Here
EndFunc   ;==>Example

So if you want to close the first gui, where do you suppose you need to move the GuiDelete call?

i tried your code. and the first gui does not delete until the second gui is closed

Share this post


Link to post
Share on other sites
Collins
#include <GUIConstantsEx.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example")
    Local $idOK = GUICtrlCreateButton("OK", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idOK
           Call("secondGui")
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
   GUIDelete($hGUI)
EndFunc   ;==>Example





Func secondGui()

    ; Create a GUI with various controls.
    Local $sGUI = GUICreate("SECONDGUI")
    Local $exit = GUICtrlCreateButton("EXIT", 310, 370, 85, 25)

    ; Display the GUI.
    GUISetState(@SW_SHOW, $sGUI)

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $exit
                ExitLoop

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($sGUI)
    EndFunc

 

Share this post


Link to post
Share on other sites
JLogan3o13
3 hours ago, Collins said:

i tried your code. and the first gui does not delete until the second gui is closed

Then you are obviously not reading it correctly, as your code in the last post is still wrong. Not sure how I can spoon feed it to you any more clearly than I did before, or any more clearly than mikell did before me  - Move the first GuiDelete up above the First ExitLoop


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
mikell

@JLogan3o13

To write the text in italic/red is a pretty good idea. It could work  :lmao:

Share this post


Link to post
Share on other sites
jchd

Try voodoo guys.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites
Collins

Thank you guys.. I really appreciate your help.. It worked

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

×