Solved

Progress Bar

Posted on 2002-05-28
10
788 Views
Last Modified: 2010-04-04
How can i change the color of the progress bar in Delphi 5
0
Comment
Question by:alshepstone
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
control image tags in a string ? 12 142
Adoquery sql  left join does not work 25 99
how to resize animated Gif image in delphi ? 1 35
CheckListBox usage 3 71
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…

840 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