type
TMyEvents = class(TComponent)
public
procedure DoeOnTimer(Sender: TObject);
procedure DoeOnFormClose(Sender: TObject; var Action: TCloseAction);
end;
procedure TMyEvents.DoeOnTimer(Sender: TObject);
var
Lab: TLabel;
Tim: TTimer;
begin
Lab := TLabel(TForm(TTimer(Sender).Owner).FindComponent('lbSeconden'));
Tim := TTimer(TForm(TTimer(Sender).Owner).FindComponent('tmSeconden'));
if (Tim <> nil) and (Lab <> nil) then
begin
Tim.Tag := Tim.Tag - 1;
Lab.Caption := Tim.Tag.ToString;
if Tim.Tag <= 0 then TForm(TTimer(Sender).Owner).Close;
end;
end;
procedure TMyEvents.DoeOnFormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
function MaakMelding(CaptionValue: string; Timeout: Integer = 6; Kleur: TColor = clInfoBk): TForm;
var
Events: TMyEvents;
begin
Result := TForm.Create(Application);
try
Events := TMyEvents.Create(Result);
Result.Height := Round(80 * (Result.PixelsPerInch / 96));
Result.Width := Round(200 * (Result.PixelsPerInch / 96));
Result.BorderStyle := bsDialog;
Result.OnClose := @Events.DoeOnFormClose;
Result.Left := Screen.WorkAreaWidth - Result.Width - 4;
Result.Top := Screen.WorkAreaHeight - GetSystemMetrics(SM_CYCAPTION) - 4 - Result.Height;
Result.Color := clInfoBk;
with TTimer.Create(Result) do
begin
Name := 'tmSeconden';
Tag := TimeOut;
Interval := 1000;
OnTimer := @Events.DoeOnTimer;
Enabled := True;
end;
with TLabel.Create(Result) do
begin
Parent := Result;
Align := alClient;
Alignment := taCenter;
Layout := tlCenter;
Font.Size := 14;
Caption := CaptionValue;
end;
with TLabel.Create(Result) do
begin
Name := 'lbSeconden';
Parent := Result;
Left := 10;
Top := 10;
Font.Size := 9;
Caption := TimeOut.ToString;
end;
Result.Show;
except
on E: Exception do
Result.Free;
end;
end;
procedure TFmain.MenuItemPRINTClick(Sender: TObject);
var
dl: TForm;
begin
if QuestionDlg('KEUZE !', 'Gegevens afdrukken?' + #13 + '', mtConfirmation,
[mrYes, 'OK', mrNo, 'Annuleren'], '') = mrYes then
begin
dl := MaakMelding('Printer is bezig');
try
PrintStringGrid(StringGrid1, 'Print Stringgrid Wiezen ' +
formatdatetime('dd' + '/' + 'mm' + '/' + 'YYYY', Now));
finally
// dl.Free; // vrijgeven moet niet omdat dat vanzelf gebeurd
end;
end;
end;
Bookmarks