Recent

Author Topic: Manually assigning an event procedure  (Read 5537 times)

tech-pro

  • Full Member
  • ***
  • Posts: 173
    • Tech-Pro.net
Manually assigning an event procedure
« on: September 14, 2007, 01:59:25 pm »
I have a Delphi component used by an old Delphi program I want to migrate to Lazarus. I have managed to get it to compile. I don't want to install it into Lazarus, as it's a non visual component anyway and it is more easy to create and destroy it and set the properties in code.

All is OK, except that I seem to be unable to assign an event handling procedure of type TNotifyEvent.

The prcedure is defined in the component as:

property OnRxClusterEvent : TNotifyEvent read fOnRxClusterEvent write fOnRxClusterEvent;

It is defined in my form's private declarations as:

procedure SerialPortNG1RxClusterEvent(Sender: TObject);

After I create the component I have the statement:

SerialPortNG1.OnRxClusterEvent := SerialPortNG1RxClusterEvent;

I have done this many times in Delphi, but FPC reports the error "Wrong number of parameters specified." I have enabled the Delphi compatibility switch in project options.
Julian

pch

  • Jr. Member
  • **
  • Posts: 51
    • http://ap-i.net
RE: Manually assigning an event procedure
« Reply #1 on: September 14, 2007, 03:08:33 pm »
SerialPortNG1.OnRxClusterEvent := @SerialPortNG1RxClusterEvent;

or replace {$mode objfpc} by {$mode delphi}

tech-pro

  • Full Member
  • ***
  • Posts: 173
    • Tech-Pro.net
Manually assigning an event procedure
« Reply #2 on: September 14, 2007, 03:31:15 pm »
Thanks. :)
Julian

 

TinyPortal © 2005-2018