[Lazarus] How to load the Form from LFM-file at run time?
Александр С.
sss0991 at gmail.com
Mon Feb 18 12:49:55 CET 2013
Example: there is a empty form that has an event: another form (from
LFM-file) to be loaded instead of this form by double-clicking on old
form at run time.
I tried several ways to do this, for example:
1. File -> FileStream -> BinStream -> BinStream.ReadComponent(Form)
2. ReadComponentResFile()
These methods have drawbacks:
a. Double-clicking event from the old form doesn't disappear in new
b. Need to register (RegisterClasses) for all the classes that are in
the new form. Parsing the LFM-file, you can get the names of classes
in the strings. What content should have a function "function
StringToClass(AStr: string): TClass", to be able to call
"RegisterClass(StringToClass(AStr))" ?
3. File -> StringStream -> Reader -> Reader.ReadComponent -> InsertComponent
But my methods does not work. Could you please help me: how to load
Form from LFM-file at run time?
More information about the Lazarus
mailing list