本帖最后由 58fly 于 2014-2-14 22:19 编辑
回复 1# 不死帝国
以下方法仅是一种提供准确进度条的方案,如果你的遍历数量太大,会影响效率(因为是2次遍历)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#Region ### START Koda GUI section ### Form=C:\Users\Administrator\Desktop\测试进度条.kxf
$Form1 = GUICreate("测试进度条", 615, 438, 192, 124)
$Label1 = GUICtrlCreateLabel(" ", 96, 80, 36, 17)
$Progress1 = GUICtrlCreateProgress(96, 104, 406, 17)
$Button1 = GUICtrlCreateButton("开始", 432, 184, 75, 25)
$Inpute = GUICtrlCreateInput("", 96, 24, 361, 21)
$Button2 = GUICtrlCreateButton("...", 464, 24, 43, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button2
GUICtrlSetData($Inpute,FileSelectFolder("",""))
Case $Button1
GUICtrlSetData($Progress1,0)
Local $list = _FileListToArrayRec(GUICtrlRead($Inpute),"*",0,1,0,2) ;把搜索结果存入到数组中
Local $file_x = 0
GUICtrlSetData($Label1,"正在计算..")
For $i = 1 To $list[0] ;先计算文件数量
$file_x = $i +1
Next
For $i = 1 To $list[0] ;从第一个到最大值
GUICtrlSetData($Progress1,$i / $file_x * 100) ;准确进度条(按文件数量)
Next
EndSwitch
WEnd
|