gseller Posted August 24, 2008 Posted August 24, 2008 Sorry, I could not find this or any good example in the helpfile or forum so I just wanted to document it for anyone else looking. So many great scripts coming out in onevent that I am changing some of mine to incorporate new stuff into my existing scripts. Hope this finds someone in need of it... expandcollapse popup#include <guiconstants.au3> Global $hGuiChild Opt("GuiOnEventMode", 1) $hGuiParent = GUICreate("Parent GUI", 200, 100, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUISetState() $ParentLabel = GUICtrlCreateLabel("Parent GUI", 70, 05, 60) $ClickHereLabel = GUICtrlCreateLabel("Click Here to Launch CHild GUI", 25, 25, 150) $okbutton = GUICtrlCreateButton("OK", 70, 40, 60) GUICtrlSetOnEvent($okbutton,"_okbutton") $CloseMebutton = GUICtrlCreateButton("Close Me", 70, 70, 60) GUICtrlSetOnEvent($CloseMebutton,"_Quit") GUISetState() While 1 Sleep(20) WEnd Func _Quit() Exit EndFunc Func _okbutton() $hGuiChild = GUICreate("Child GUI", 200, 100, 300, 300, -1, -1, $hGuiParent) GUISetOnEvent($GUI_EVENT_CLOSE, "_Warn") $Closebutton = GUICtrlCreateButton("Close", 70, 50, 60) GUICtrlSetOnEvent($Closebutton,"_Warn") GUISetState(@SW_SHOW) EndFunc ;==>ActiverButtonclick Func _Warn() MsgBox(16, "Warning", "You are closing the window.") GUIDelete($hGuiChild) EndFunc
Alek Posted August 24, 2008 Posted August 24, 2008 nice example. quick question, just a bit curious how come GuiOnEventMode is not 1 by default? [font="Impact"]Never fear, I is here.[/font]
Danny35d Posted August 25, 2008 Posted August 25, 2008 Nice example. Because you are using Opt("GuiOnEventMode", 1) we can improve what you started by changing _Quit function and use macro @GUI_WinHandle. This will allow you to have multiple child windows and the only thing else to change will be Global $hGuiChild to Global $hGuiParent.expandcollapse popupFunc _Quit() $sTitle = WinGetTitle('') MsgBox(16, "Warning", "You are closing the "& $sTitle & ".") If @GUI_WinHandle = $hGuiParent Then Exit Else GUIDelete(@GUI_WinHandle) EndIf EndFuncoÝ÷ ØLZ^jëh×6#include <guiconstants.au3> Global $hGuiParent Opt("GuiOnEventMode", 1) $hGuiParent = GUICreate("Parent GUI", 200, 100, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUISetState() $ParentLabel = GUICtrlCreateLabel("Parent GUI", 70, 05, 60) $ClickHereLabel = GUICtrlCreateLabel("Click Here to Launch CHild GUI", 25, 25, 150) $okbutton = GUICtrlCreateButton("OK", 70, 40, 60) GUICtrlSetOnEvent($okbutton, "_okbutton") $CloseMebutton = GUICtrlCreateButton("Close Me", 70, 70, 60) GUICtrlSetOnEvent($CloseMebutton, "_Quit") GUISetState() While 1 Sleep(20) WEnd Func _Quit() $sTitle = WinGetTitle('') MsgBox(16, "Warning", "You are closing the "& $sTitle & ".") If @GUI_WinHandle = $hGuiParent Then Exit Else GUIDelete(@GUI_WinHandle) EndIf EndFunc Func _okbutton() GUICreate("Child GUI", 200, 100, 300, 300, -1, -1, $hGuiParent) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $AnotherChildButton = GUICtrlCreateButton('Another Child', 60, 20, 80) GUICtrlSetOnEvent($AnotherChildButton, "_anotherchild") $Closebutton = GUICtrlCreateButton("Close", 70, 50, 60) GUICtrlSetOnEvent($Closebutton, "_Quit") GUISetState(@SW_SHOW) EndFunc ;==>_okbutton Func _anotherchild() GUICreate("Another Child GUI", 200, 100, 300, 450, -1, -1, $hGuiParent) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") $Closebutton = GUICtrlCreateButton("Close", 70, 50, 60) GUICtrlSetOnEvent($Closebutton, "_Quit") GUISetState(@SW_SHOW) EndFunc AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
euverve Posted September 10, 2008 Posted September 10, 2008 That is a very nice addition.. Thanks!Thanks for the effort, I learned something of this.
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