我有这个 Lazarus 程序:
unit Unit2;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ComCtrls;
type
{ TForm2 }
TForm2 = class(TForm)
procedure OnTlacitkoClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCreate(Sender: TObject);
tlac:TButton;
private
{ private declarations }
public
{ public declarations }
end;
var
Form2: TForm2;
implementation
{ TForm2 }
procedure TForm2.OnTlacitkoClick(Sender: TObject);
begin
ShowMessage('helloworld');
end;
procedure TForm2.FormCreate(Sender: TObject);
var
i, j: integer;
begin
tlac := TButton.Create(Form2);
tlac.OnClick := OnTlacitkoClick;
tlac.Parent := Form2;
tlac.Left := 100;
tlac.Top := 100;
end;
initialization
{$I unit2.lrs}
end.
tlac.OnClick := OnTlacitkoClick;
但是编译器在表达式上说以下错误:
unit2.pas(63,32) 错误:为调用“OnTlacitkoClick”指定的参数数量错误
我搜索过,认为这是Delphi中的合法表达。我只想注册OnTlacitkoClick
为tlac.OnClick
事件处理程序,而不是调用此过程。
代码有问题吗,还是我必须在 Lazarus/FreePascal 中做不同的事情?