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

# TCustomFrame.CalculatePreferredSize

Gets the preferred height and width for the control used during auto-sizing.

## Declaration

Source position: forms.pp line 330

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

## Arguments

`PreferredWidth` |  | Preferred width for the control.
`PreferredHeight` |  | Preferred height for the control.
`WithThemeSpace` |  | True if additional space is reserved in the width or height for theme details.

## Description

CalculatePreferredSize is an overridden method in TCustomFrame. It ensures that the inherited method is not called when the frame is an un-parented component and visible on the form designer. This allows the dimensions to be freely resized on the design surface. Values in the PreferredWidth, PreferredHeight, and WithThemeSpace arguments are not modified at design-time.

If the frame has an Owner (parent form) at run-time, the inherited method is called to get the values used in the LCL auto-sizing algorithms.

## See also

TWinControl.CalculatePreferredSize |  | Override this method to return a different preferred height and/or width for auto-sizing.