【已经解决】请问 如何做出那种倒计时后自动关闭的提示窗
本帖最后由 yunnl 于 2012-8-18 21:13 编辑Button按钮会更新倒计时时间
然后时间到了 或者点击按钮都会退出窗口
小弟不才 摸不透。。。
求前辈们指导指导#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(3秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Local $i = 3
While $i <> 0
$i = $i - 1
Sleep(1000)
GUICtrlSetData($Button1, "倒计时("&$i&"秒)")
WEnd
本帖最后由 南一 于 2012-8-18 20:55 编辑
使用API定时器来控制
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $s = 5
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(" & $s & "秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
$Timer = DllCallbackRegister("_daojishi", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Button1
DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $TimerDLL)
Exit
EndSwitch
WEnd
Func _daojishi($hWnd, $uiMsg, $Form1_idEvent, $dwTime)
If $s < 1 Then
GUICtrlSetData($Button1, "退出")
Exit
EndIf
$s -= 1
GUICtrlSetData($Button1, "倒计时(" & $s & "秒)")
EndFunc ;==>_daojishi
本帖最后由 半芯竹 于 2012-8-18 21:29 编辑
Global $time = 5
$Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(5秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
AdlibRegister("_timer", 1000)
While 1
Switch GUIGetMsg()
Case - 3,$Button1
Exit
EndSwitch
WEnd
Func _timer()
$time -= 1
GUICtrlSetData($Button1, "倒计时("&$time&")秒" )
If $time <= 0 Then Exit
EndFunc ;==>_timer 回复 2# 南一
谢谢~ 我慢慢研究下~ 回复 3# 半芯竹
非常感谢~ 学习了~ $Form1 = GUICreate("Form1", 297, 122, 192, 124)
$Button1 = GUICtrlCreateButton("倒计时(5秒)", 80, 72, 129, 33)
GUISetState(@SW_SHOW)
Global $timeA=5
$Timer = DllCallbackRegister("Timer", "int", "hwnd;uint;uint;dword")
$TimerDLL = DllCall("user32.dll", "uint", "SetTimer", "hwnd", 0, "uint", 0, "int", 1000, "ptr", DllCallbackGetPtr($Timer))
While 1
Switch GUIGetMsg()
Case - 3,$Button1
Exit
EndSwitch
WEnd
Func Timer($hWnd, $uiMsg, $idEvent, $dwTime)
If $idEvent = $TimerDLL Then
$timeA-=1
GUICtrlSetData($Button1, "倒计时("&$timeA&"秒)")
If $timeA=0 Then Exit
EndIf
EndFunc udf区,afan写过一个倒计时msgbox的函数 不错.顶一下
页:
[1]