Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing colour of a Progress bar ? 1

Status
Not open for further replies.

LucieLastic

Programmer
May 9, 2001
1,694
GB
hi

This is probably a simple question, but how do I change the colour of the progress bit in a progress bar. Mine are always set to blue.

ta
lou
 
hi,

The color used is the system highlight color. So changing the highlight color on your desktop, will alos change the color of the progressbar in your application. I didn't find a way to change this color programaticaly.

Steph [bigglasses]
 
That's a blow. Don't want to change my highlight colour. Shame you can't change it programatically, though.

Thanks for reply.

lou
[penguin]
 
hi,

Their is a possibility to change the color programmaticaly.
try the next example.

create a new project, add a progressbar and a button to the form and add the code beneath.

uses
commctrl

procedure TForm1.Button1Click(Sender: TObject);
begin
ProgressBar1.Brush.Color := clGreen;
SendMessage(ProgressBar1.Handle, PBM_SETBARCOLOR, 0, clYellow);
ProgressBar1.Position := 50;
end;

It will change the backgroud to green and the progressbar to yellow.


Steph [bigglasses]
 
Why not use a gauge from the samples tab instead? It looks better and you can set it to whatever color you want!
 
Thanks for the replies guys. As I want an easy life, I've plumped on using the Gauge comp. (thanks for that suggestion, Eric).

Steph, I've filed your bit in my useful code snippets folder - I like your solution - I can make good use of that!

[smile]
lou
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top