{"rsdb":{"rid":"395131","subhead":"","postdate":"0","aid":"272511","fid":"86","uid":"1","topic":"1","content":"
\n

var
Edit: TComponent;
begin
Edit := FindComponent("Edit1");
If Edit is TEdit then
TEdit(Edit).Text := '\u4f60\u597d Delphi7';
end;<\/p> \n

 <\/p> \n

 <\/p> \n

RTTI(RunTime Type Information): \u8fd0\u884c\u65f6\u7c7b\u578b\u4fe1\u606f, \u5c31\u662f\u5728\u7a0b\u5e8f\u8fd0\u884c\u540e\u4e5f\u80fd\u5f97\u5230\u7c7b\u578b(\u8b6c\u5982 TButton \u7c7b)\u7684\u4fe1\u606f.<\/p> \n

 <\/p> \n

\u8fd9\u5728\u65e9\u671f\u4e3b\u8981\u7528\u4e8e IDE \u8bbe\u8ba1\u65f6, \u8b6c\u5982\u628a\u4e00\u4e2a Button \u653e\u5230\u7a97\u4f53\u540e, \u6b64\u65f6\u6211\u4eec\u7684\u7a0b\u5e8f\u867d\u7136\u6ca1\u6709\u8fd0\u884c, \u4f46\u5728 Delphi \u7684 IDE \u7f16\u8f91\u73af\u5883\u4e2d, \u8fd9\u4e2a Button \u5df2\u7ecf\u662f\u5728\u8fd0\u884c\u72b6\u6001\uff08\u8981\u4e0d\u7136IDE\u600e\u4e48\u624d\u80fd\u663e\u793a\u6211\u4eec\u8981\u6c42\u7684TButton\u5462\uff09; \u6b64\u65f6\u6211\u4eec\u5bf9 Button \u7684\u5c5e\u6027\u7b49\u4fe1\u606f\u7684\u8bbe\u7f6e\u90fd\u662f\u901a\u8fc7 RTTI \u6280\u672f\u5b9e\u73b0\u7684.<\/p> \n

 <\/p> \n

\u4f46\u5728 Delphi 2007 \u4e4b\u524d, \u80fd\u591f\u83b7\u53d6 RTTI \u4fe1\u606f\u662f\u6709\u9650\u7684.<\/p> \n

Delphi 2009 \u589e\u52a0\u4e86 ObjAuto \u5355\u5143\u3001Delphi 2010 \u589e\u52a0\u7684 RTTI \u5355\u5143, \u8fd9\u90fd\u53ef\u4ee5\u8ba9\u7a0b\u5e8f\u5728\u8fd0\u884c\u65f6\u5bf9\u7c7b\u578b\u6709\u66f4\u591a\u638c\u63a7(\u526f\u4f5c\u7528\u662f\u6700\u540e\u751f\u6210\u7684\u7a0b\u5e8f\u8d8a\u6765\u8d8a\u5927).?<\/p> \n

-------------------------------------\u4f8b\u5b501----------------------------------------<\/p> \n

Uses Rtti, TypInfo;<\/p> \n

procedure TForm1.Button3Click(Sender: TObject);<\/p> \n

begin<\/p> \n

ShowMessage(GetEnumName(TypeInfo(TFormStyle), Ord(FormStyle)));<\/p> \n

end;<\/p> \n

\u4e3b\u7a97\u4f53\u4e0a\u653e2\u4e2aLabel\uff0c3\u4e2aButton\uff0c\u7136\u540e<\/p> \n

procedure TForm1.Button1Click(Sender: TObject);<\/p> \n

var<\/p> \n

i: integer;<\/p> \n

PropInfo: PPropInfo;<\/p> \n

begin<\/p> \n

for I := 0 to ComponentCount-1 do<\/p> \n

begin<\/p> \n

PropInfo:=GetPropInfo(Components[i].ClassInfo, 'Color');<\/p> \n

if PropInfo <> nil then<\/p> \n

SetOrdProp(Components[i], PropInfo, clBlue);<\/p> \n

end;<\/p> \n

end;<\/p> \n


-----------------------------------
Delphi\u7684RTTI\uff08\u8bb8\u591a\u53c2\u8003\u94fe\u63a5\uff09
https:\/\/blog.51cto.com\/u_15127692\/4693281<\/p> \n<\/div>","orderid":"0","title":"dephi RTI \uff08Runtime Type Information\uff09\u83b7\u53d6\u8fd0\u884c\u65f6\u7684\u63a7\u4ef6\u4fe1\u606f","smalltitle":"","mid":"0","fname":"Delphi","special_id":"0","bak_id":"0","info":"0","hits":"190","pages":"1","comments":"0","posttime":"2023-08-06 07:49:28","list":"1691279368","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"dephi<\/A> RTI<\/A> Runtime<\/A> Type<\/A> Information<\/A> \u65f6\u7684\u63a7<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"211.148.71.108","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"dephi RTI \uff08Runtime Type Information\uff09\u83b7\u53d6\u8fd0\u884c\u65f6\u7684\u63a7\u4ef6\u4fe1\u606f","lastview":"1713289991","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}