• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1088
  • Last Modified:

ProgressBar in StatusBar Panel

Please..Please...
how can i add a progressbar to a TStatusbar and how to fit it
into one of the Statusbar-Panels?

Thank's
0
Miucha
Asked:
Miucha
1 Solution
 
LukA_YJKCommented:
Using standard features. Set the Style to psOwnerDraw and write your drawing code (simple blue colored bar) to the OnDrawPanel event. Then you can use Invalidate or Repaint every time you need to update your ProgressBar. Hope it will help... Do ou need a code?
0
 
SpetsonCommented:
//----->The Code Begin Here
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls;

//This is the Normal TForm Class...
//Don't forget to add a ProgressBar and a Status Bar to this Form.
//And also, don't forget to add a least 2 panels to your StatusBar!
type
  TForm1 = class(TForm)
  StatusBar1: TStatusBar;
  ProgressBar1: TProgressBar;
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
end;

//Now, this is a special class
TMyStatusBar = class(TStatusBar)
public
constructor Create(AOwner: TComponent); override;
end;

var
  Form1: TForm1;

implementation
  uses commctrl;

  constructor TMyStatusBar.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ControlStyle:= ControlStyle + [csAcceptsControls];
end;

{$R *.dfm}
//Form On Show Event

procedure TForm1.FormShow(Sender: TObject);
var r : TRect;
begin


Statusbar1.perform(SB_GETRECT,1,integer( @R ));
//The number 1 above, determine the StatusBar Panel number.
// 0 = first Panel; 1 = the second and so on.


progressbar1.parent := Statusbar1;
progressbar1.top := r.top;
progressbar1.left := r.left;
progressbar1.width := r.right-r.left;
progressbar1.height := r.bottom-r.top;
end;


end.
//----->The Code Ends Here

0
 
MiuchaAuthor Commented:
Oh! Very Nice...
This worked perfectly in my program!
Thank's!
0
 
kenny_njcCommented:
I will drop two components in the form (one is status bar and another is progress bar)
Then fit the progress bar with the status bar.
Then bring the progress bar to front of the status bar.

kenny
0
 
SpetsonCommented:
Yes, this will work's to!
But i think that, if you resize your form, or maximize it, maybe u got some problems!
Please correct me here if i'm wrong...

.::Spetson::.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now