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

# TCustomFlowPanel.CalculatePreferredSize

Calculates the preferred size for the control.

## Declaration

Source position: extctrls.pp line 1323

`protected procedure TCustomFlowPanel.CalculatePreferredSize(`
`var PreferredWidth: Integer;`
`var PreferredHeight: Integer;`
`WithThemeSpace: Boolean`
`); override;`

## Arguments

`PreferredWidth` |  | Preferred width for new instances of the control.
`PreferredHeight` |  | Preferred height for new instances of the control.
`WithThemeSpace` |  | True if additional space is reserved for theme element details.

## Description

CalculatePreferredSize is an overridden procedure used to calculate the preferred height and width for the flow panel. The preferred height and width are used in the LCL auto-sizing algorithm as the default size for the control. CalculatePreferredSize calls the inherited method on entry to calculate preferred dimensions for its child Controls.

CalculatePreferredSize extends the inherited method to calculate the preferred width and height using the FlowStyle for the child Controls. It ensures that additional space for bevels on the panel and BorderSpacing for the child controls are included in the calculated preferred width and height. Only visible child controls are included in the calculated values.

## Version info

Modified in LCL 2.2.6+ to exclude hidden child controls from the calculated dimensions for the flow panel.

## See also

TCustomFlowPanel.FlowStyle |  | Contains the flow direction used to position controls on the panel.
TControl.CalculatePreferredSize |  | Override this method to return the preferred height and width for the control.