[Lazarus] AlignTop/AlignBottom issue

Mattias Gaertner nc-gaertnma at netcologne.de
Tue May 26 14:50:19 CEST 2015


On Mon, 25 May 2015 19:13:27 +0200
Giuliano Colla <giuliano.colla at fastwebnet.it> wrote:

> AlignTop and AlignBottom do not appear to behave as they should.
> 
> When you have several controls contained in another control, you would 
> expect that each AlignTop or AlignBottom would stack the control in the 
> first free position: with AlignBottom on top of the stack of the other 
> bottom aligned components, with AlignTop at the bottom of the stack of 
> the other top aligned components.

It works like this:
http://wiki.lazarus.freepascal.org/Autosize_/_Layout#Order_of_controls_with_same_Align

When you drop (or move) a control with alTop in the designer, the
control is inserted at the current mouse position. It is *not* moved to
the free bottom/top position. This is Delphi compatible.

When you add controls at runtime, keep in mind that the initial
control's Left/Top is 0,0. Contrary to the VCL the LCL can (and often
does) delay updating the layout (DisableAutoSize/EnableAutoSize).
For example all changes in FormCreate are delayed and the layout
is computed from the final property values. On the other hand
ButtonClick has no delay (aka you have to add the
Disable/EnableAutoSize yourself), so inserting alTop controls may have
different results.

If you want a specific order, use Disable/EnableAutoSize and set the
"Top" properties.

Mattias




More information about the Lazarus mailing list