unit uProgressDialog;
interface
uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ComCtrls,
Vcl.ExtCtrls;
type
TOnProgressEvent =
procedure(Sender: TObject)
of Object;
TfrmProgressDialog =
class(TForm)
Label1: TLabel;
Label2: TLabel;
ProgressBar1: TProgressBar;
Button1: TButton;
TimerStartOnProgress: TTimer;
function GetOnProgress: TOnProgressEvent;
procedure SetOnProgress(Event: TOnProgressEvent);
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure TimerStartOnProgressTimer(Sender: TObject);
private
{ Private-Deklarationen }
FOnProgress: TOnProgressEvent;
public
{ Public-Deklarationen }
property OnProgress: TOnProgressEvent
read GetOnProgress
write SetOnProgress;
end;
var
frmProgressDialog: TfrmProgressDialog;
implementation
{$R *.dfm}
{ TfrmProgressDialog }
procedure TfrmProgressDialog.FormCreate(Sender: TObject);
begin
//init
TimerStartOnProgress.Enabled := False;
TimerStartOnProgress.Interval := 250;
end;
procedure TfrmProgressDialog.FormShow(Sender: TObject);
begin
//Timer aktivieren
TimerStartOnProgress.Enabled := True;
end;
function TfrmProgressDialog.GetOnProgress: TOnProgressEvent;
begin
result := FOnProgress;
end;
procedure TfrmProgressDialog.SetOnProgress(Event: TOnProgressEvent);
begin
FOnProgress := Event;
end;
procedure TfrmProgressDialog.TimerStartOnProgressTimer(Sender: TObject);
begin
//Timer deaktivieren
TimerStartOnProgress.Enabled := False;
//Ereignis ausführen...
if Assigned(FOnProgress)
then FOnProgress(Self);
end;
end.