1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| unit MaxExecutiontimer;
interface
uses
Classes, Functions, ExtCtrls, UnitMessages, UnitOS, Windows, SysUtils ;
type
TMaxExecutiontimer = class
private
{ Déclarations privées }
//Timer : TTimer ;
Intervale : Cardinal ;
Timer : Cardinal ;
protected
{ Déclarations protégées }
public
{ Déclarations publiques }
procedure TimerEnd ;
procedure Enable(state : Boolean) ;
constructor Create(TimeOfTheTime : Cardinal) ;
destructor Free ;
published
{ Déclarations publiées }
end;
procedure TimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; dwTime: DWORD); stdcall;
implementation
Const NumTimer = 1 ;
{*******************************************************************************
* Fonction appelée lorsque le timer est écoulé
******************************************************************************}
procedure TMaxExecutiontimer.TimerEnd ;
begin
OsKillTimer(timer) ;
//Timer.Enabled := False ;
ErrorMsg(sTimeIsEnd) ;
FinishProgramm ;
Halt ;
end ;
procedure TimerProc(hWnd: HWND; uMsg: UINT; idEvent: UINT; dwTime: DWORD); stdcall;
begin
KillTimer(NumTimer) ;
writeln('erotyeoryot') ;
end;
{******************************************************************************
* Consructeur
******************************************************************************}
constructor TMaxExecutiontimer.Create(TimeOfTheTime : Cardinal) ;
begin
inherited Create();
Intervale := TimeOfTheTime ;
Timer := NumTimer ;
{
Timer := TTimer.Create(nil) ;
Timer.Interval := TimeOfTheTime ;
Timer.OnTimer := TimerEnd ;
Timer.Enabled := False ;
}
end ;
{******************************************************************************
* Destructeur
******************************************************************************}
destructor TMaxExecutiontimer.Free ;
begin
//Timer.Free ;
KillTimer(timer)
end ;
procedure TMaxExecutiontimer.Enable(state : Boolean) ;
begin
//Timer.Enabled := State
if state = true
then
SetTimer(0, timer, Intervale, @TimerProc) //TimerEnd)
else
KillTimer(0, timer) ;
end ;
end. |
Partager