Lazarus - why I can't assign event to run-time component?
Posted
by Garret Raziel
on Stack Overflow
See other posts from Stack Overflow
or by Garret Raziel
Published on 2010-03-20T12:15:11Z
Indexed on
2010/03/20
12:21 UTC
Read the original article
Hit count: 423
Hello, I have this Lazarus program:
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.
but compiler says: unit2.pas(63,32) Error: Wrong number of parameters specified for call to "OnTlacitkoClick" in tlac.OnClick:=OnTlacitkoClick; expression. I have searched and think that this is legal expression in Delphi. I want simply to registrate OnTlacitkoClick as tlac.OnClick event,not to call this procedure. Is there somethink wrong with the code or must I do it different in Lazarus/Freepascal?
Thanks.
© Stack Overflow or respective owner