On Mon, 23 Jul 2007, Graeme Geldenhuys wrote:
> On 23/07/07, Michael Van Canneyt <[EMAIL PROTECTED]> wrote:
> >
> > The .lfm file is not code. It's a resource, which you can replace
> > at runtime.
>
> OK, I understand the resource part. It's components that have been
> streamed to a file. From this I also assume that it will recreate the
> form faster than via code. But on today's computers I don't really
> know is that is relevant anymore.
No, via code is actually faster. It saves the RTTI lookup etc.
>
> Can you explain the 'replace at runtime' part a bit more. I'm not sure
> I understand that statement. :)
The form definition is stored in a resource as text. In theory you
can replace the resource with another resource. The translation engine
of Delphi relies on this, for instance...
Suppose I have a form definition:
MyForm Object TMyForm
Caption = 'A nice form'
Width = 200
Height = 100
end
Then it can be replaced in the running binary by e.g. a translated version
MyForm Object TMyForm
Caption = 'Een leuk venster'
Width = 220
Height = 110
end
With adapted width and height (a dutch text is usually longer).
The alternative version can be loaded from a resource dll, or from
file. XML comes to mind: the original author of fpGUI imagined that the
original form is stored as XML. It would then be easy to create a second
XML 'overload' part which can be used to change the visual appearance of
the form. This second XML file could simply be loaded from a file on disk.
Using the constructor method, all this is not possible (well, I suppose you
could find a way, but it would be less elegant). Since the form definition
is now just text, it can be simply replaced with another text. If the form
definition was XML, this would actually be very easy. Now it is slightly
more complicated.
Michael.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives