事件模式,按照我的想法是想实现按ok键,开始循环计数,按cancel键停止循环计数,再次按ok键,又继续循环计数。不知道为什么不能暂停??求教
#include <GUIConstants.au3>
Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)
$parent1 = GUICreate("Parent1")
$Label1 = GUICtrlCreateLabel("0", 16, 16, 108, 41)
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")
$ok1 = GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "SpecialEvents")
$cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "SpecialEvents")
GUISetState(@SW_SHOW)
; 闲置
While 1
Sleep(100)
Wend
Func SpecialEvents()
Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
MsgBox(0, "关闭按钮被按下", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Exit
Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "窗口被最小化", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "窗口被还原", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Case $ok1
MsgBox(0, "OK 按钮被按下,开始循环计数", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
AdlibEnable("test",10)
Case $cancel1
MsgBox(0, "Cancel 按钮被按下,停止计数", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
AdlibDisable()
EndSelect
EndFunc
Func test()
GUICtrlSetData($Label1, GUICtrlRead($Label1) + 1)
EndFunc
晕,原来中间事件没有检测到。
[ 本帖最后由 streamload 于 2008-11-15 19:34 编辑 ] |