Delphi: OnTimer event of my own Timer never happens
- by Mikhail
I need a Timer in a 'no form' Delphi unit, so I do this:
unit ...
interface
type
TMyTimer = Class(TTimer)
public
procedure OnMyTimer(Sender: TObject);
end;
var
MyTimer: TMyTimer;
implementation
procedure TMyTimer.OnMyTimer(Sender: TObject);
begin
...
end;
initialization
MyTimer := TMyTimer.Create(nil);
with MyTimer do
begin
Interval := 1000;
Enabled := True;
OnTimer := OnMyTimer;
end;
finalization
FreeAndNil(MouseTimer);
The problem is that the OnMyTimer procedure is never run. I'll truly appreciate any ideas as to why :-)