[Lazarus] Newbie, porting class to FPC but get procedure assignment error
Bo Berglund
bo.berglund at gmail.com
Fri Jun 19 09:25:56 CEST 2015
I am trying to make a test program in Lazarus to evaluate if I can
port a dongle component in Delphi to a normal class in Lazarus.
So far I had no real problems but now I don't understand what I am
doing wrong. Relevant code below:
TSentinel = class
private
FTimer: TTimer;
...
procedure OnCheckTimer(Sender: TObject);
...
public
{ Public declarations }
constructor Create;
...
end;
constructor TSentinel.Create;
begin
FTimer := TTimer.Create(Application);
FTimer.Enabled := false;
FTimer.Interval := 0;
FTimer.OnTimer := OnCheckTimer(Self); //<= Error here
...
end;
The timer is used to automatically check the presence of the dongle so
I have to assign the OnTimer procedure to the newly created TTimer
object. This works fine in Delphi...
On compilation I get an error message as follows.
In the Delphi code there was no argument on the assignment of the
OnTimer event procedure, in Lazarus it shows this error:
sentinel.pas(647,21) Error: Wrong number of parameters specified for
call to "OnCheckTimer"
Using argument Self or NIL (like I often do in Delphi):
sentinel.pas(647,39) Error: Incompatible type for arg no. 1: Got
"untyped", expected "<procedure variable type of procedure(TObject) of
object;Register>"
Why is this difference Delphi/FPC appearing and what can I do?
--
Bo Berglund
Developer in Sweden
More information about the Lazarus
mailing list