您的位置:首页 > 其它

定义事件过程类型

2012-12-27 17:05 197 查看
// 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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐