vcl-styles-utils icon indicating copy to clipboard operation
vcl-styles-utils copied to clipboard

How to add support for State property on ProgressBar?

Open Kriggi opened this issue 6 years ago • 1 comments

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.

Kriggi avatar Jul 22 '19 20:07 Kriggi

@Kriggi

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

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

end.

Add this to the bottom of your main unit file

wantedxnn avatar Dec 10 '20 19:12 wantedxnn