本帖最后由 tryhi 于 2012-3-5 20:08 编辑
对于楼主的结构感觉很奇怪,反而不是很理解楼主要干嘛#include <GuiConstants.au3>
#include <ButtonConstants.au3>
Opt("GUIOnEventMode", 1);OnEvent模式
Global $ChildWin
$ParentWin = GUICreate("父窗口", 350, 200,-1, -1)
$Button1 = GUICtrlCreateButton("弹出对话框", 62, 157-21, 100, 30)
$Button2 = GUICtrlCreateButton("弹出子窗口", 185, 157-21, 100, 30)
GUISetState(@SW_SHOW)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
GUICtrlSetOnEvent($Button1, "gui")
GUICtrlSetOnEvent($Button2, "gui")
While 1
Sleep(100)
WEnd
Func gui()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
MsgBox(0,"0","这仅仅是一个测试",5)
Case $Button2
Child()
EndSwitch
EndFunc
Func Child()
$ChildWin = GUICreate("子窗口", 340, 190,-1, -1,-1, -1, $ParentWin)
GUISetOnEvent($GUI_EVENT_CLOSE, "gui")
$Button3= GUICtrlCreateButton("执行test函数", 50, 140, 100, 30)
GUICtrlSetOnEvent(-1, "test")
$Button4= GUICtrlCreateButton("关闭", 230, 140, 80, 30)
GUICtrlSetOnEvent(-1, "button4")
GUISetState(@SW_DISABLE, $ParentWin)
GUISwitch($ChildWin)
GUISetState(@SW_SHOW)
EndFunc
Func test()
MsgBox(0,"0","哈哈,该事件相应啦",5)
EndFunc
Func button4()
GUIDelete($ChildWin)
GUISetState(@SW_ENABLE , $ParentWin)
WinActivate($ParentWin)
EndFunc
|