[Lazarus] Which method is called at the very end of TWinControl creation?

2015-11-08 Thread Krzysztof
Hi,

I have form which has a lot of panels created at runtime. These panels have
controls and splitters (inside). The problem is with setting initial
splitters position when user open form. I want that spliiters should have
center position of its parent (parent = runtime created panel) but it is
tricky because parents of splitters are not fully initialized and have
Width and Height = 0 so I can't calculate splitter position on creation
stage. Whole layout is based on Aligns.
I solved this by overriding AdjustSize/InvalidatePreferredSize method.
There I'm checking if widths and heights are <> 0, if yes then setting up
splitters. It is working fine but I'm wondering if there is more clear
solution. What I'm looking is virtual method like
"ThisIsCalledWhenControlIsCompletelyAdjustedAndReadyWithAllChildrens" .
Tried other methods like VisibleChanged, ChildHandlesCreated etc
but without success

Regards
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Which method is called at the very end of TWinControl creation?

2015-11-08 Thread Howard



On 08/11/2015 17:05, Krzysztof wrote:
What I'm looking is virtual method like 
"ThisIsCalledWhenControlIsCompletelyAdjustedAndReadyWithAllChildrens" 
. Tried other methods like VisibleChanged, ChildHandlesCreated etc 
but without success


Possible methods to try include:

Loaded
FormEndUpdated

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Which method is called at the very end of TWinControl creation?

2015-11-08 Thread Mattias Gaertner
On Sun, 8 Nov 2015 18:05:10 +0100
Krzysztof  wrote:

> Hi,
> 
> I have form which has a lot of panels created at runtime. These panels have
> controls and splitters (inside). The problem is with setting initial
> splitters position when user open form. I want that spliiters should have
> center position of its parent (parent = runtime created panel) but it is
> tricky because parents of splitters are not fully initialized and have
> Width and Height = 0 so I can't calculate splitter position on creation
> stage. Whole layout is based on Aligns.
> I solved this by overriding AdjustSize/InvalidatePreferredSize method.
> There I'm checking if widths and heights are <> 0, if yes then setting up
> splitters. It is working fine but I'm wondering if there is more clear
> solution. What I'm looking is virtual method like
> "ThisIsCalledWhenControlIsCompletelyAdjustedAndReadyWithAllChildrens" .

If you need to change the Splitter position, then apparently the
control is not completely adjusted.
Every time some layout property changes the LCL has to recompute the
layout. To avoid overhead, you should react early instead of late.

If your splitter depends on the client size of its parent, then you can
use the parent's DoOnChangeBounds/OnChangeBounds or AlignControls.


Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus