[已解决]如何使鼠标拖动窗体倒计时不停止?
本帖最后由 laomeng 于 2014-12-9 21:46 编辑在论坛上看到大侠写的倒计时,但是鼠标点到窗体上方或者移动窗体的时候 倒计时会停止,如何实现不让它停止呢?谢谢 指教!!!#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $time = 30
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibEnable("_timer", 1000)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
Exit
Case $Button1
ExitLoop
EndSwitch
If $time <= 0 Then ExitLoop
WEnd
main()
Exit
Func _timer()
$time -= 1
GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
GUICtrlSetData($Progress1, (30 - $time) / 0.3)
If $time <= 0 Then AdlibDisable()
EndFunc ;==>_timer
Func main()
MsgBox(0, 'test', '倒计时结束,进入主程序.', 10)
;以下为主程序
EndFunc ;==>main
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $time = 30
#Region ### START Koda GUI section ### Form=
AdlibRegister("time")
$time1 = TimerInit()
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button2
AdlibUnRegister("time")
Exit
Case $Button1
ExitLoop
EndSwitch
If $time = 1 Then ExitLoop
WEnd
main()
Exit
Func time()
If TimerDiff($time1) > 1000 Then
GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
GUICtrlSetData($Progress1, (30 - $time) / 0.3)
$time = $time - 1
$time1 = TimerInit()
EndIf
EndFunc ;==>time
Func main()
MsgBox(0, 'test', '倒计时结束,进入主程序.', 10)
;以下为主程序
EndFunc ;==>main 回复 2# austere
谢谢但是 还是一样会停止 回复 3# laomeng
你的意思是窗口没有激活,就暂停进度条吗? 学习了,感谢分享!! 回复 4# austere
不是。
是在倒计时开始后用鼠标点到窗体上方拖动的时候读秒会停止,有什么办法 使它 不停止呢 回复 3# laomeng
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $time = 30, $time1, $Label1, $Progress1
GUIa()
While 1
Sleep(1000)
WEnd
Func GUIa()
;AdlibRegister("time")
$time1 = TimerInit()
$Form1 = GUICreate("倒计时测试窗口", 350, 172, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Label1 = GUICtrlCreateLabel("30秒后将进入主程序!", 56, 32, 232, 28)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Progress1 = GUICtrlCreateProgress(8, 88, 333, 17)
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
GUICtrlSetOnEvent($Button1, "time")
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUICtrlSetOnEvent($Button2, "Form1Close")
GUISetState(@SW_SHOW)
EndFunc ;==>GUIaProg
Func time()
AdlibRegister("time")
If TimerDiff($time1) > 1000 Then
GUICtrlSetData($Label1, $time & "秒后将进入主程序!")
GUICtrlSetData($Progress1, (30 - $time) / 0.3)
$time = $time - 1
$time1 = TimerInit()
EndIf
If $time = 0 Then
main()
EndIf
EndFunc ;==>time
Func main()
MsgBox(0, 'test', '倒计时结束,进入主程序.', 1)
;以下为主程序
Form1Close()
EndFunc ;==>main
Func Form1Close()
Exit
EndFunc ;==>Form1Close 回复 7# chzj589
谢谢你的解答,但还是没有解决我的问题
鼠标 拖动窗体读秒还是会停止。 我记得之前有看到过 实现的方法, 现在找不到了 明白你的意思了,你按了标题栏程序会暂停的~所以用winmove来实现就可以了~ 回复 9# austere
请指教 谢! 用定时器
#Include <Timers.au3>
_Timer_SetTimer($hWnd [, $iElapse = 250 [, $sTimerFunc = "" [, $iTimerID = -1]]]) Afan的办法不错,试过可行~ 回复 11# afan
多谢提醒已解决 回复 12# austere
已OK
页:
[1]