Geert Posted March 17, 2006 Share Posted March 17, 2006 I am trying to use a childgui. Normally when closing the childgui $GUI_EVENT_CLOSE is given and will end the script. I would like the script end only when then parentgui is being closed.So I used WinActive($ChildGui) to make it work.Is this the right way to do this or is there an alternative.#include <GUIConstants.au3> Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced $ParentGUI = GUICreate("Parent") ; will create a dialog box that when displayed is centered $ButtonOpenChildGUI = GUICtrlCreateButton("Open ChildGUI", 10, 30, 100) $Input = GUICtrlCreateInput("", 160, 65, 130, 20) $ChildGui = GUICreate("Child", 200, 200, 600, 300, -1, -1, $ParentGUI) ; will create a dialog box $ButtonTime = GUICtrlCreateButton("Time", 10, 30, 50) GUISetState(@SW_SHOW, $ParentGUI) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE If WinActive($ChildGui) Then GUISetState(@SW_HIDE, $ChildGui); Hide $ChildGui Else ExitLoop; Exit Program EndIf Case $msg = $ButtonOpenChildGUI GUISetState(@SW_SHOW, $ChildGui) Case $msg = $ButtonTime GUICtrlSetData($Input, @HOUR & @MIN & @SEC) EndSelect WEnd Link to comment Share on other sites More sharing options...
GaryFrost Posted March 17, 2006 Share Posted March 17, 2006 I would have each in its own loop i.e. expandcollapse popup#include <GUIConstants.au3> Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced $ParentGUI = GUICreate("Parent"); will create a dialog box that when displayed is centered $ButtonOpenChildGUI = GUICtrlCreateButton("Open ChildGUI", 10, 30, 100) $Input = GUICtrlCreateInput("", 160, 65, 130, 20) GUISetState(@SW_SHOW, $ParentGUI) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop; Exit Program Case $msg = $ButtonOpenChildGUI _ChildGui() EndSelect WEnd Func _ChildGui() ; Run the GUI until the dialog is closed $ChildGui = GUICreate("Child", 200, 200, 600, 300, -1, -1, $ParentGUI); will create a dialog box $ButtonTime = GUICtrlCreateButton("Time", 10, 30, 50) GUISetState(@SW_SHOW, $ChildGui) ; will display an empty dialog box While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE ExitLoop; Exit Program Case $msg2 = $ButtonTime GUICtrlSetData($Input, @HOUR & @MIN & @SEC) EndSelect WEnd GUIDelete($ChildGui) EndFunc ;==>_ChildGui SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Geert Posted March 17, 2006 Author Share Posted March 17, 2006 (edited) Well this is looking better. Calling the childGUI as a function gives more order in the script. But: when the childGUI is open and then you close the parentGUI, it closes childGUI instead of exiting te script... Edited March 17, 2006 by Geert Link to comment Share on other sites More sharing options...
GaryFrost Posted March 17, 2006 Share Posted March 17, 2006 Well this is looking better. Calling the childGUI as a function gives more order in the script.But: when the childGUI is open and then you close the parentGUI, it closes childGUI instead of exiting te script... just change the exitloop in the main loop to exit SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 17, 2006 Moderators Share Posted March 17, 2006 Or...expandcollapse popup#include <GUIConstants.au3> Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced $ParentGUI = GUICreate("Parent"); will create a dialog box that when displayed is centered $ButtonOpenChildGUI = GUICtrlCreateButton("Open ChildGUI", 10, 30, 100) $Input = GUICtrlCreateInput("", 160, 65, 130, 20) GUISetState(@SW_SHOW, $ParentGUI) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop; Exit Program Case $msg = $ButtonOpenChildGUI ;typically we disable the parent while the child is open ;GUISetState(@SW_DISABLE, $ParentGUI) _ChildGui($ParentGUI) ;GUISetState(@SW_ENABLE, $ParentGUI) EndSelect WEnd Func _ChildGui($sParent) ; Run the GUI until the dialog is closed $ChildGui = GUICreate("Child", 200, 200, 600, 300, -1, -1, $ParentGUI); will create a dialog box $ButtonTime = GUICtrlCreateButton("Time", 10, 30, 50) GUISetState(@SW_SHOW, $ChildGui) ; will display an empty dialog box While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE And WinActive($sParent) Exit Case $msg2 = $GUI_EVENT_CLOSE ExitLoop; Exit Program Case $msg2 = $ButtonTime GUICtrlSetData($Input, @HOUR & @MIN & @SEC) EndSelect WEnd GUIDelete($ChildGui) EndFunc ;==>_ChildGui Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Geert Posted March 17, 2006 Author Share Posted March 17, 2006 just change the exitloop in the main loop to exitI tried that already, it's not doing what is should do... Link to comment Share on other sites More sharing options...
GaryFrost Posted March 17, 2006 Share Posted March 17, 2006 or make it a modal child expandcollapse popup#include <GUIConstants.au3> Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced $ParentGUI = GUICreate("Parent"); will create a dialog box that when displayed is centered $ButtonOpenChildGUI = GUICtrlCreateButton("Open ChildGUI", 10, 30, 100) $Input = GUICtrlCreateInput("", 160, 65, 130, 20) GUISetState(@SW_SHOW, $ParentGUI) ; will display an empty dialog box ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit; Exit Program Case $msg = $ButtonOpenChildGUI GUISetState(@SW_DISABLE, $ParentGUI) _ChildGui() EndSelect WEnd Func _ChildGui() ; Run the GUI until the dialog is closed $ChildGui = GUICreate("Child", 200, 200, 600, 300, -1, -1, $ParentGUI); will create a dialog box $ButtonTime = GUICtrlCreateButton("Time", 10, 30, 50) GUISetState(@SW_SHOW, $ChildGui) ; will display an empty dialog box While 1 $msg2 = GUIGetMsg() Select Case $msg2 = $GUI_EVENT_CLOSE ExitLoop; Exit Program Case $msg2 = $ButtonTime GUICtrlSetData($Input, @HOUR & @MIN & @SEC) EndSelect WEnd GUISetState(@SW_ENABLE, $ParentGUI) GUISwitch($ParentGUI) GUIDelete($ChildGui) EndFunc ;==>_ChildGui SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Geert Posted March 17, 2006 Author Share Posted March 17, 2006 Thank you both!My script wil use SmOke_N's: $msg2 = $GUI_EVENT_CLOSE And WinActive($sParent) to keep control on the parentGUI 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