用事件模式
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $form1, $ButtonA1, $ButtonA2, $form2, $ButtonB1, $ButtonB2
_CreatForm1()
While 1
Sleep(100)
WEnd
Func _CExit()
GUIDelete()
Exit
EndFunc ;==>_CExit
Func _CreatForm1()
$form1 = GUICreate('1', 200, 200, 800, 400)
GUISetOnEvent($GUI_EVENT_CLOSE, "_CExit")
$ButtonA1 = GUICtrlCreateButton('显示窗口2', 20, 80, 100, 20)
GUICtrlSetOnEvent(-1, "_ButtonA1")
$ButtonA2 = GUICtrlCreateButton('隐藏窗口2', 20, 110, 100, 20)
GUICtrlSetOnEvent(-1, "_ButtonA2")
GUISetState(@SW_SHOW, $form1)
EndFunc ;==>_CreatForm1
Func _CreatForm2()
$form2 = GUICreate('2', 200, 200, 1200, 400)
$ButtonB1 = GUICtrlCreateButton('B1', 20, 80, 100, 20)
GUICtrlSetOnEvent(-1, "_ButtonB1")
$ButtonB2 = GUICtrlCreateButton('B2', 20, 110, 100, 20)
GUICtrlSetOnEvent(-1, "_ButtonB2")
GUISetState(@SW_SHOW, $form2)
EndFunc ;==>_CreatForm2
Func _ButtonA1()
_CreatForm2()
EndFunc ;==>_ButtonA1
Func _ButtonA2()
GUIDelete($form2)
EndFunc ;==>_ButtonA2
Func _ButtonB1()
MsgBox(262144, '', 'B1')
EndFunc ;==>_ButtonB1
Func _ButtonB2()
MsgBox(262144, '', 'B2')
EndFunc ;==>_ButtonB2
|