ich möchte eine Progressbar ín eine Statusbar einbetten.
Warum erscheint die Progressbar nicht.
Code: Alles auswählen
unit StatusProgu;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
Buttons;
type
{ TForm1 }
TForm1 = class(TForm)
BitBtn1: TBitBtn;
Button1: TButton;
StatusBar1: TStatusBar;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
const Rect: TRect);
private
ProgBar :TProgressBar;
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
ProgBar:=TProgressBar.Create(Self);
ProgBar.Anchors:=[];
ProgBar.Min:=0;
ProgBar.Max:=100;
ProgBar.Position:=0;
ProgBar.Height:=15;
ProgBar.Width:=60;
ProgBar.Parent:=StatusBar1;
StatusBar1.Panels[0].Style:=psOwnerDraw;
ProgBar.Visible:=True;
ProgBar.Enabled:=True;
StatusBar1.Invalidate;
end;
procedure TForm1.Button1Click(Sender: TObject);
var i :Integer;
begin
for i:=0 to 100 do begin
Caption:=i.ToString;
Application.ProcessMessages;
ProgBar.Position:=i;
Sleep(10);
end;
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
ProgBar.Free;
end;
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: TRect);
begin
if (Panel=StatusBar1.Panels[0]) then ProgBar.BoundsRect:=Rect;
end;
end.
Vielen Dank.
Gruß, Linkat