Solved

Progress Bar

Posted on 2002-05-28
10
758 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
 
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now