[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Controls' (#lcl)

# TWinControl.AlignControls

Repositions and resizes the control and child controls.

## Declaration

Source position: controls.pp line 2157

`protected procedure TWinControl.AlignControls(`
`AControl: TControl;`
`var RemainingClientRect: TRect`
`); virtual;`

## Arguments

`AControl` |  | Control examined and updated in the method.
`RemainingClientRect` |  | The available space, becomes remaining space on exit.

## Description

AlignControls is a method used to reposition and resize the specified control and the children in its Controls property. This includes using the DockManager (when assigned and enabled) to reserve space for docked controls in the client rectangle. It uses settings in the Align, Anchor, BorderSpacing, ChildSizing, and Constraints properties to determine the actions needed in the method for each of the controls.

AlignControls checks and updates the windowed control flags prior to starting the operation. No actions are performed in the method when wcfAligningControls is already included in the control flags.

The ControlsAligned method is called when the method is completed, and the control flags are updated to remove the value wcfAligningControls.

AlignControls is called from the private AlignControl method after the client rectangle has been adjusted and the logical display area for the control has been determined. AlignControl is the boss; AlignControls performs the heavy lifting.

## Version info

Behavior modified in LCL version 3.4 to use the adjusted client rectangle when controls are aligned.

## See also

TWinControl.Controls |  | Provides indexed access to the child controls for the class instance.
TWinControl.AdjustClientRect |  | Override this method when the ClientRect for a control differs from the default value.
TWinControl.ChildSizing |  | Provides a grid (table) layout for the children of this control.
TWinControl.DoAdjustClientRectChange |  | Asks the widget if ClientRect has changed since the last AlignControl execution; calls AdjustSize on change.
TControl.DoAllAutoSize |  | Resizes and aligns the control and all of it children.
TWinControlFlag |  | State flags of TWinControl.