[Lazarus] Hiding a component by changing its parent
Martin Grajcar
maaartinus at gmail.com
Mon Aug 24 16:29:49 CEST 2015
In code I'm working on, I've found a pattern like
PROCEDURE HideIt;
BEGIN
SomeComponent.Visible := FALSE;
SomeComponent.Parent := SELF;
SomeComponent.Visible := TRUE;
END;
PROCEDURE ShowIt(NewParent: TForm);
BEGIN
SomeComponent.Visible := FALSE;
SomeComponent.Parent := NewParent;
...some more stuff...
SomeComponent.Visible := TRUE;
...some more stuff...
END;
I can't really see what it's good for. I guess, the idea was to preserve
the widget, but the widget seems to get freed immediately in the first
line. It comes from D7 or older. Does it make sense on Lazarus 1.4 using
GTK+?
Whenever there's a focused TextField in SomeComponent, there's a segment
violation on Linux after HideIt. It looks like an event (lost focus?) gets
delivered to its already freed widget. Any thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150824/2bd324e9/attachment-0002.html>
More information about the Lazarus
mailing list