// TonEvent = procedure of object; //定义事件过程类型后加面加 of object
Tcls = class
private
FonEvent: TNotifyEvent;
public
procedure show(sender: TObject);
property onEvent: TNotifyEvent read FonEvent write FonEvent;
constructor create;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
constructor Tcls.create;
begin
FonEvent := show;
end;
procedure Tcls.show;
begin
ShowMessage('触发事件');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Tc: Tcls;
begin
Tc := Tcls.Create;
Tc.onEvent(Sender);
Tc.Free;
end;