本帖最后由 chamlien 于 2016-8-14 18:25 编辑
回复 1# qqwwqqwww
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
$Form1 = GUICreate("form")
$ProgressText = GUICtrlCreateLabel("", 10, 10, 140, 40)
;添加上下文菜单(右键)
$ContextMenu = GUICtrlCreateContextMenu()
$Exit = GUICtrlCreateMenuItem("退出", $ContextMenu)
GUISetState(@SW_SHOW)
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
$Time = 50
While $Time > 0
Switch GUIGetMsg()
Case $Exit, $GUI_EVENT_CLOSE
Exit
EndSwitch
GUICtrlSetData($ProgressText, StringFormat("%02d",Floor($Time/60)) &":"& StringFormat("%02d",Mod($Time,60)))
WEnd
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
DllCallbackFree($Timer)
GUIDelete($Form1)
Exit
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $TimerDLL[0] Then $Time -= 1
EndFunc ;==>Timer
上面代码右键点击后,计时不会停止,但是数字刷新会暂停,要解决这个问题,用Opt("GUIOnEventMode", 1)模式 |