delphi中一切皆指针
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.
delphi中一切皆指针的更多相关文章
- Delphi中的函数指针判断是否为空
delphi函数指针 只有@@p才代表了函数指针本身的地址 assigned(p) 判断是否为空 或者用 @p=nil 来判断函数指针是不是为空 Delphi中的函数指针实际上就是指针,只是在使用 ...
- delphi 中的函数指针 回调函数(传递函数指针,以及它需要的函数参数)
以下代码仅仅是测试代码:delphi XE7 UP1 interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.V ...
- delphi 中Adoquery ,在打开时能否让记录指针不移动? [问题点数:40分,结帖人microd]
delphi 中Adoquery ,在打开时能否让记录指针不移动?由于数据集Adoquery 时,它的针指称动会废时,能否在打开完成之前不让记录指针不移动.打开完毕之后再回复移动? 这样用:self. ...
- Delphi中使用比较少的一些语法
本文是为了加强记忆而写,这里写的大多数内容都是在编程的日常工作中使用频率不高的东西,但是又十分重要. ---Murphy 1,构造和析构函数: a,构造函数: 一般基于TComponent组件的派生类 ...
- 翻箱倒柜,《Delphi中建议使用的语句》
(*//标题:Delphi中建议使用的语句整理:Zswang连接:http://www.csdn.net/Expert/TopicView1.asp?id=724036日期:2002-06-22支持: ...
- Delphi中window消息截获的实现方式(2)
Delphi是Borland公司提供的一种全新的WINDOWS编程开发工具.由于它采用了具有弹性的和可重用的面向对象Pascal(object-orientedpascal)语言,并有强大的数据库引擎 ...
- Delphi 中的 procedure of object
转载:http://www.cnblogs.com/ywangzi/archive/2012/08/28/2659811.html 总结:TMyEvent = procedure of object; ...
- Delphi中的异常处理
转载:http://www.cnblogs.com/doit8791/archive/2012/05/08/2489471.html 以前写Delphi程序一直不注意异常处理,对其异常处理的机制总是一 ...
- Delphi中DLL的创建和使用
参考:http://blog.csdn.net/ninetowns2008/article/details/6311663 结合这篇博客:http://www.cnblogs.com/xumenger ...
随机推荐
- jQuery prop 全选和全不全
$('#ckAll').click(function() { var value = $(this).is(':checked') ? true : false; $("input[name ...
- 我的Python成长之路---GitHub使用克隆GitHub(SSH key配置)
六.克隆GitHub仓库 1.创建仓库目录,目录位置没有要求,比如D:\learngit. 2.配置ssh(如果不配置会每次都输入用户名和密码) 使用TortoiseGit生成ssh-key:开始菜单 ...
- Raphael入门实例:动画与箭头
raphael 实例 动画 隐藏和显示参数说明 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 var c = paper.circle(50, 50, 40); function ...
- 网站开启gzip的方法
.如果空间支持Zlib压缩文件,可用php.ini方法 这个方法比较简单,压缩率也较高,可达75%左右.新建一个名为 php.ini 的文件,添加以下代码,保存后上传至网站根目录即可. output_ ...
- Json也可以这么使
public string GetJSON() { //Json数据 string json112 = "{\"control_info\":{\"imei\& ...
- shu_1548 悟空问题(大哥,主妖怪抓走的朋友!)
http://202.121.199.212/JudgeOnline/problem.php?cid=1078&pid=17 分析: 直接暴力了.. . 代码: #include <s ...
- Smarty - 安装+入门小例子
环境: smarty 1.在http://www.smarty.net/download下载最新smarty包,window选择zips,linux下选择tar.gz.以windows为例,下载后解压 ...
- 【ant项目构建学习点滴】--(3)打包及运行jar文件
<?xml version="1.0" encoding="UTF-8"?> <project default="compile&q ...
- 我的Python成长之路---第二天---Python基础(8)---2016年1月9日(晴)
数据类型之字典 一.字典简介 字典dict(dictionary),在其他语言中也成为map,使用键-值(key-value)的形式存储和展现,具有极快的查找速度. 字典的定义 d = {'key': ...
- CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方
CentOS 6.2 二进制安装apache2.4.3出现configure: error: APR-util not found. Please read the documentation的解决方 ...