码迷,mamicode.com
首页 > Windows程序 > 详细

delphi中一切皆指针

时间:2016-02-25 19:42:10      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,TypInfo,ObjAuto;

type
  TForm1 = class(TForm)
    btn1: TButton;
    btn2: TButton;
    btn3: TButton;
    btn4: TButton;
    btn5: TButton;
    procedure btn1Click(Sender: TObject);
    procedure btn2Click(Sender: TObject);
    procedure btn3Click(Sender: TObject);
    procedure btn4Click(Sender: TObject);
    procedure btn5Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation
var
  f:procedure;
  i:Integer;
  j:integer;
{$R *.dfm}

procedure ExtClick1(Sender: TObject);
begin
  {asm
    mov eax,[edx+8]
    call showmessage
  end; }
  showmessage(TComponent(Sender).Name);
end;
procedure ExtClick(Frm: TObject;Sender: TObject);
begin
  {asm
    mov eax,[edx+8]
    call showmessage
  end; }
  showmessage(TComponent(Sender).Name);
  if Frm is TForm then
    TForm(Frm).Close
end;
procedure TForm1.btn2Click(Sender: TObject);
var
  ExtClickEvent: TNotifyEvent;
begin
  integer(@ExtClickEvent) := integer(@ExtClick); 
//将ExtClickEvent地址指针指向外部函数ExtClick1方法的地址
  btn1.OnClick := ExtClickEvent;
//将该地址赋值给 Button1的OnClick事件替换以前的OnClick事件
end;

 

procedure TForm1.btn1Click(Sender: TObject);
begin
  showmessage(TComponent(Sender).Name);

end;

procedure TForm1.btn3Click(Sender: TObject);
begin
 btn1.OnClick := btn1click;//还原为对象内触发事件函数

end;

procedure TForm1.btn4Click(Sender: TObject);

begin
  i:=0;
  i:=Integer(@f);
  //j:=Integer(@@f);
    ShowMessage(inttostr(i));
    i:=Integer(@@f);
  ShowMessage(inttostr(i));

end;

procedure TForm1.btn5Click(Sender: TObject);
begin
  i:=0;
  i:=Integer(@f);
  //j:=Integer(@@f);
    ShowMessage(inttostr(i));


end;

end.

 
http://blog.csdn.net/diligentcatrich/article/details/8115783
 
----------------------------------------------------------------------
delphi 中一切皆指针,任何类型都是指针,不错,你没看错。不过本篇不详细的说明delphi中指针的用法,因为篇幅所限,只是简单说明一下。delphi 中有的语法看起来比较奇怪如ppointer等,其实ppointer(p)与 pointer(p)是一样的,只不过是将其视做的对象不同而已,任何类型的指针都可以通过integer(p)转换成integer( 这里的integer就是地址的值)。
 
http://blog.csdn.net/diligentcatrich/article/details/8130449

delphi中一切皆指针

标签:

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

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