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 properties at runtime
The retreiving and changing the property value can be done by special access properties: AsFloat, AsMethod, AsInteger, AsChar, AsBoolean, AsObject, AsDateTime, AsDate, AsTime, AsString, AsVariant. Just use the appropriated property to get/set the value. Nothe that the AsString property can be used for any property type and the following ways will have the same effect.
var
  P: TProperty;
...
  P:=SomePropertyList.FindProperty('Color');
  P.AsInteger:=clRed;
  P.AsString:='clRed';
Each property has Properties property (TPropertyList type) that contains the subproperties (like properties of the Font property in TControl) and the FullName property the contains the name of the property and the names of all owner properties divided by points. The FindProperty method of TPropertyList class supports full names, so the code
procedure TForm1.FormClick(Sender: TObject);
var
  P1,P2: TProperty;
begin
  with TPropertyList.Create(nil) do
  try
    Instance:=Self;
    Root:=Self;
    P1:=FindProperty('Font');
    P2:=P1.Properties.FindProperty('Color');
    P2.AsInteger:=clRed;
  finally
    Free;
  end;
end;
can be simplified to the code
procedure TForm1.FormClick(Sender: TObject);
var
  P: TProperty;
begin
  with TPropertyList.Create(nil) do
  try
    Instance:=Self;
    Root:=Self;
    P:=FindProperty('Font.Color');
    P.AsInteger:=clRed;
  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