代码事件模式:
;-----------------------------------------------------------------
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
Opt("GUIOnEventMode", 1)
Global $iWait, $Input1
Example()
While 1
Sleep(10)
WEnd
Func Example()
GUICreate("进度条控件 GUI", 270, 100, -1, 200)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
Local $idButton = GUICtrlCreateButton("启动", 55, 70, 70, 20)
GUICtrlSetOnEvent(-1, "Examplea")
Local $idButton1 = GUICtrlCreateButton("关闭", 155, 70, 70, 20)
GUICtrlSetOnEvent(-1, "_Off")
$Label = GUICtrlCreateLabel('选择延时', 10, 12, 50, 22)
$Input1 = GUICtrlCreateInput("100", 65, 10, 70, 17)
GUISetState(@SW_SHOW)
#cs
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $idButton
Examplea()
Case $idButton1
ProgressOff()
EndSwitch
WEnd
#ce
EndFunc ;==>Example
Func Examplea()
$iWait = GUICtrlRead($Input1)
; 显示一个进度条窗口.
ProgressOn("进度计算", "每秒增量", "0%", 870, 200, 16)
; 更新进度条窗口的每秒进度值.
For $i = 0 To 105 Step 1 ;例子是从0%开始到100%结束,每秒进10%
Sleep($iWait)
ProgressSet($i, $i & "%")
Next
; 设置进度条窗口 "子文本" 与 "主文本".
ProgressSet(100, "完成", "进度状态:")
Sleep($iWait)
; 关闭进度窗口.
;ProgressOff()
EndFunc ;==>Examplea
Func _Off()
ProgressOff()
EndFunc ;==>Examplea
Func _Exit()
Exit
EndFunc ;==>QUIT
|