Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Put a ProgressBar on a StatusBar Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
21-Nov-02
Category
VCL-General
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

Putting a ProgressBar on a StatusBar

Answer:

Many programs out there display a progress bar on the status bar. Internet Explorer 
is one of those. However, Delphi doesn't have component with that feature built-in. 
But that doesn't prevent us from having a progress bar inside a status bar panel. 
This is what this trick will tech you.

To make this tip work, create a form with a StatusBar (let's accept the default 
name: StatusBar1). Add a few panels to it.

To the public section of the form class declaration, add:

ProgressBar1: TProgressBar;

To the OnCreate event handler of the form, add:

1   var
2     ProgressBarStyle: LongInt;
3   begin
4     {create a run progress bar in the status bar}
5     ProgressBar1 := TProgressBar.Create(StatusBar1);
6     ProgressBar1.Parent := StatusBar1;
7     {remove progress bar border}
8     ProgressBarStyle := GetWindowLong(ProgressBar1.Handle, GWL_EXSTYLE);
9     ProgressBarStyle := ProgressBarStyle - WS_EX_STATICEDGE;
10    SetWindowLong(ProgressBar1.Handle, GWL_EXSTYLE, ProgressBarStyle);
11    {set progress bar position and size - put in Panel[2]}
12    ProgressBar1.Left := StatusBar1.Panels.Items[0].Width +
13      StatusBar1.Panels.Items[1].Width + 4;
14    ProgressBar1.Top := 4;
15    ProgressBar1.Height := StatusBar1.Height - 6;
16    ProgressBar1.Width := StatusBar1.Panels.Items[2].Width - 6;
17    {set range and initial state}
18    ProgressBar1.Min := 0;
19    ProgressBar1.Max := 100;
20    ProgressBar1.Step := 1;
21    ProgressBar1.Position := 0;
22  end;
23    
24  //In the OnDestroy event handler of the form, add:
25  
26  ProgressBar1.free;


If the position of the ProgressBar within the StatusBar doesn't please you, you can change the top, left, height and width properties of the ProgressBar. You can also change the Step, Max and Min properties of the ProgressBar. Within your program, work with the progress bar as you normally would, by accessing it's Position property.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC