码迷,mamicode.com
首页 > 其他好文 > 详细

Delphi的函数指针

时间:2014-05-12 20:58:45      阅读:432      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   c   

不求全面,先留个爪:

  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的函数指针

标签:style   blog   class   code   java   c   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!