Sign in to follow this  
Followers 0
jerome

Progress Bar with percentage

4 posts in this topic

#1 ·  Posted (edited)

Hello,

I saw here and there some very complicated solution to progress bar with a percentage while there is a very efficient and simple solution in 11 line that I included in my RAM monitor in system tray. As it is inside the source code, I put it out in order that it can be easily used...

Thanks

JD

;---------------------------------------------------------------
;- Enhanced Progress widget
;---------------------------------------------------------------
 Func CreateProgress($x, $y, $w, $h, $Label="")
     Dim $Progress[2]
     $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h)
     $Progress[1] = GuiCtrlCreateLabel($Label, $x, $y+3, $w, $h, $SS_CENTER )
     GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT)
     Return $Progress
 EndFunc
 
 Func UpdateProgress($ProgressID, $Percent, $Label="")
     GUICtrlSetData($ProgressID[0], $Percent)
     GUICtrlSetData($ProgressID[1], $Label & $Percent & "%")    
 EndFunc
Edited by jerome

Share this post


Link to post
Share on other sites



Works great. Because I need examples: :P

GUICreate("Enhanced Progress widget",220,70, -1,-1)
$progressbar1 = CreateProgress (10,10,200,20, "Starting...")
$progressbar2 = CreateProgress (10,40,200,20, "Please wait")
GUISetState ()

Sleep(2000)

for $x=0 to 100 
    sleep(25)
    UpdateProgress($progressbar1, $x, "")
    UpdateProgress($progressbar2, 100-$x, "")
Next

Share this post


Link to post
Share on other sites

Here ya go.

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 392, 71, 193, 115)
$Progress1 = CreateProgress(16, 16, 353, 25)
GUICtrlSetData(-1, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

For $i = 1 To 500
    UpdateProgress($Progress1, $i / 500 * 100)
    Sleep(100)
Next


While 1
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit

 EndSwitch
WEnd

;---------------------------------------------------------------
;- Enhanced Progress widget
;---------------------------------------------------------------
Func CreateProgress($x, $y, $w, $h, $Label="")
     Dim $Progress[2]
     $Progress[0] = GuiCtrlCreateProgress($x, $y, $w, $h)
     $Progress[1] = GuiCtrlCreateLabel($Label, $x, $y+3, $w, $h, $SS_CENTER )
     GUICtrlSetBkColor($Progress[1], $GUI_BKCOLOR_TRANSPARENT)
     Return $Progress
EndFunc

Func UpdateProgress($ProgressID, $Percent, $Label="")
     GUICtrlSetData($ProgressID[0], $Percent)
     GUICtrlSetData($ProgressID[1], $Label & $Percent & "%")    
EndFunc

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thats cool, but I don't know how to put it into:

[__CODE_PROTECTED]I2luY2x1ZGUgJiM2MDtHVUlDb25zdGFudHMuYXUzJiM2Mjs8YnIgLz4KPGJyIC8+CiNSZWdpb24gIyMjIFNUQVJUIEtvZGEgR1VJIHNlY3Rpb24gIyMjIEZvcm09PGJyIC8+CiYjMDM2O0Zvcm0xID0gR1VJQ3JlYXRlJiM0MDsmIzM0O0JldGFQYWQgfCBBbHBoYSBWRTIuMCBHVUkmIzM0OywgNjI2LCA0NjYsIDI0NSwgMjg5LCBCaXRPUiYjNDA7JiMwMzY7V1NfTUFYSU1JWkVCT1gsJiMwMzY7V1NfTUlOSU1JWkVCT1gsJiMwMzY7V1NfU0laRUJPWCwmIzAzNjtXU19DQVBUSU9OLCYjMDM2O1dTX09WRVJMQVBQRURXSU5ET1csJiMwMzY7V1NfQk9SREVSJiM0MTsmIzQxOzxiciAvPgomIzAzNjtTZWFyY2hJbnB1dCA9IEdVSUN0cmxDcmVhdGVJbnB1dCYjNDA7JiMzNDsmIzM0OywgMCwgMCwgNDQ5LCAyMSYjNDE7PGJyIC8+CiYjMDM2O1NlYXJjaCA9IEdVSUN0cmxDcmVhdGVCdXR0b24mIzQwOyYjMzQ7JmFtcDtTZWFyY2gmIzM0OywgNTM2LCAwLCA4OSwgMjUsIDAmIzQxOzxiciAvPgomIzAzNjtFbmdpbmUgPSBHVUlDdHJsQ3JlYXRlQ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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