Sign in to follow this  
Followers 0
dorst622

GUI: closing current form

5 posts in this topic

how do you close a current form?

i have 2 forms

form 1 call form 2.

than i like to close form 2.

how do i do that.

Share this post


Link to post
Share on other sites



I, and most people here, need to see more code so I/we can tell what you are trying to accomplish

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

my bad.

here is the code

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

form1()

func form1()
    $form1 = GUICreate("form1")
    
    $Button_0 = GUICtrlCreateButton("Form2", 20, 10, 100)
    
    GUISetState() 
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_0
                form2()
        EndSelect
    WEnd
EndFunc

func form2()
    $form1 = GUICreate("form2")
    $Button_1 = GUICtrlCreateButton("close", 20, 10, 100)
    GUISetState() 
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                     ;;;;;;close current form).how to close current for
        EndSelect
    WEnd
EndFunc

how do you close a current form?

i have 2 forms

form 1 call form 2.

than i like to close form 2.

how do i do that.

Edited by dorst622

Share this post


Link to post
Share on other sites

In this example it is possible to close either "form1" or "form2" first, then close the remaining GUI.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

form1()

Func form1()
    Local $msg, $Button_1, $Button_0, $form1, $form2, $aGuiPos
    $form1 = GUICreate("form1")
    $Button_0 = GUICtrlCreateButton("Form2", 20, 10, 100)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                If WinExists("form2") = 1 And BitAND(WinGetState("form2"), 8) Then ; If form2 exits & is active.
                    GUIDelete($form2)
                ElseIf WinExists("form1") = 1 And BitAND(WinGetState("form1"), 8) Then ; If form1 exits & is active.
                    GUIDelete($form1)
                EndIf
            Case $Button_0
                If WinExists("form2") <> 1 Then
                    $form2 = GUICreate("form2")
                    $Button_1 = GUICtrlCreateButton("close", 20, 10, 100)
                    GUISwitch($form2)

                    $aGuiPos = WinGetPos("form2"); Avoid superimposing GUIs
                    WinMove("form2", "", $aGuiPos[0] + 200, $aGuiPos[1] - 100)
                    GUISetState()
                EndIf
            Case $Button_1
                If WinExists("form2") = 1 Then GUIDelete($form2)
        EndSwitch

        If WinExists("form2") <> 1 And WinExists("form1") <> 1 Then Exit

    WEnd
EndFunc ;==>form1

Share this post


Link to post
Share on other sites

tks alot.

this is what i need.

In this example it is possible to close either "form1" or "form2" first, then close the remaining GUI.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

form1()

Func form1()
    Local $msg, $Button_1, $Button_0, $form1, $form2, $aGuiPos
    $form1 = GUICreate("form1")
    $Button_0 = GUICtrlCreateButton("Form2", 20, 10, 100)
    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                If WinExists("form2") = 1 And BitAND(WinGetState("form2"), 8) Then ; If form2 exits & is active.
                    GUIDelete($form2)
                ElseIf WinExists("form1") = 1 And BitAND(WinGetState("form1"), 8) Then ; If form1 exits & is active.
                    GUIDelete($form1)
                EndIf
            Case $Button_0
                If WinExists("form2") <> 1 Then
                    $form2 = GUICreate("form2")
                    $Button_1 = GUICtrlCreateButton("close", 20, 10, 100)
                    GUISwitch($form2)

                    $aGuiPos = WinGetPos("form2"); Avoid superimposing GUIs
                    WinMove("form2", "", $aGuiPos[0] + 200, $aGuiPos[1] - 100)
                    GUISetState()
                EndIf
            Case $Button_1
                If WinExists("form2") = 1 Then GUIDelete($form2)
        EndSwitch

        If WinExists("form2") <> 1 And WinExists("form1") <> 1 Then Exit

    WEnd
EndFunc ;==>form1

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