unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure OnTimerEvent(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses
Contnrs, ExtCtrls;
var
TimerList: TObjectList;
procedure TForm1.OnTimerEvent(Sender: TObject);
begin
with (Sender
as TTimer)
do
begin
Enabled := False;
Self.Refresh;
Self.Canvas.TextOut(10, 10, '
Das Ereignis von ' +
Name +
'
($' + IntToHex(LongInt(Sender), 8) + '
) wurde ausgelöst.');
TimerList.Delete(TimerList.IndexOf(Sender));
Self.Canvas.TextOut(10, 30, '
TimerList hat noch ' + IntToStr(TimerList.Count) + '
Objekte.');
Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
Timer: TTimer;
I: Integer;
begin
for I := 1
to 10
do
begin
Timer := TTimer.Create(Self);
Timer.
Name := '
TimerNo' + IntToStr(I);
Timer.OnTimer := OnTimerEvent;
Timer.Interval := 11000 - (I * 1000);
Timer.Enabled := True;
TimerList.Add(Timer);
end;
end;
initialization
TimerList := TObjectList.Create(False);
finalization
if Assigned(TimerList)
then
TimerList.Free;
end.