请问给位Delphi高手,可以在运行时态取到VCL控件的属性列表吗?
解决方案 »
- 在sql server中能執行的語句在delphi中不能執行
- 见鬼了,在线程里不能创建TADOConnection?
- 兄弟门: 新的一年到来,又该盘店了
- 请问DBGrid表中的记录可以交换位置吗?
- 如何在memo或richedit中读取文件中特定的行??
- 小弟初学DELPHI,编了个软件,请大家测试一下!!!
- Oracle数据库图片存取问题
- oracle 10g 快速导出expdp从服务导出到本地 参数network_link高手来帮忙看看
- 简单问题!签个名,该帖子的分就是你的!反正没人答得出!
- 怎么样实现系统栏右下的shelltrayicon?
- 怎樣調用存儲過程,怎樣使用它返回的數據集
- 两种不同方法创建form的问题。
unit MainFrm;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TMainForm = class(TForm)
lbSamps: TListBox;
memInfo: TMemo;
procedure FormCreate(Sender: TObject);
procedure lbSampsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation
uses TypInfo, Buttons;{$R *.DFM}
procedure TMainForm.FormCreate(Sender: TObject);
begin
// Add some example enumerated types
with lbSamps.Items do
begin
AddObject('TButtonState', TypeInfo(TButtonState));
AddObject('TFormStyle', TypeInfo(TFormStyle));
AddObject('Boolean', TypeInfo(Boolean));
end;
end;procedure TMainForm.lbSampsClick(Sender: TObject);
var
OrdTypeInfo: PTypeInfo;
OrdTypeData: PTypeData; TypeNameStr: String;
TypeKindStr: String;
MinVal, MaxVal: Integer;
i: integer;
begin
memInfo.Lines.Clear;
with lbSamps do
begin // Get the TTypeInfo pointer
OrdTypeInfo := PTypeInfo(Items.Objects[ItemIndex]);
// Get the TTypeData pointer
OrdTypeData := GetTypeData(OrdTypeInfo); // Get the type name string
TypeNameStr := OrdTypeInfo.Name;
// Get the type kind string
TypeKindStr := GetEnumName(TypeInfo(TTypeKind), Integer(OrdTypeInfo^.Kind)); // Get the minimum and maximum values for the type
MinVal := OrdTypeData^.MinValue;
MaxVal := OrdTypeData^.MaxValue;
// Add the information to the memo
with memInfo.Lines do
begin
Add('Type Name: '+TypeNameStr);
Add('Type Kind: '+TypeKindStr); Add('Min Val: '+IntToStr(MinVal));
Add('Max Val: '+IntToStr(MaxVal)); // Show the values and names of the enumerated types
if OrdTypeInfo^.Kind = tkEnumeration then
for i := MinVal to MaxVal do
Add(Format(' Value: %d Name: %s', [i, GetEnumName(OrdTypeInfo, i)])); end;
end;
end;end.
可能我表达错了,我是说可以在运行时态取得VCL控件的所有Publish属性名字。比如“name”,“caption”,“left”……等等。
var
vPropList: PPropList;
I: Integer;
begin
ListBox1.Clear;
for I := 0 to GetPropList(Self, vPropList) - 1 do
ListBox1.AddItem(vPropList[I].Name, TObject(vPropList[I]));
end;嘻嘻嘻 想玩VCL的RTTI就去花时间了解TypInfo单元 嘻嘻嘻嘻