In der Kürze liegt die Würze:
Delphi-Quellcode:
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
procedure MyBtnClick(Sender: TObject);
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.MyBtnClick(Sender: TObject);
begin
ShowMessage('foobar');
end;
procedure TForm1.FormCreate(Sender: TObject);
var
MyButton: TButton;
begin
MyButton := TButton.Create(Form1);
MyButton.Parent := Form1;
MyButton.OnClick := MyBtnClick;
end;