unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DateUtils, ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Timer1: TTimer;
Label2: TLabel;
Label3: TLabel;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
ShutDownDateTime : TDateTime;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
ShutDownDateTime := IncMinute(now, StrToInt(Edit1.Text));
Label2.Caption := '
Shutdown DateTime: ' + DateTimeToStr(ShutDownDateTime);
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label3.Caption := Format('
ShutDown in %d Sekunden...', [SecondsBetween(now, ShutDownDateTime)]);
if now >= ShutDownDateTime
then Begin
// "=" würde nicht reichen, der Timer wird ja nicht EXAKT am Endzeitpunkt ausgelöst, also auch auf Zeit später
reagieren.
Timer1.Enabled := False;
// Nicht vergessen!!!!!!!!!!!!!!!!!!!!
Label3.Caption := '
FERTIG!!!';
showmessage('
Hier was machen...');
End;
end;
end.