The code can run on delphi/kylix,but a error occurs while compiling with Lazarus
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Menus;
type
{ TForm1 }
TForm1 = class(TForm)
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure test(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
item:tmenuitem;
begin
item:=tmenuitem.create(self);
item.onclick:=test;
MenuItem1.add(item);
end;
procedure TForm1.test(Sender: TObject);
begin
showmessage(tmenuitem(sender).caption);
end;
initialization
{$I unit1.lrs}
end.
Hint: Start of reading config file /etc/fpc.cfg
Hint: End of reading config file /etc/fpc.cfg
Free Pascal Compiler version 2.0.4 [2006/08/20] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Linux for i386
Compiling /tmp/project1.lpr
Compiling unit1.pas
unit1.pas(39,22) Error: Wrong number of parameters specified
item.onclick:=test;
unit1.pas(18,15) Hint: Found declaration: TForm1.test(TObject)
unit1.pas(53) Fatal: There were 1 errors compiling module, stopping
Any clues?Thanks