In article <Xns915C242E8E30kristianvirkuswe...@62.153.159.134>, Kristian Virkus
wrote:
Quote
> I'd like to load strings from a file and then change the caption property of
> some components given by the strings.
> In the following example
> ComponentName and
> ClassName are strings loaded from a file:
> (Form1.FindComponent(ComponentName) as Class(ClassName)).Caption := ...
You can dispense with the classname. Use the component name with FindComponent
and then use routines from the Typinfo unit to set the property by name.
You can modify the routine below as you need.
{-- SetControlText ----------------------------------------------------}
{: Set a control Text propery, if it has one. If it does not, try the
Caption property.
@Param aControl is the control to work on.
@Param aText is the text to copy.
Quote
}{ Created 13.12.2000 by P. Below
-----------------------------------------------------------------------}
Procedure SetControlText( aControl: TControl; Const aText: String );
Begin { SetControlText }
Assert( Assigned( aControl ));
If IsPublishedProp( aControl, 'Text' ) Then
SetStrProp( aControl, 'Text', aText )
Else If IsPublishedProp( aControl, 'Caption' ) Then
SetStrProp( aControl, 'Caption', aText );
End; { SetControlText }
Quote
> This example doesn't work. Can anybody tell me how to realize such a task?
> If you can, please send me an example.
> I'd be glad about any answer.
> Kristian Virkus
Peter Below (TeamB) 100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Note: I'm unable to visit the newsgroups every day at the moment,
so be patient if you don't get a reply immediately.