首页 > 其他 > 详细

Delphi的函数指针

时间:2014-05-12 20:59:16      阅读:471      评论:0      收藏:0      [点我收藏+]

不求全面,先留个爪:

  TNotifyEvent = procedure(Sender: TObject) of object;
  TMethod = record
    Code, Data: Pointer;
  end;

判断两个按钮的事件是否相等:

bubuko.com,布布扣
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;
bubuko.com,布布扣

 参考:

http://blog.csdn.net/linzhengqun/article/details/1755493

Delphi的函数指针,布布扣,bubuko.com

Delphi的函数指针

原文:http://www.cnblogs.com/findumars/p/3722094.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!