un piccolo esempio:

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var button2: tbutton;
begin
button2:= Tbutton.create(self);
button2.parent:= self;
button2.left:=x;
button2.Top:=Y;
button2.OnClick:= showmessage('ciao'); //ERRORE!!
end;

in questo caso come si fa ad eseguire un codice o una procedura all'evento onclick?