|
本帖最后由 cpark 于 2012-2-2 22:55 编辑
下面这段代码 带2个进度条,上面的宽的那个 显示 总体进度
下面的那个显示当前进度
我想实现 总体进度 由程序控制
下面的那个当前进度就一直自己跑
模仿的是ATI的驱动安装界面的进度条
下面的代码在效果上实现了,但是无法使用,因为进入一个循环了
有咩有同学能实现这个效果,而且代码能正常使用的#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("窗体1", 413, 305, -1, -1)
$Button1 = GUICtrlCreateButton("Button1", 315, 255, 75, 25)
GUISetState(@SW_SHOW)
Global $FRM_PROGRESS = GUICreate("", 566, 168, -1, -1, BitOR($WS_POPUP, $DS_SETFOREGROUND, $WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE ), $Form2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_STEP = GUICtrlCreateGroup("", 10, 5, 151, 151)
Global $LABEL_STEP_DESCRIBE = GUICtrlCreateLabel("STEP:", 20, 15, 75, 32)
GUICtrlSetFont(-1, 18, 800, 2, "Arial")
Global $LABEL_STEP_COUNT = GUICtrlCreateLabel("", 20, 50, 130, 94, $SS_RIGHT)
GUICtrlSetFont(-1, 68, 400, 2, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_OVERALL = GUICtrlCreateGroup("", 170, 5, 385, 80)
Global $LABEL_OVERALL = GUICtrlCreateLabel("整体进度:", 180, 20, 64, 17)
Global $PROGRESS_OVERALL = GUICtrlCreateProgress(180, 40, 363, 36)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_CURRENT = GUICtrlCreateGroup("", 170, 90, 385, 65)
Global $LABEL_CURRENT = GUICtrlCreateLabel("当前操作:", 180, 105, 64, 17)
Global $PROGRESS_CURENT = GUICtrlCreateProgress(180, 125, 363, 21)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $FRM_PROGRESS)
While 1
For $i = 10 To 100 Step 10
Sleep(100)
GUICtrlSetData($PROGRESS_CURENT, $i)
Next
WEnd
EndSwitch
WEnd
根据A版的提示,重新做了代码,和我想的效果一抹一样,而且最好玩的是,在主进度条在一个循环内部的时候,AdlibRegister注册的函数还是会正常执行,而不是等待主进度的循环结束在进行!
学习了
多谢A版#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("窗体1", 413, 305, -1, -1)
$Button1 = GUICtrlCreateButton("Button1", 315, 255, 75, 25)
GUISetState(@SW_SHOW)
Global $ix_loop = 0
Global $FRM_PROGRESS = GUICreate("", 566, 168, -1, -1, BitOR($WS_POPUP, $DS_SETFOREGROUND, $WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE), $Form2)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_STEP = GUICtrlCreateGroup("", 10, 5, 151, 151)
Global $LABEL_STEP_DESCRIBE = GUICtrlCreateLabel("STEP:", 20, 15, 75, 32)
GUICtrlSetFont(-1, 18, 800, 2, "Arial")
Global $LABEL_STEP_COUNT = GUICtrlCreateLabel("", 20, 50, 130, 94, $SS_RIGHT)
GUICtrlSetFont(-1, 68, 400, 2, "Arial")
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_OVERALL = GUICtrlCreateGroup("", 170, 5, 385, 80)
Global $LABEL_OVERALL = GUICtrlCreateLabel("整体进度:", 180, 20, 64, 17)
Global $PROGRESS_OVERALL = GUICtrlCreateProgress(180, 40, 363, 36)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $GRP_CURRENT = GUICtrlCreateGroup("", 170, 90, 385, 65)
Global $LABEL_CURRENT = GUICtrlCreateLabel("当前操作:", 180, 105, 64, 17)
Global $PROGRESS_CURENT = GUICtrlCreateProgress(180, 125, 363, 21)
#endregion ### END Koda GUI section ###
AdlibRegister("_refreshProgressBar")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
GUISetState(@SW_HIDE, $Form2)
GUISetState(@SW_SHOW, $FRM_PROGRESS)
For $i = 10 To 100 Step 10
Sleep(1000)
GUICtrlSetData($PROGRESS_OVERALL, $i)
Next
EndSwitch
WEnd
Func _refreshProgressBar()
$ix_loop = $ix_loop+10
If $ix_loop > 100 Then $ix_loop = 0
GUICtrlSetData($PROGRESS_CURENT, $ix_loop)
EndFunc ;==>_refreshProgressBar
|
|