不求全面,先留个爪:
TNotifyEvent = procedure(Sender: TObject) of object; TMethod = record Code, Data: Pointer; end;
判断两个按钮的事件是否相等:
procedure TForm1.Button5Click(Sender: TObject); var f1,f2: TNotifyEvent; begin f1:=Button1.OnClick; f2:=Button2.OnClick; if (@f1=@f2) then begin ShowMessage('相等'); end else begin ShowMessage('不相等'); end; end; procedure TForm1.Button6Click(Sender: TObject); var t1,t2: TMethod; begin t1:=TMethod(Button1.OnClick); t2:=TMethod(Button2.OnClick); if t1.Code=t2.Code then showmessage('method.Code is same'); if t1.Data=t2.Data then showmessage('method.Data is same'); end; procedure TForm1.Button7Click(Sender: TObject); begin if Addr(Button1.OnClick)=Addr(Button2.OnClick) then showmessage('ffffff'); end;
参考:
http://blog.csdn.net/linzhengqun/article/details/1755493