Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
More info
Object Inspector FAQ
Object Inspector Home
Delphi Components
See also
Products
Form Designer
Runtime Fusion
Print Suite
Commented Image
Image Editor  new!
Delphi Toys
Ultimate Pack  hot!

FAQs
Form Designer FAQ
Print Suite FAQ
Image Editor FAQ

Links
Software for .NET
Software for VB 6
Delphi Tips & Tricks

Services
Outsourcing
Access internal data of RTTI (Runtime Type Information)
TProperty has properties allowing to access all RTTI-related technical information through the properties appropriate to RTTI's PropInfo data (PropType, GetProc, SetProc, StoredProc, Index, Default, NameIndex and Name). The following example shows the NameIndex (sequental number of the property in the class declaration).
procedure TForm1.FormClick(Sender: TObject);
var
  P: TProperty;
begin
  with TPropertyList.Create(nil) do
  try
    Instance:=Self;
    Root:=Self;
    P:=FindProperty('Caption');
    if Assigned(P) then ShowMessage(IntToStr(Integer(P.NameIndex)));
  finally
    Free;
  end;
end;
Most useful property from the PropInfo data is Name that contains the property name. The following code fills the memo with the names of all properties of the form.
procedure TForm1.FormClick(Sender: TObject);
var
  i: Integer;
  S: string;
begin
  with TPropertyList.Create(nil) do
  try
    Instance:=Self;
    Root:=Self;
    S:='';
    for i:=0 to Pred(Count) do S:=S+Properties[i].Name+#13;
    Memo1.Lines.Text:=S;
  finally
    Free;
  end;
end;

Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software