just for fun, slightly modified and dressed as functions
there are 2 paired functions: _GUICtrlCreateProgressCustom()
allows you to create a customized Progressbar with the percentage superimposed. You can choose the colors of the background and of the progress bar. You can also optionally choose at what percentage of progress the color of the progress bar can change to another color. _GUICtrlSetDataProgressCustom()
used to set the value of the custom progress bar
hope you have fun
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
; -----
#include <WinAPITheme.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Progress", 367, 148, 192, 124)
; -----
; create some example pregress bars
Global $ahProgress[6] ; to store bars references
$ahProgress[0] = _GUICtrlCreateProgressCustom(20, 10, 255, 25) ; plain progress bar
$ahProgress[1] = _GUICtrlCreateProgressCustom(20, 40, 255, 25, -1, 0xFFFFFF, 0x00ff00, 70, 0xff00ff) ; change color when >= 70%
$ahProgress[2] = _GUICtrlCreateProgressCustom(20, 70, 255, 25, 0x04, 0xFFFFFF, 0x00ff00, 100, 0xff0000) ; vertical filling effect + red at 100%
$ahProgress[3] = _GUICtrlCreateProgressCustom(20, 100, 255, 25, -1, 0xFFFFFF, 0x5555aa, 90, 0xaaaaff) ; change color when >= 90%
$ahProgress[4] = _GUICtrlCreateProgressCustom(290, 10, 25, 115, 0x04, 0x7f7f7f, 0x00ffff, 80, 0xaaaa00) ; vertical ; darker background ; some ugly colors
$ahProgress[5] = _GUICtrlCreateProgressCustom(330, 10, 25, 115, 0x04, 0x7f7f7f, 0xff0000, 100, 0x00ff00) ; vertical ; darker background ; some ugly colors
; -----
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
; update the progess bars
For $i = 0 To 100
For $ii = 0 To UBound($ahProgress) - 1
_GUICtrlSetDataProgressCustom($ahProgress[$ii], $i)
Next
Sleep(100)
Next
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlCreateProgressCustom
; Description ...:
; Syntax ........: _GUICtrlCreateProgressCustom($Left, $Top, $Width, $Height[, $Style = -1[, $BackColor = 0xFFFFFF[,
; $ForeColor = 0x00FF00[, $Warn = 0[, $WarnColor = 0xFF0000]]]]])
; Parameters ....: $Left - The left side of the control.
; $Top - The top of the control.
; $Width - The width of the control.
; $Height - The height of the control.
; $Style - [optional] Defines the style of the control. Default is -1.
; the style con be useful to set a vertical Progress (use $PBS_VERTICAL 0x04)
; $BackColor - [optional] The background RGB color to use. Default is 0xFFFFFF.
; $ForeColor - [optional] The Progress bar RGB color to use. Default is 0x00FF00.
; $Warn - [optional] A value (inclusive) beyond which the bar color changes to the warning color.
; Default is 0 (disabled). (ie: use 101 to signal if a value > 100 has been set)
; $WarnColor - [optional] The Progress bar RGB color to use while in warn values. Default is 0xFF0000.
; Return values .: Returns an 1D 5 elements array as follow:
; [0] the identifier (controlID) of the new control.
; [1] the identifier (controlID) of the overlapped label control.
; [2] the Progress bar RGB color assigned to this bar.
; [3] the "warn" value at which and beyond which the bar color changes to the warning color.
; [4] The Progress bar RGB color to use while in warn values.
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlCreateProgressCustom($Left, $Top, $Width, $Height, $Style = -1, $BackColor = 0xFFFFFF, $ForeColor = 0x00FF00, $Warn = 0, $WarnColor = 0xFF0000)
Local $aProgrStruct[5], $LabelWidth = 30, $LabelHeight = 25
$aProgrStruct[0] = GUICtrlCreateProgress($Left, $Top, $Width, $Height, $Style)
_WinAPI_SetWindowTheme(GUICtrlGetHandle(-1), "", "")
GUICtrlSetBkColor(-1, $BackColor)
GUICtrlSetColor(-1, $ForeColor) ; color of the advancing bar
$aProgrStruct[1] = GUICtrlCreateLabel("0%", _
$Left + ($Width / 2) - ($LabelWidth / 2), _
$Top + ($Height / 2) - ($LabelHeight / 2), _
$LabelWidth, $LabelHeight, $SS_CENTER + $SS_CENTERIMAGE)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
; optional
$aProgrStruct[2] = $ForeColor
$aProgrStruct[3] = $Warn
$aProgrStruct[4] = $WarnColor
Return $aProgrStruct
EndFunc ;==>_GUICtrlCreateProgressCustom
; #FUNCTION# ====================================================================================================================
; Name ..........: _GUICtrlSetDataProgressCustom
; Description ...:
; Syntax ........: _GUICtrlSetDataProgressCustom($aProgress, $iValue)
; Parameters ....: $aProgress - the array returned by the _GUICtrlCreateProgressCustom() function.
; $iValue - an integer value to set the progress bar to.
; Return values .: None
; Author ........: Chimp
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: No
; ===============================================================================================================================
Func _GUICtrlSetDataProgressCustom($aProgress, $iValue)
Local $iFC = $aProgress[2]
If $aProgress[3] And $iValue >= $aProgress[3] Then $iFC = $aProgress[4]
GUICtrlSetColor($aProgress[0], $iFC)
GUICtrlSetData($aProgress[0], $iValue)
;~ GUICtrlSetData($aProgress[1], $iValue & '%')
GUICtrlSetData($aProgress[1], GUICtrlRead($aProgress[0]) & '%')
EndFunc ;==>_GUICtrlSetDataProgressCustom