Solved

Progress Bar

Posted on 2002-05-28
10
837 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
Technology Partners: 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 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