用事件模式,更一目了然Opt('guioneventmode', 1)
Local $hGUI1 = -1, $hGUI2 = -1
$hGUI = GUICreate('GUI-MAIN', 250, 300, Default, Default, 0x10070000)
GUISetOnEvent(-3, '_exit')
$b1 = GUICtrlCreateButton('window1', 20, 50)
GUICtrlSetOnEvent(-1, '_hGui1')
$b2 = GUICtrlCreateButton('window2', 150, 50)
GUICtrlSetOnEvent(-1, '_hGui2')
GUISetState()
While 1
Sleep(100)
WEnd
Func _exit()
Exit
EndFunc
Func _hGui1()
If $hGUI1 = -1 Then
$hGUI1 = GUICreate('windows1', 200, 150, -250, Default, 0x10070000, 0x0000040, $hGUI)
GUISetOnEvent(-3, '_del_gui1')
Else
WinActivate($hGUI1)
EndIf
EndFunc ;==>_hGui1
Func _hGui2()
If $hGUI2 = -1 Then
$hGUI2 = GUICreate('windows2', 200, 150, -250, Default, 0x10070000, 0x0000040, $hGUI)
GUISetOnEvent(-3, '_del_gui2')
Else
WinActivate($hGUI2)
EndIf
EndFunc ;==>_hGui2
Func _del_gui1()
GUIDelete($hGUI1)
$hGUI1 = -1
EndFunc ;==>_del_gui1
Func _del_gui2()
GUIDelete($hGUI2)
$hGUI2 = -1
EndFunc ;==>_del_gui2
|