Jump to content

How to delete a gui and run another gui


Recommended Posts

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

 

Link to comment
Share on other sites

  • Moderators

@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?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

#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

 

Link to comment
Share on other sites

  • Moderators
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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...