Board index » delphi » Assigning componentes properties by a string

Assigning componentes properties by a string

    How can I set a property of a component if I have the property name
in a string?
    P.S.: Im trying to create components dynamic from a DFM file,
reading the properties
and set than to the values in the file.I Think that TForm to that, but I
could not find it
in the source code of VCL.
            I had tried the ReadResFromFile or something like that, but
that just works fine
for simple components, not for those wich has others components inside,
like a TPageControl.
            I really want to read and mount dynamic the components,
because I want to can
change or add some components with no executable redistribution.

            Thanks for any help.

Eduardo Rambo.

 

Re:Assigning componentes properties by a string


Quote
In article <399DCC65.675D7...@portoweb.com.br>,  wrote:
>     How can I set a property of a component if I have the property name
> in a string?

You can if the property is published, through using run-time type
information and the (undocumented) routines in the TypInfo unit.

Quote
>     P.S.: Im trying to create components dynamic from a DFM file,
> reading the properties
> and set than to the values in the file.I Think that TForm to that, but I
> could not find it
> in the source code of VCL.

The actual streaming code is located in the implementations of TReader and
TWriter in the Classes unit. If you have a valid DFM file and all the
classes it contains have been registered via RegisterClasses and there are
no name clashes with existing components on your form you can load the
resource by opening it in a TFilestream and using the streams ReadComponent
method.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads