Ich habs bisher erfolglos so versucht : (Auszug)
Code: Alles auswählen
unit InvDB;
{$mode objfpc}{$M+}
interface
uses
Classes, SysUtils, Dialogs, Dbf, db, Dbf_Common, Graphics, STIclass,
Forms, StdCtrls, ComCtrls, Controls;
type
// ********** TDBProgress Class *************************************//
TDBProgress = class
private
FForm: TForm;
FLabel: TLabel;
FBar: TProgressBar;
FMin: Integer;
FMax: Integer;
procedure SetProgress (Progress: Integer);
public
// Constructor and Destructor
constructor Create(Min, Max: Integer; Title: String);
destructor Destroy; override;
property Progress: Integer write SetProgress;
procedure Step;
end;
...
implementation
...
//********************************************************//
// TDBProgress implementation //
//********************************************************//
constructor TDBProgress.Create (Min, Max: Integer; Title: String);
begin
inherited Create;
FForm := TForm.Create(owner);
FForm.Height := 50;
FForm.Width := 300;
FForm.Position := poScreenCenter;
FForm.FormStyle := fsStayOnTop;
FForm.Caption := Title;
FForm.BorderIcons := FForm.BorderIcons - [biHelp];
FForm.BorderIcons := FForm.BorderIcons - [biMaximize];
FForm.BorderIcons := FForm.BorderIcons - [biMinimize];
FForm.BorderIcons := FForm.BorderIcons - [biSystemMenu];
FForm.BorderStyle := bsSingle;
FLabel := TLabel.Create(FForm);
FLabel.Parent := FForm;
FLabel.Caption := 'Fortschritt :';
FLabel.Font.Style := FLabel.Font.Style + [fsBold];
FLabel.Font.Style := FLabel.Font.Style + [fsUnderline];
FLabel.Top := 5;
FLabel.Left := 5;
FBar := TProgressBar.Create(FForm);
FBar.Parent := FForm;
FBar.Min := Min;
FMin := Min;
FBar.Max := Max;
FMax := Max;
FBar.Top := 25;
FBar.Left := 5;
FBar.Height := 20;
FBar.Width := 290;
ShowMessage('Create'); // nur zum Testen, ob aufgerufen wird
FBar.StepBy(1);
FLabel.Show;
FBar.Show;
FForm.Show;
end;
destructor TDBProgress.destroy;
begin
inherited destroy;
FForm.Close;
FLabel.Free;
FBar.Free;
FForm.Free;
end;
procedure TDBProgress.SetProgress (Progress: Integer);
begin
FBar.Position := Progress;
end;
procedure TDBProgress.Step;
begin
FBar.StepIt;
end;
Code: Alles auswählen
private
PBar: TDBProgress;
...
implementation
...
procedure TForm1.Button1Click(Sender: TObject);
// var PBar: TDBProgress; <--- so gibts SIGSEGV !
begin
PBar.Create(0,100,'Test Bar');
ShowMessage('mal gucken ....');
PBar.Free;
end;
Kann mir jemand sagen, wie man's richtig macht ??
LG Cocky