本帖最后由 happytc 于 2011-6-8 09:58 编辑
回复 1# itljl
要深入了解GUISetState(@SW_hide,$Form1)的用法,它把窗口隐藏后,同时也会窗口上的控件都失活了。而你用WinSetState("TestEvent", "", @SW_SHOW)仅仅是激了窗体而已,并不能激活控件。所以你只需要把Func Button2()改一下就可以了:
Func Button2()
WinSetState("TestEvent", "", @SW_HIDE)
EndFunc
跟你编译不编译没有任何关系,如下面代码,你试试
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("TestEvent", 399, 191, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("测试", 136, 80, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("隐藏窗口", 136, 80+60, 75, 25)
GUICtrlSetOnEvent(-1, "Button2")
GUISetState(@SW_SHOW)
While 1
Sleep(100)
WEnd
Func Button1Click()
MsgBox(0, 0, "有响应")
EndFunc ;==>Button1Click
Func Button2()
GUISetState(@SW_hide,$Form1)
Sleep(1000)
WinSetState("TestEvent", "", @SW_SHOW)
EndFunc ;==>Button1Click
Func Form1Close()
Exit
EndFunc ;==>Form1Close
|