LCL Internals - Resizing, Moving

From Lazarus wiki
Jump to navigationJump to search

Overview

The LCL has a lot of resizing properties (Left, Width, Anchors, Align, AnchorSide, AutoSize, Constraints, ChildSizing, ...) and hooks where applications can alter the behavior (OnResize, OnChangeBounds, ...). All these things can not be calculated in one step, so controls can move quite a lot before the final coordinates come out. To reduce flickering the LCL does not send every move/resize to the LCL interface. For example during Begin/EndAlign and csLoading no move/resize is sent to the interface. The widgetset will try to follow the advices of the LCL, but there are some cases, where it does not follow. For example forms (top level windows) are limited by the window manager policies. And TPage completely depends on the size and theme of the TNotebook.

How the LCL tells the interface to resize/move a handle

In TWinControl.DoSendBoundsToInterface the widget function SetBounds is called

 TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);

How the Interface tells the LCL to resize/move a handle

First the LCL interface send a LM_WINDOWPOSCHANGED message

  • x := Left (relative to 0,0 of client area of parent)
  • y := Top
  • cx := Width
  • cy := Height

Then a LM_SIZE message is sent

  • Width
  • Height
  • SizeType is a bit flag containing Size_SourceIsInterface plus one of the values SIZENORMAL, SIZEICONIC, SIZEFULLSCREEN.

Then a LM_MOVE message is sent

  • MoveType := Move_SourceIsInterface;
  • XPos := Left (relative to 0,0 of client area of parent)
  • YPos := Top

How the LCL gets the current size / position of a LCL interface handle