原帖由 ceoguang 于 2009-1-17 03:56 发表
呵呵,我再来增加个难题
#include
#include
#include
$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
$Button2 = GUICtrlCreateButton("停 ...
fit 本来就是每500毫秒运行一次的,楼上给的问题存在逻辑错误
如果要实现楼上的问题,可以加上一个判断,可以变成这样
#include
#include
#include
$Form = GUICreate("例子一", 307, 81, -1, -1)
$Button1 = GUICtrlCreateButton("开始", 32, 24, 97, 33, 0)
$Button2 = GUICtrlCreateButton("停止", 176, 24, 97, 33, 0)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_TIMER, "WM_TIMER")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Global $i = 0
$iTimeProgres4 = _Timer_SetTimer($Form, 100)
Case $Button2
_Timer_KillTimer($Form, $iTimeProgres4)
MsgBox(0, "结果", $i)
EndSwitch
WEnd
Func WM_TIMER($hWnd, $iMsg, $iwParam, $ilParam)
Switch _Timer_GetTimerID($iwParam)
Case $iTimeProgres4
fit()
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_TIMER
Func fit()
If $i >= 100 Then
_Timer_KillTimer($Form, $iTimeProgres4)
MsgBox(0, "结果", $i)
Return
EndIf
$i += 1
TrayTip("脚本正在循环中", "目的是第" & $i & "次", 10, 1)
EndFunc ;==>fit
[ 本帖最后由 superflq 于 2009-2-5 13:44 编辑 ] |