Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Progress Bar

Posted on 2002-05-28
10
Medium Priority
?
882 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 200 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

876 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