Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Accessing nested properties of components

Status
Not open for further replies.

luben111

Advanced Member level 1
Joined
Mar 2, 2002
Messages
489
Helped
111
Reputation
223
Reaction score
107
Trophy points
1,323
Location
UK
Activity points
3,924
Hi,
I have the following problem - to read and write the properties of components in my application. Imagine that I have a TLabel component and it has Property Font.Name

How I can access the property of Font.Name by using strings as description of the field names - i.e. I need a function like this

ReadComponentPropertyAsSTring(component : TComponent; propertyName : String) : String;

If the property is not nested (example for nested property is Label1.Font.Name) then I can easily read or write the property by using GetPropInfo, GetPropValue and SetPropValue as listed below:

function ReadComponentPropertyAsString(component : TComponent; propertyName : String) : String; // read the property of component
var
propInfo : PPropInfo;
begin

Result := '';
propInfo := GetPropInfo(component.ClassInfo, propertyName); // we try to locate the property from RTTI

if Assigned(propInfo) then
begin
Result := GetPropValue(component, PropInfo, True); // we'll get the property as string
end;
end;

My question is - how should look like the same function ReadComponentPropertyAsString listed above if I have to read the property of Label1.Font.Name ?

Thank you!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top