rain6867 发表于 2009-1-4 08:35:44

如何实现秒表的功能

如何实现类似秒表的功能,按开始键开始自身加1,按停止键停止按开始键继续运行,归根结底就是想退出死循环,这个功能很有用,请大家帮帮忙

大绯狼 发表于 2009-1-4 09:39:08

楼主是要这样的功能?
#include <GUIConstants.au3>
Opt("GuiOnEventMode", 1)
$time = 5
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 449, 193, 125)
$Button1 = GUICtrlCreateButton("开始", 224, 224, 75, 25, 0)
GUICtrlSetOnEvent(-1, "ca")
$Label2 = GUICtrlCreateLabel($time, 192, 88, 36, 17)
GUISetState(@SW_SHOW)
;~ AdlibEnable("lefttime", 1000)
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
#EndRegion ### END Koda GUI section ###

While 1
        Sleep(100)
WEnd

Func lefttime()
        GUICtrlSetData($Button1, "取消")
        If $time = 0 Then
                MsgBox(0, 0, "时间到")
                AdlibDisable()
                GUICtrlSetData($Button1, "开始")
        Else
                $time -= 1
                GUICtrlSetData($Label2, $time)
        EndIf
EndFunc   ;==>lefttime

Func ca()
        If GUICtrlRead($Button1) = "开始"Then
                AdlibEnable("lefttime", 1000)
        Else
                AdlibDisable()
                MsgBox(0, 0, "已取消")
                $time = 100
                GUICtrlSetData($Button1, "开始")
                GUICtrlSetData($Label2, $time)
        EndIf
EndFunc   ;==>ca

Func quit()
        Exit
EndFunc   ;==>quit
页: [1]
查看完整版本: 如何实现秒表的功能