This is what I have:

In a unit where a logging class is defined:

type
  TRxEvent = procedure (const Buffer: TBytes) of object;
...
  TWiFiCommLogger = class(TThread)
  private
  ...
    FOnRxData: TRxEvent;
  ...
  public
  ...
    property OnRxData: TRxEvent read FOnRxData write FOnRxData;
  ...
end;

procedure TWiFiCommLogger.Execute;
begin
  while not Terminated do
  begin
     ...
      if Assigned(FOnRxData) then
      begin
        FOnRxData(FBuffer);
        SetLength(FBuffer, 0);
      end;
     ...

Then in the form unit where I want to use this:
...
  private
...
    procedure OnRxSS(Buf: TBytes);
...
end;

In the form constructor:

procedure TfrmCommTest.FormCreate(Sender: TObject);
...
  FLogSS := TWiFiCommLogger.Create;
  FLogSS.OnRxData := OnRxSS;  // <== Error on this line
...

When I compile this I get the following error:

formcommtest.pas(112,22) Error: Incompatible types: got
"TfrmCommTest.OnRxSS(TBytes);" expected "<procedure variable type of
procedure(const TBytes) of object;Register>"


What am I doing wrong here?

I have written similar types of programs where I have used this kind
of construction and it has worked fine (in Delphi).
 
Both the form file and the unit where the handler class is defined
have been set to:

{$mode Delphi}



-- 
Bo Berglund
Developer in Sweden

-- 
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus

Reply via email to