这段代码可以显示一个对象的属性
Procedure GetProperties(tobject : TObject);
var
PropList : PPropList;
i : Integer;
begin
PropList := AllocMem(SizeOf(PropList^));
i := 0;
try
GetPropList(PTypeInfo (tobject.ClassInfo), [tkMethod], PropList);
while (PropList^[i] <> Nil) and (i < High(PropList^)) do
begin
MessageDlg(PropList^[i].Name + ': ' + PropList^[i].PropType^.Name,
mtInformation, [mbOK], 0);
Inc(i);
end;
finally
FreeMem(PropList);
end;
end;
在使用中发现,它只能显示TComponent类或者由TComponent派生的类 的对象 的所有属性,其他的非TComponent派生的类 的对象,是什么都得不到。请问 : 我该怎么得到一个类的所有可以访问的属性(包括隐含属性)。分不够再加。GetPropList,GetPropInfo..那几个函数/过程 我都试过了不行,如果是这方面作回答的朋友,请先试一下然后才回复,因为我觉得用这几个函数不可能得到,所以
Procedure GetProperties(tobject : TObject);
var
PropList : PPropList;
i : Integer;
begin
PropList := AllocMem(SizeOf(PropList^));
i := 0;
try
GetPropList(PTypeInfo (tobject.ClassInfo), [tkMethod], PropList);
while (PropList^[i] <> Nil) and (i < High(PropList^)) do
begin
MessageDlg(PropList^[i].Name + ': ' + PropList^[i].PropType^.Name,
mtInformation, [mbOK], 0);
Inc(i);
end;
finally
FreeMem(PropList);
end;
end;
在使用中发现,它只能显示TComponent类或者由TComponent派生的类 的对象 的所有属性,其他的非TComponent派生的类 的对象,是什么都得不到。请问 : 我该怎么得到一个类的所有可以访问的属性(包括隐含属性)。分不够再加。GetPropList,GetPropInfo..那几个函数/过程 我都试过了不行,如果是这方面作回答的朋友,请先试一下然后才回复,因为我觉得用这几个函数不可能得到,所以
解决方案 »
- 急~! 高分求解:delphi 和 水晶报表的问题
- FT,请教关于类的protected问题????
- PC机使用SPCOMM与下位单片机通讯的问题
- 如何控制EXCEL的CELL中的内容自动居中!(急!)
- 如何用记事本打开FileListBox1陈列出来的的文件??
- 初来乍到,向各位老大问好!
- 怎么解析由客户浏览器发过来的经base64编码的用户名和密码,用什么函数?还是什么组件?棘手!
- 求解?数据库无法删除是何原因?
- 如何通过IWebBrowser2接口获取当前文档的类型?
- 用adotable1.append/adotable1['tab1']:=123/adotable1.post新增记录,通过dbgrid体现,但发现自动编号id(access数据库)始终为0,原因何在,我该如何处理(本人想提取本记录的id编号.)
- 高分求教:读WIN98下面DOS窗口程序内存问题。
- 请高手帮我看以下很慢很慢的SQL查询问题,在线??????
没有RTTI信息
另,RTTI指Published域的信息,没有所谓隐含的属性.
-------------
Returns a pointer to the runtime type information (RTTI) table for the object type.Delphi syntax:class function ClassInfo: Pointer;C++ syntax:static void * __fastcall ClassInfo(TClass cls);
void * __fastcall ClassInfo(){return ClassInfo(ClassType()); }DescriptionClassInfo provides access to the RTTI table for a given object type.Note: The format of the RTTI table is subject to change. Applications should use the other RTTI methods provided by TObject; these provide easy, consistent access to RTTI data.
Note: Some classes do not provide runtime type information. For these classes, ClassInfo returns nil (Delphi) or NULL (C++). All classes descended from TPersistent do provide runtime type information.