Board index » delphi » How to include progress bar into status bar ?

How to include progress bar into status bar ?

Does any body know ?
 

Re:How to include progress bar into status bar ?


Nick Yevseyev schrieb:

Quote

> Does any body know ?

Yeah, I know!

1.) Create a empty Statusbarpanel.
2.) Implement these 2 procedures for initializing and destroying the
Progressbar. You may change the 'left',... properties, so that it fits
into your StatusbarPanel

Procedure TfrmImport.InitProgressBar(AMax : Integer);

Begin
  barProgress := TProgressBar.Create(barStatus);
  barProgress.Top      := 2;
  barProgress.Left     := barStatus.Panels[0].Width + 2;
  barProgress.Height   := barStatus.Height - 2;
  barProgress.Width    := barStatus.Panels[1].Width - 2;
  barProgress.Max      := AMax;
  barProgress.Parent   := barStatus;
  barProgress.Min      := 0;
  barProgress.Position := 0;
End;

{---}

Procedure TfrmImport.DoneProgressBar;

Begin
  barProgress.Free;
End;

3.) Set the 'Position' property as needed in your code.

Hope that helps

-danijel

Re:How to include progress bar into status bar ?


I found a component that has this option, and many more.
Its a very good component.
If you want it, tell me.

Lcio
lu...@cultura.com.br

Quote
Nick Yevseyev <nikolay.m.yevse...@usa.net> wrote in message

news:7j0fsg$g2b1@forums.borland.com...
Quote
> Does any body know ?

Re:How to include progress bar into status bar ?


There is no need for a new coomponent. Use this :

On the FormCreate (OnCreate event) of the form:
 ProgressBar1.Parent := StatusBar1;

On the StatusBar's OnDrawPanel event :
ProgressBar1.BoundsRect := rect;

I put an SpinEdit component to increase the progressbar's value. The
code below is  on the SpinEdit's OnChange event:
ProgressBar1.Position := SpinEdit1.Value;

Note : Create 2 panels from the statusbar. Select the property "style"
to psOwnerDraw of the first panel.(panels[0])

This should work fine.

Quote
Nick Yevseyev wrote:
> Does any body know ?

Re:How to include progress bar into status bar ?


On Tue, 1 Jun 1999 15:27:35 +0400, "Nick Yevseyev"

Quote
<nikolay.m.yevse...@usa.net> wrote:
>Does any body know ?

You could try the following:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    StatusBar1: TStatusBar;
    ProgressBar1: TProgressBar;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  StatusBar1.Panels.Items[1].Width:=Progressbar1.Width;
  ProgressBar1.Parent:=StatusBar1;
end;

procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
  ProgressBar1.BoundsRect:=Rect;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  ProgressBar1.StepIt;
end;

end.

Quote
>-----<

object Form1: TForm1
  Left = 231
  Top = 123
  Width = 315
  Height = 233
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object StatusBar1: TStatusBar
    Left = 0
    Top = 187
    Width = 307
    Height = 19
    Panels = <
      item
        Width = 50
      end
      item
        Style = psOwnerDraw
        Width = 50
      end
      item
        Width = 50
      end>
    SimplePanel = False
    OnDrawPanel = StatusBar1DrawPanel
  end
  object ProgressBar1: TProgressBar
    Left = 70
    Top = 68
    Width = 150
    Height = 16
    Anchors = []
    Min = 0
    Max = 100
    Step = 5
    TabOrder = 1
  end
  object Timer1: TTimer
    Interval = 150
    OnTimer = Timer1Timer
    Left = 80
    Top = 16
  end
end

Re:How to include progress bar into status bar ?


Hello,
for this case I build a TStatusbar descendant.

:-) Jens Schumann

unit StatusBarEx;

interface

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

type
  TStatusBarEx = class(TStatusBar)
  private
    { Private-Deklarationen}
  protected
    { Protected-Deklarationen}
  public
    { Public-Deklarationen}
    constructor Create(AOwner: TComponent); override;
  published
    { Published-Deklarationen }
  end;

procedure Register;

implementation

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

procedure Register;
begin
  RegisterComponents('Beispiele', [TStatusBarEx]);
end;

end.

Nick Yevseyev <nikolay.m.yevse...@usa.net> schrieb im Beitrag
<7j0fsg$g...@forums.borland.com>...

Quote
> Does any body know ?

Re:How to include progress bar into status bar ?


Hi, Nick.

Try this:

PB_Indicator.Parent:= StatusBar;
PB_Indicator.SetBounds(2,((StatusBar.Height- PB_Indicator.Height) div 2)+ 1,
                                 PB_Indicator.Width,PB_Indicator.Height);

This set PB_Indicator on first panel to status bar.

Gratitude.

ps. I'm sorry for my very bad English.
--
Petio Tonev
pto...@iname.com
www.i.am/ptonev

Other Threads