type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
I:Integer;
ppiPropInfo;
pPropsPropList;
ptiTypeInfo;
ptdTypeData;
PropInfoPropInfo;
begin
for I:=0 to Self.ComponentCount-1 do
begin
PropInfo:=GetPropInfo(Components.classinfo,'Caption');
if PropInfo<>nil then
begin
ShowMessage(Components.Name+' old Caption='+ GetStrProp(Components,propinfo));
//设置属性
SetStrProp(Components.Name,propInfo,'我是谁');
ShowMessage(Components.Name+' new Caption='+ GetStrProp(Components,propinfo));
end;
else
ShowMessage(Components.Name+' has not Caption property');
end;
nd;