Solved

Progress Bar

Posted on 2002-05-28
10
797 Views
Last Modified: 2010-04-04
How can i change the color of the progress bar in Delphi 5
0
Comment
Question by:alshepstone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 9

Accepted Solution

by:
ginsonic earned 50 total points
ID: 7039557
procedure TForm1.Button1Click(Sender: TObject);
begin
  //Set bar color to red
  SendMessage(ProgressBar1.Handle, PBM_SETBARCOLOR, 0, clRed);
end;
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7039561
Or:

SendMessage(ProgressBar1.Handle, PBM_SETBKCOLOR, 0, clRed);
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 7040038
Interesting ...

I tried it, but I got compiler-errors on PBM_SETBARCOLOR and PBM_SETBKCOLOR : Undeclared identifier.

Have I forgot to use one or more units ?

The Mayor
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:freshman3k
ID: 7040382
Hello!

This should do the trick:

First You Need To Add CommCtrl to your Uses clause, it contains the necessary message definitions

Code:
SendMessage(MyProgressBar.Handle, PBM_SETBARCOLOR, 0,clYellow);

Good Luck!
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7040927
freshman3k , your code look alike mine. You just replace the color ( clRed with clYellow ).
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7040935
wimmeyvaert, yes you must add CommCtrl unit . And then ...

procedure TForm1.FormCreate(Sender: TObject);
begin
  SendMessage(ProgressBar1.Handle, PBM_SETBARCOLOR, 0, MyColorHere);
end;
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 7041037
Works great ...
Hope alshepstone has the same meaning here.

Only
  SendMessage(ProgressBar1.Handle, PBM_SETBKCOLOR, 0, clRed);
seems not doing anything. I suppose this should color the background of the progrssbar. Maybe there it is better to do : ProgressBar1.Brush.Color := clRed;


Best regards,
The Mayor
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7041047
The question is color of progressbar and not progressbar background :)
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 7041053
Yes, I know, but in your second comment you placed

SendMessage(ProgressBar1.Handle, PBM_SETBKCOLOR, 0, clRed);

and I just want to let you know that this does not work, and that I think that 'ProgressBar1.Brush.Color := clRed'
is a good alternative.

Best regards,

The Mayor.

0
 
LVL 9

Expert Comment

by:ginsonic
ID: 7041151
OK :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question