Search code examples
delphilazarus

Change progressbar color


I have a progressbar in my form and I need to change its color. I need it to be Yellow and so I am using this code:

SendMessage(ProgressBar5.Handle, PBM_SETBARCOLOR, 0, clYellow); 

I am using Lazarus and I couldn't use the SendMessage(); procedure. Then I have googled a bit and I found that I need to include in the uses the lclintf library.

Now I have another hassle because Lazarus can't recognize the parameter PBM_SETBARCOLOR. In fact it states:

unit5.pas(245,50) Error: Identifier not found "PBM_SETBARCOLOR";

I see that the first line of code that I wrote is the only way to change the color of a ProgressBar from green to the one I need.

Any help? I am using the latest version of Lazarus.


Solution

  • The PBM_SETBARCOLOR is declared in the commctrl.pp unit of freepascal, same as in Delphi.

    You could also declare it as a constant with value 1033 (WM_USER + 9).