一个简单的例子, Form1 上放两个 Button(Button1, Button2):
procedure TForm1.Button1Click(Sender: TObject);
var
Event: TMethod;
EventSender: TObject;
begin
Event.Code := MethodAddress('Button2Click');
Event.Data := Self;
EventSender := FieldAddress('Button2')
if Assigned(Event.Code) and Assigned(EventSender) then
TNotifyEvent(Event)(EventSender)
//这里将调用 Button2Click
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShowMessage('Button2 Clicked!');
end;