[RE: [[lazarus] CreateComponent]]

Samuel Liddicott sam at campbellsci.co.uk
Tue Aug 17 05:50:58 EDT 1999




> -----Original Message-----
> From: Michal Bukovjan [mailto:mbukovjan at netscape.net]
> Sent: 17 August 1999 12:22 PM
> To: lazarus at miraclec.com
> Subject: Re: [RE: [[lazarus] CreateComponent]]
>
> Well, this might be good if it somewhat glues together the
> differences between
> Win32 and Gtk/Qt/whatever. I am curious :-)

It does/will

> > > recreate control. Yes, you can destroy and then create the
> > > control once again,
> > > then setup all properties, but this is a DRAG.
> >
> > Its not really a drag, its fully "automatic".  There is no
> problem with it
> > at all.
>
> It is a DRAG (tm), becuase (in case of recreating GTK control):
>
> 1. Memory must be reallocated, may cause memory fragmentation.

ah, yes.

> 2. Children controls, as well as parent will have to be informed of that
> (which is automatic, but still it is a overhead), some of them
> being destroyed
> along the way (unless someone rewrites the GTK libs).

You are right, all child windows are re-created too (automatically of
course)

> 3. You have to remember most of the properties and then re-assign
> them, which
> is NOT automatic.

As you say.

> In fact, many of the properties (like Items)
> are held only
> within the control (not in Lazarus wrapper), and once you destroy
> the control,
> you have to keep a copy in memory :-(, then re-assign them as
> well.
> BTW, the
> same applies to Delphi and Win32 stuff.

This is how Delphi does it

> I don't know what they do in Win32 when re-creating
> handles/controls, but that
> might be one of the reasons why Windows is so slow. (Although I
> admit that in
> real world application, you usually do not change many properties on-the
> fly).

It is usually only properties that affect the fundamental appearance that
cause a re-createwnd - it actually rarely happens. Changing border does it
for one, but we MUST support this for other reasons: It should be possible
to remove a TListBox so it has no parent, and then assign it to a parent in
ANOTHER FORM and still keep it's contents.

> Again, I am talking about GTK, not Win32. So the best solution
> for RecreateWnd
> for GTK would be to be ignored.

RecreateWnd itself will not be needed for GTK, but the things it uses to do
its tricks will be needed, as in above about moving listbox to another form.
But its just donky work, nothing difficult about it.  And the slow-down only
occurs when it is used - rarely but when it is used it is needed and a
work-around would be even worse.  I will manage/check this if you want.

Sam






More information about the Lazarus mailing list