Rtti.TRttiType (Delphi)
Description
Contents
This example is a Delphi VCL Forms Application that displays in a TTreeView component the RTTI that can be found for the TButton class.
Code
procedure TForm1.FormCreate(Sender: TObject);
var
LContext: TRttiContext;
LType: TRttiType;
LMethod: TRttiMethod;
LProperty: TRttiProperty;
LField: TRttiField;
LTreeNode1, LTreeNode2: TTreeNode;
begin
LContext := TRttiContext.Create;
try
LType := LContext.GetType(TButton);
LTreeNode1 := TreeView1.Items.AddChild(nil, LType.ToString);
LTreeNode2 := TreeView1.Items.AddChild(LTreeNode1, 'Methods');
for LMethod in LType.GetMethods do
begin
TreeView1.Items.AddChild(LTreeNode2, LMethod.ToString);
end;
LTreeNode2 := TreeView1.Items.AddChild(LTreeNode1, 'Properties');
for LProperty in LType.GetProperties do
begin
TreeView1.Items.AddChild(LTreeNode2, LProperty.ToString);
end;
LTreeNode2 := TreeView1.Items.AddChild(LTreeNode1, 'Fields');
for LField in LType.GetFields do
begin
TreeView1.Items.AddChild(LTreeNode2, LField.ToString);
end;
TreeView1.FullExpand;
finally
LContext.Free;
end;
end;
Uses
- System.Rtti.TRttiType.GetMethods ( fr | de | ja )
- System.Rtti.TRttiMethod.ToString ( fr | de | ja )
- System.Rtti.TRttiType.GetProperties ( fr | de | ja )
- System.Rtti.TRttiType.GetFields ( fr | de | ja )
- System.Rtti.TRttiType ( fr | de | ja )
- System.Rtti.TRttiProperty ( fr | de | ja )
- System.Rtti.TRttiMethod ( fr | de | ja )
- System.Rtti.TRttiField ( fr | de | ja )