#region: - Options Opt('GUIOnEventMode', 1) Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 0) Opt('TrayIconHide', 1) Opt('WinDetectHiddenText', 1) #endregion #region: - Include #include <GUIConstantsEx.au3> #Include <OnEventFunc.au3> #endregion #region: - Win Global $sProGUID = _Get_GUID() Func _Get_GUID() Local $oTypeLib = ObjCreate('Scriptlet.TypeLib') If IsObj($oTypeLib) Then Return $oTypeLib.GUID Return SetError(1, 0, 0) EndFunc Func _Win_Close() GUIDelete(@GUI_WinHandle) EndFunc #endregion #region: - Main Win Func _MainWin_Create() GUICreate('Main win', 200, 200, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, '_Pro_Exit') GUICtrlCreateLabel($sProGUID & ': Main win', -100, -100) GUICtrlSetState(-1, $GUI_HIDE) GUICtrlCreateButton('Open Second win', 20, 20, 150) SetOnEventA(-1, '_MainWin_Actions', $paramByVal, 'Del / Create Second win on button1') GUISetState() EndFunc Func _MainWin_Actions($sAction) Switch $sAction Case 'Del / Create Second win on button1' Switch GUICtrlRead(@GUI_CtrlId) Case 'Open Second win' _SecondWin_Create() GUICtrlSetData(@GUI_CtrlId, 'Close Second win') Case 'Close Second win' GUIDelete(WinGetTitle('Second win', $sProGUID & ': Second win')) GUICtrlSetData(@GUI_CtrlId, 'Open Second win') EndSwitch EndSwitch EndFunc #endregion #region: - Second Win Func _SecondWin_Create() GUICreate('Second win', 200, 200, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, '_Win_Close') GUICtrlCreateLabel($sProGUID & ': Second win', -100, -100) GUICtrlSetState(-1, $GUI_HIDE) GUISetState() EndFunc #endregion #region: - After creating all GUI _MainWin_Create() #endregion #region: - Sleep, Exit, OnAutoItExit While 1 Sleep(10) WEnd Func _Pro_Exit() Exit EndFunc #endregion ; |