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
TProperty class
TProperty class is a class that allows to access to the property of some object. Any information can be access with extremal simplicity:
procedure TForm1.FormClick(Sender: TObject);
var
  P: TProperty;
begin
  with TPropertyList.Create(nil) do
  try
    Instance:=Self;
    Root:=Self;

    // retreiving the font name
    P:=FindProperty('Font.Name');
    if Assigned(P) then ShowMessage(P.AsString);

    // changing the font style - different ways
    P:=FindProperty('Font.Style');
    if Assigned(P) then
    begin
      // setting as integer using set bit masks
      P.AsInteger:=Integer(1 shl Integer(fsItalic));
      // setting as string
      P.AsString:='[fsBold,fsItalic,fsUnderline]';
    end;
    // direct setting using subproperty
    P:=FindProperty('Font.Style.fsBold');
    if Assigned(P) then P.AsBoolean:=False;
    // changing the font using direct access to the Font object
    P:=FindProperty('Font');
    with (P.AsObject as TFont) do
    begin
      Style:=[];
      Color:=clRed;
    end;
    // restoring the font color
    P:=FindProperty('Font.Color');
    if Assigned(P) then P.AsInteger:=clWindowText;
    // the string value can be used too:
    // if Assigned(P) then P.AsString:='clWindowText';

    // getting the method declaration
    P:=FindProperty('OnDragOver');
    if Assigned(P) then ShowMessage(P.MethodDeclaration);
  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