标签:
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://www.cnblogs.com/findumars/p/5218051.html