Sign in to follow this  
Followers 0
FreeRider

Customized ProgressBar

1 post in this topic

#1 ·  Posted (edited)

#include <GUIConstants.au3>
; ------- Signification for parameters passed by the calling instruction ------
;$CmdLine[1] = Name of the calling program
;$CmdLine[2] = Estimated total number of records to be handled
;$CmdLine[3] = Estimated number of records handled by second
;-------- Windows creation -----------------------------------------------
GUICreate($CmdLine[1],220,60, 100,200)
GUICtrlSetColor(-1,00130); not working with Windows XP Style
GUICtrlCreateLabel ("",10,35,200,20)
$TextLbl=GUICtrlCreateLabel ("",10,35,200,20)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20,$PBS_SMOOTH)
GUISetState ()
;-------- Initializes the variables and starts the loop-----------------------------------------
$EstimTime=($CmdLine[2]/$CmdLine[3])*1000; -- Estimated total time in Ms --
$Begin = TimerInit()             ; -- Start Timestamp (reference value) --
$wait = 20; wait 20ms for next progressstep; -- Waiting time between each incrementation --
$s = 0; progressbar-saveposition     ; - Init progressbar ----
do;-- Main loop start
    $msg = GUIGetMsg()
        
        For $i = $s To 100;-- Loop start
        $Dif = TimerDiff($Begin); -- Elapsed time in Ms--
        $Progress=($Dif/$EstimTime)*100; -- Transformed in %age --
        $i=$Progress; -- Counter update --
        If WinExists ('Traitement terminé','') Then ExitLoop; -- Test if operation is prematurely terminated --
        $s = $i; -- Save "$i" value in "$s" --
        GUICtrlSetData ($progressbar1,$Progress); -- Update progress bar --
        GUICtrlSetData ($TextLbl, & Int($Progress)'% déjà traité...'); -- Update Text label --
        Sleep($wait)
        Next; -- Loop End
until $i >100;-- Main loop end
; -- Force the Progressbar to 100% when calling process is terminated or if Main loop ended normally --
GUICtrlSetData ($progressbar1,100) ; -- Remplissage de la progress bar --
GUICtrlSetData ($TextLbl,'100% - Traitement terminé'); -- Mise à 100% du text label --
Sleep(2000); -- Wait 2 seconds before exiting
Exit

Edited by Larry

FreeRiderHonour & Fidelity

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0