of object
这个在过程后,有什么意义!我不太明白
这个在过程后,有什么意义!我不太明白
解决方案 »
- intraweb下打印用什么控件?
- 求个SQL语句,要求如下:如何查询数据库中一行记录中某几个字段的和,是每行都要求这几个字段的和
- 创建一个CONSOLE APLLICATION怎么闪现dos窗口?能避免吗???
- 为什么这样的表拷贝不行??
- 串口通信问题!高手请进!!!
- 程序员健康状况调查,你是否满意现在的健康状况? 进者有分
- 图标
- 求解?数据库无法删除是何原因?
- chechy,cobi,focus,kingron,nircosoft,newyj,tikkypeng,zswang,TechnoFantasy,kevincsg 据说你们是Delphi的高手可以比试一下吗?
- 50分的简单问题
- 有关treeview的奇怪,帮帮忙
- 有谁知道那里有《进销存管理系统》源代码下载吗?
type
proc = wndproc(value:integer) of object
of object 这个有什么意义!
我不明白啊
TNotifyEvent = procedure(Sender: TObject) of object;These types represent method pointers. A method pointer is really a pair of pointers; the first stores the address of a method, and the second stores a reference to the object the method belongs to. Given the declarationstype TNotifyEvent = procedure(Sender: TObject) of object;
TMainForm = class(TForm)
procedure ButtonClick(Sender: TObject);
...
end;
var
MainForm: TMainForm;
OnClick: TNotifyEventwe could make the following assignment.OnClick := MainForm.ButtonClick;Two procedural types are compatible if they havethe same calling convention,
the same return value (or no return value), and
the same number of parameters, with identically typed parameters in corresponding positions. (Parameter names do not matter.)Procedure pointer types are always incompatible with method pointer types. The value nil can be assigned to any procedural type.
Nested procedures and functions (routines declared within other routines) cannot be used as procedural values, nor can predefined procedures and functions. If you want to use a predefined routine like Length as a procedural value, write a wrapper for it:function FLength(S: string): Integer;begin
Result := Length(S);
end;
如果你开发自己的控件中,事件的参数需要自己定义,那么定义时就要加上of object,如TMyNodify = procedure (Sender: TObject; ARef1: Integer; ARef2: TControl) of object;type
MyComponent = class(TComponent)
...
private
...
FMyEvent: TMyNodify;
...
published
...
property OnMyEvent: TMyNodify read FMyEvent write FMyEvent;
...
end;
对象的方法和独立函数的区别在于一个隐含参数,好像是,类的方法有个隐含的参数,传递主调此方法的对象.比如 AnObject.AMethod(AParam) ,编译时是按 AMethod(AnObject,AParam) 处理的.而独立方法没有这个隐含参数,归根到底还是函数指针和其引用的函数参数一致的问题.
来看方法的定义
TMethod = record
Code, Data: Pointer;
end;
它包含Code:代码指针,Data:数据指针,其实Code指向函数体本身,Data指向所属的类这样不同的类可以调用统一个方法,但Data指向的类不同,Code执行效果也不同-对不同的
类操作,例如“事件”Event就是这样做的