[456] | 1 | unit fTimeout;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
| 6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 7 | fAutoSz, ExtCtrls, StdCtrls, ORFn;
|
---|
| 8 |
|
---|
| 9 | type
|
---|
| 10 | TfrmTimeout = class(TfrmAutoSz)
|
---|
| 11 | Label1: TStaticText;
|
---|
| 12 | Label2: TStaticText;
|
---|
| 13 | cmdContinue: TButton;
|
---|
| 14 | lblCount: TStaticText;
|
---|
| 15 | timCountDown: TTimer;
|
---|
| 16 | procedure FormCreate(Sender: TObject);
|
---|
| 17 | procedure cmdContinueClick(Sender: TObject);
|
---|
| 18 | procedure timCountDownTimer(Sender: TObject);
|
---|
| 19 | private
|
---|
| 20 | { Private declarations }
|
---|
| 21 | FContinue: Boolean;
|
---|
| 22 | FCount: Integer;
|
---|
| 23 | end;
|
---|
| 24 |
|
---|
| 25 | function AllowTimeout: Boolean;
|
---|
| 26 |
|
---|
| 27 | implementation
|
---|
| 28 |
|
---|
| 29 | {$R *.DFM}
|
---|
| 30 |
|
---|
| 31 | uses uCore;
|
---|
| 32 |
|
---|
| 33 | function AllowTimeout: Boolean;
|
---|
| 34 | var
|
---|
| 35 | frmTimeout: TfrmTimeout;
|
---|
| 36 | begin
|
---|
| 37 | frmTimeout := TfrmTimeout.Create(Application);
|
---|
| 38 | try
|
---|
| 39 | ResizeFormToFont(TForm(frmTimeout));
|
---|
| 40 | frmTimeout.ShowModal;
|
---|
| 41 | Result := not frmTimeout.FContinue;
|
---|
| 42 | finally
|
---|
| 43 | frmTimeout.Release;
|
---|
| 44 | end;
|
---|
| 45 | end;
|
---|
| 46 |
|
---|
| 47 | procedure TfrmTimeout.FormCreate(Sender: TObject);
|
---|
| 48 | begin
|
---|
| 49 | inherited;
|
---|
| 50 | MessageBeep(MB_ICONASTERISK);
|
---|
| 51 | FCount := User.CountDown;
|
---|
| 52 | lblCount.Caption := IntToStr(FCount);
|
---|
| 53 | end;
|
---|
| 54 |
|
---|
| 55 | procedure TfrmTimeout.cmdContinueClick(Sender: TObject);
|
---|
| 56 | begin
|
---|
| 57 | inherited;
|
---|
| 58 | FContinue := True;
|
---|
| 59 | Close;
|
---|
| 60 | end;
|
---|
| 61 |
|
---|
| 62 | procedure TfrmTimeout.timCountDownTimer(Sender: TObject);
|
---|
| 63 | begin
|
---|
| 64 | inherited;
|
---|
| 65 | if FCount = User.CountDown then
|
---|
| 66 | begin
|
---|
| 67 | MessageBeep(MB_ICONASTERISK);
|
---|
| 68 | timCountDown.Enabled := False;
|
---|
| 69 | timCountDown.Interval := 1000;
|
---|
| 70 | timCountDown.Enabled := True;
|
---|
| 71 | end;
|
---|
| 72 | Dec(FCount);
|
---|
| 73 | lblCount.Caption := IntToStr(FCount);
|
---|
| 74 | if FCount = 0 then
|
---|
| 75 | begin
|
---|
| 76 | timCountDown.Enabled := False;
|
---|
| 77 | Close;
|
---|
| 78 | end;
|
---|
| 79 | end;
|
---|
| 80 |
|
---|
| 81 | end.
|
---|