dorst622 Posted March 18, 2010 Share Posted March 18, 2010 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. Link to comment Share on other sites More sharing options...
Valuater Posted March 18, 2010 Share Posted March 18, 2010 I, and most people here, need to see more code so I/we can tell what you are trying to accomplish 8) Link to comment Share on other sites More sharing options...
dorst622 Posted March 18, 2010 Author Share Posted March 18, 2010 (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 March 18, 2010 by dorst622 Link to comment Share on other sites More sharing options...
Malkey Posted March 18, 2010 Share Posted March 18, 2010 In this example it is possible to close either "form1" or "form2" first, then close the remaining GUI.expandcollapse popup#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 Link to comment Share on other sites More sharing options...
dorst622 Posted March 19, 2010 Author Share Posted March 19, 2010 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now