Delphi: OnTimer event of my own Timer never happens

Posted by Mikhail on Stack Overflow See other posts from Stack Overflow or by Mikhail
Published on 2010-04-14T06:09:00Z Indexed on 2010/04/14 6:13 UTC
Read the original article Hit count: 242

Filed under:
|
|

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 :-)

© Stack Overflow or respective owner

Related posts about delphi

Related posts about delphi-7