Understanding run-Time type information (RTTI)

Source: Internet
Author: User

Rtti need to reference unit TypeInfo

The Getpropinfo function is used to get the RTTI pointer ppropinfo of the property. It has four overloaded forms, and the subsequent implementations of the three overloads are the first form of invocation. The Akinds parameter is used to restrict the type of the property, and nil is returned if the resulting ppropinfo does not belong to the specified type.

function Getpropinfo (typeinfo:ptypeinfo; const propname:string): Ppropinfo;

function Getpropinfo (instance:tobject; const propname:string; Akinds:ttypekinds = []): Ppropinfo;

function Getpropinfo (aclass:tclass; const propname:string; Akinds:ttypekinds = []): Ppropinfo;

function Getpropinfo (typeinfo:ptypeinfo; const propname:string; Akinds:ttypekinds): Ppropinfo;

//The following code loops through the Capiton of the button component on the form//method One:proceduretform1.setcaption;varPinfo:ppropinfo; I:integer;begin   forI: =0  toSelf.controlcount-1  Do  beginPInfo:= Getpropinfo (Self.controls[i],'Caption');//Getpropinfo, find Caption property according to ' Caption ' string    ifPInfo <>Nil  Then                             //if there isTButton (Self.controls[i]). caption:='ABC';//Modify Capiton  End;End; method Two:proceduretform1.setcaption;varPinfo:ppropinfo; I:integer;begin   forI: =0  toSelf.controlcount-1  Do  beginPInfo:= Getpropinfo (Self.controls[i],'Caption'); ifPInfo <>Nil  ThenSetpropvalue (Self.controls[i],'Caption','ABC'); End;End;

Reference: http://www.cnblogs.com/key-ok/p/3358804.html

Understanding run-Time type information (RTTI)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.