RRUZ / vcl-styles-utils

Extend and improve the Delphi VCL Styles
https://theroadtodelphi.wordpress.com/
331 stars 114 forks source link

How to add support for State property on ProgressBar? #254

Open Kriggi opened 5 years ago

Kriggi commented 5 years ago

Hi Rodrigo! The component ProgressBar have a 'State' property: npbsNormal, npbsError, npbsPaused.

Example#1 ProgressBarState

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

Example#2 ProgressBarStateStyle

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.

wantedxnn commented 3 years ago

@Kriggi

...
initialization
TStyleManager.Engine.RegisterStyleHook(TProgressBar, TStyleHook);

finalization
TStyleManager.Engine.UnRegisterStyleHook(TProgressBar, TStyleHook);

end.

Add this to the bottom of your main unit file