Forum > General

how to change TprogressBar color


mas steindorff:
A search of the web says the color of the bar (position) is OS dependant.  Delphi uses a "sendmessage" fun() call to do the change.  the ProgressBar.color and ProgressBar.brush.color fields change the background

There is a simple way to do this because I have one program with a green bar but the default color in a new program is blue.  If I had to work at the color change I would have remembered it.
I have searched my "green" program and have found all of the places I change the position but found no color adjustments!
I have cut the green bar from the green program and pasted it onto my new one and it turned blue.

This is like a fly.  it's not hurting anything for the new program to have a blue bar but it's really bugging me.
Thank You

For windows
SendMessage(xxxxxxProgressBar.Handle, PBM_SETBARCOLOR, 0, clRed);

mas steindorff:
After a bit of digging I got my "blue" project to look green ;D.  the sendMessage needs to include windows (as expected) but the PBM_SETBARCOLOR is not defined in the windows unit or the messages so I did some digging in microsofts web pages and found it's value is 1033. 

Once I included the windows unit on my form, I started getting
Incompatible type, got AnsiString, expected "PChar"
error messages for code that was working before so I just created a new unit and placed the call in there with the uses windows,ComCtrls, and Graphics to get all of the type info correct.

This still does not explain why I have two different programs with different progress bar colors before this fix was added :-\ 


[0] Message Index

Go to full version