faustf Posted September 20, 2016 Share Posted September 20, 2016 hi guys i have a gui with 2 child like matrioska parent (push button )--> 1 child in child (push button ) --->2 child when i colse the last child , is all ok the gui killed , but the 1 child or parent not possible close why?? expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $pass gui() Func gui() $Form1 = GUICreate("Form1", 623, 449, 192, 114) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $Button1 = GUICtrlCreateButton("Button1", 272, 128, 75, 25) GUICtrlSetOnEvent(-1, "Button1Click") GUISetState(@SW_SHOW) $pass=$Form1 GUISetOnEvent($GUI_EVENT_CLOSE, Form1Close) EndFunc While 1 Sleep(100) WEnd Func Button1Click() ; GUISetState( @SW_DISABLE , $Form1) $Form2 = GUICreate("Form1", 413, 305, 781, 414) $Button3 = GUICtrlCreateButton("Button1", 320, 208, 75, 25) GUICtrlSetOnEvent(-1, "Button1Click2") GUISetState(@SW_SHOW) $pass=$Form2 GUISetOnEvent($GUI_EVENT_CLOSE, Form1Close) EndFunc Func Button1Click2() $Form3 = GUICreate("Form1", 413, 305, 781, 414) $Button4 = GUICtrlCreateButton("Button1", 320, 208, 75, 25) GUICtrlSetOnEvent(-1, "Button1Click2") GUISetState(@SW_SHOW) $pass=$Form3 GUISetOnEvent($GUI_EVENT_CLOSE, Form1Close) EndFunc Func Form1Close() GUIDelete($pass) EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Link to comment Share on other sites More sharing options...
AutoBert Posted September 20, 2016 Share Posted September 20, 2016 You alway execute the same func: GUISetOnEvent($GUI_EVENT_CLOSE, Form1Close) you need a differnet func for every GUI, or you must handle which GUI has fired the event using @GUI_CtrlHandle. I also suggest read https://www.autoitscript.com/wiki/Managing_Multiple_GUIs Link to comment Share on other sites More sharing options...
faustf Posted September 20, 2016 Author Share Posted September 20, 2016 (edited) yes but , i delete always different handel because Func Form1Close() GUIDelete($pass) EndFunc $pass is global and i assign at them some time handel of form1 or form2 or form3 is not correct ??? Edited September 20, 2016 by faustf Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2016 Share Posted September 20, 2016 Please try this Func Form1Close() GuiDelete(@GUI_WinHandle) EndFunc faustf 1 Link to comment Share on other sites More sharing options...
faustf Posted September 20, 2016 Author Share Posted September 20, 2016 (edited) i bow @mikel is perfect Edited September 20, 2016 by faustf Link to comment Share on other sites More sharing options...
AutoBert Posted September 20, 2016 Share Posted September 20, 2016 19 minutes ago, faustf said: i bow @mikel is perfect realy? GUI's are closed but Script never exit. Link to comment Share on other sites More sharing options...
faustf Posted September 20, 2016 Author Share Posted September 20, 2016 @AutoBert what your suggestion ?? Link to comment Share on other sites More sharing options...
AutoBert Posted September 20, 2016 Share Posted September 20, 2016 Insert a If statement for main GUI to exit faustf 1 Link to comment Share on other sites More sharing options...
faustf Posted September 20, 2016 Author Share Posted September 20, 2016 i do thankz again Link to comment Share on other sites More sharing options...
mikell Posted September 20, 2016 Share Posted September 20, 2016 Hmmmyes. Sorry. I was in a hurry when I answered Forget and fire away the $pass variable, declare $Form1 global, and then Func Form1Close() If @GUI_WinHandle = $Form1 Then Exit GuiDelete(@GUI_WinHandle) EndFunc 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