{"id":674,"date":"2008-05-20T07:20:10","date_gmt":"2008-05-20T07:20:10","guid":{"rendered":"http:\/\/6teen.ru\/?p=335"},"modified":"2008-05-20T07:20:10","modified_gmt":"2008-05-20T07:20:10","slug":"6662","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=674","title":{"rendered":"\u041a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438"},"content":{"rendered":"<p>\u041a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438\n\ntype\nTForm1 = class(TForm)\nButton1: TButton;\nprocedure Button1Click(Sender: TObject);\nprivate\nf1 : Integer; \/\/ \u042d\u0442\u043e \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\npublished\n{\u041a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 p1 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438}\nproperty p1 : Integer read f1 write f1;\nend;\n\nvar\nForm1: TForm1;\n\nimplementation\n\n{$R *.DFM}\n\nuses\nTypInfo;\n\nprocedure TForm1.Button1Click(Sender: TObject);\nvar\nPInfo : PPropInfo;\nbegin\np1 := GetTickCount; \/\/ \u0417\u0434\u0435\u0441\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u0447\u0442\u043e-\u0442\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b\u0438\n\nPInfo:= GetPropInfo(TForm1.ClassInfo, 'p1'); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\n\/\/ \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430\nif PInfo = nil then\nraise Exception.Create('Property not exist');\nCaption := IntToStr(GetOrdProp(Form1, PInfo)); \/\/ \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\n\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\nend;\n+++++++++++++++++++++++++++++++++++++++++\n\nuses\nTypInfo;\n\nfunction ObjPropInfo(AObject: TObject; const PropName: String): PPropInfo;\nbegin\nResult := GetPropInfo(AObject.ClassInfo, PropName);\nif Result = nil then\nraise Exception.Create('Property not exist');\nend;\n\nprocedure SetOrdProperty( AObject: TObject; const PropName:String;  const\nValue: Longint);\nbegin\nSetOrdProp(AObject, ObjPropInfo(AObject, PropName), Value);\nend;\n\nfunction GetOrdProperty(AObject: TObject; const PropName:String):Longint;\n{\u0441\u043c. \u0442\u0430\u043a\u0436\u0435 TypInfo: GetStrProp, GetFloatProp, GetEnumValue etc.}\nbegin\nResult:= GetOrdProp(AObject, ObjPropInfo(AObject, PropName));\nend;\n\nprocedure SetStrProperty( AObject: TObject; const PropName:String; const\nValue: String);\nbegin\nSetStrProp(AObject, ObjPropInfo(AObject, PropName), Value);\nend;\n\nprocedure SetFloatProperty( AObject: TObject; const PropName:String; const\nValue: Extended);\nbegin\nSetFloatProp(AObject, ObjPropInfo(AObject, PropName), Value);\nend;\n\nprocedure SetVariantProperty( AObject: TObject; const PropName:String; const\nValue: Variant);\nbegin\nSetVariantProp(AObject, ObjPropInfo(AObject, PropName), Value);\nend;\n\nprocedure SetMethodProperty( AObject: TObject; const PropName:String; const\nValue: Pointer);\nvar\nAMethod: TMethod;\nbegin\nAMethod.Code := Value;\nAMethod.Data := AObject;\nSetMethodProp(AObject, ObjPropInfo(AObject, PropName), AMethod);\nend;\n\nprocedure TForm1.Button1Click(Sender: TObject);\nvar\nAFont: TFont;\nbegin\nSetOrdProperty(Button1, 'Width', 100); \/\/ \u0446\u0435\u043b\u043e\u0435\nAFont := TFont.Create;\nAFont.Style := [fsBold];\nSetOrdProperty(Button1, 'Font', Longint(AFont)); \/\/ \u043e\u0431\u044a\u0435\u043a\u0442\nAFont.Free;\nSetMethodProperty(Button1, 'OnClick', @TForm1.Button2Click); \/\/ \u043c\u0435\u0442\u043e\u0434\nend;\n\nprocedure TForm1.Button2Click(Sender: TObject);\nbegin\nShowMessage((Sender as TButton).Caption);\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u0430\u043a \u043e\u0431\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 \u043f\u043e \u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[386,454],"tags":[1498,1702],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/674"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=674"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/674\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=674"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}