Property InterfaceSimple-in-use way to RTTI for VCL and FMX
For all versions of Delphi and C++ Builder from 3 to 10.2 Tokyo and for all versions of Windows from XP to 10
Property Interface (TPropertyInterface component) allows you to access any property and event of any object at runtime by it's name. The complete list of properties and events is also availabe in the indexed list. Each property is present by special TProperty class that provides complete information about the property including value, type, access methods addresses, minimal and maximal values, enumeration lists, and much more. The complete set of value access methods are available too: AsFloat, AsMethod, AsInteger, AsChar, AsString and so on.
Just drop TPropertyInterface component onto the form, assign Root and Instance properties and access any value of any property at runtime with very simple code:
The indexed list of all the properties allows to do some very interesting tricks. For example, the following code makes all the string properties of all components on the form upper case:
uses ..., TypInfo, PropList, PropIntf; ... var P: TProperty; begin P:=cmpPropertyInterface.FindProperty('Caption'); if Assigned(P) then P.AsString:='New Caption'; P:=cmpPropertyInterface.FindProperty('Font.Style.fsBold'); if Assigned(P) then P.AsBoolean:=True; end;
Property Interface suite contains special demo projects for VCL and FMX that demonstrate all the features of TPropertyInterface component and TProperty class:
uses ..., TypInfo, PropList, PropIntf; ... var C,P: Integer; Prop: TProperty; begin // components loop for C:=0 to Pred(ComponentCount) do with PropertyInterface do begin Instance:=Self.Components[C]; // component's properties loop for P:=0 to Pred(Count) do begin Prop:=Properties[P]; if Assigned(Prop) then with Prop do if TypeKind in [tkString,tkLString,tkWString,tkUString] then // this is a string type property, we must process it AsString:=UpperCase(AsString); end; end; end;