vcl-styles-utils
vcl-styles-utils copied to clipboard
How to add support for State property on ProgressBar?
Hi Rodrigo! The component ProgressBar have a 'State' property: npbsNormal, npbsError, npbsPaused.
Example#1

If enable VCL Style all State property of the bar have one color
Example#2

How can I change the color of the bar in accordance with the 'State' property?
I found a procedure TSysProgressBarStyleHook.PaintBar(Canvas: TCanvas) in the Vcl.Styles.Utils.ComCtrls.pas file and added code
...
if ((SysControl.Style And PBST_ERROR) <> 0) then
SendMessage(Handle, PBM_SETBARCOLOR, 0, clRed);
if ((SysControl.Style And PBST_PAUSED) <> 0) then
SendMessage(Handle, PBM_SETBARCOLOR, 0, clYellow);
...
but it doesn't work.
@Kriggi
...
initialization
TStyleManager.Engine.RegisterStyleHook(TProgressBar, TStyleHook);
finalization
TStyleManager.Engine.UnRegisterStyleHook(TProgressBar, TStyleHook);
end.
Add this to the bottom of your main unit file