谁知道用什么方法可以列出某一个控件的所有属性么 比如点击一下BUTTON就可以获得她的所有属性。不知DELPHI可不可以做到这一点哪。
解决方案 »
- 用sendmessage发消息,为啥2个线程释放后主进程无响应???
- 新手求教!delphi动态加载菜单的菜单表怎么设计?
- 请教New()在Win2K3服务器申请内存指针偶尔会失败并导致程序无响应.本机Win7运行却从没错误...
- 请问ADOQuery如何设置才可以不自动保存到数据库?
- RyanGT(笑书神侠) 请进来,给你100分.
- 程序运行中出现的问题.急!!!在线等!!!
- 打死韩狗: http://www.fuwu100.com/china.asp
- 面向接口编程问题
- 请问如何判断一个注册表的键值是否存在?希望详细一点,谢谢。!!
- 如何在数据中增加空记录--新手
- 如何检测edit里输入的不是数字或者英文字母就提示错误信息
- 在学习dll的知识,写了个简单的dll,和调用它的程序,执行时说找不到dll文件,贴出代码,大家帮我看看哪里有问题
fpropList: PPropList;
fPropCount,i: integer;
begin
fPropCount := GetTypeData(button2.ClassInfo).PropCount;
fPropList := Nil;
if fPropCount > 0 then
begin
GetMem(fPropList, fPropCount * SizeOf(Pointer));
GetPropInfos(button2.ClassInfo, fPropList);
end;
for i := 0 to fPropCount - 1 do
listbox1.Items.Add(fproplist[i].Name);建议学习一下rtti相关只是
TYPINFO
单元中还有一个函数,应为GET开头,后面忘了,前段时间用过
去单元里查一下,即可
PreferStrings: Boolean = True): Variant;procedure SetPropValue(Instance: TObject; const PropName: string;
const Value: Variant);
{ This method retrieves the property names and types for the given object
and adds that information to the AStrings parameter. }
var
PropList: PPropList;
ClassTypeInfo: PTypeInfo;
ClassTypeData: PTypeData;
i: integer;
NumProps: Integer;
begin ClassTypeInfo := AClass.ClassInfo;
ClassTypeData := GetTypeData(ClassTypeInfo); if ClassTypeData.PropCount <> 0 then
begin
// allocate the memory needed to hold the references to the TPropInfo
// structures on the number of properties.
GetMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount);
try
// fill PropList with the pointer references to the TPropInfo structures
GetPropInfos(AClass.ClassInfo, PropList);
for i := 0 to ClassTypeData.PropCount - 1 do
// filter out properties that are events ( method pointer properties)
if not (PropList[i]^.PropType^.Kind = tkMethod) then
AStrings.Add(Format('%s: %s', [PropList[i]^.Name, PropList[i]^.PropType^.Name])); // Now get properties that are events (method pointer properties)
NumProps := GetPropList(AClass.ClassInfo, [tkMethod], PropList);
if NumProps <> 0 then begin
AStrings.Add('');
AStrings.Add(' EVENTS ================ ');
AStrings.Add('');
end;
// Fill the AStrings with the events.
for i := 0 to NumProps - 1 do
AStrings.Add(Format('%s: %s', [PropList[i]^.Name, PropList[i]^.PropType^.Name])); finally
FreeMem(PropList, SizeOf(PPropInfo) * ClassTypeData.PropCount);
end;
end;end;