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

# TControl.GetPreferredSize

Returns default/preferred height and width, for use in auto-sizing.

## Declaration

Source position: controls.pp line 1663

`public procedure TControl.GetPreferredSize(`
`var PreferredWidth: Integer;`
`var PreferredHeight: Integer;`
`Raw: Boolean = False;`
`WithThemeSpace: Boolean = True`
`); virtual;`

## Arguments

`PreferredWidth` |  | Default width for a new instance of the control.
`PreferredHeight` |  | Default height for a new instance of the control.
`Raw` |  | When False, the values will be adjusted by the constraints, and undefined values will be replaced by GetDefaultWidth/GetDefaultHeight.
`WithThemeSpace` |  | If True, adds space for stacking.

## Description

Called during AutoSize calculations. Only positive values are valid. Negative or 0 are treated as undefined and the LCL uses other sizes instead.

WithThemeSpace: If True, adds space for stacking.

For example: TRadioButton has a minimum size. But for stacking multiple TRadioButtons there should be some space around. This space is theme dependent, so the parameter is passed to the widgetset

TWinControl overrides this and asks the interface for theme dependent values. See TWinControl.CalculatePreferredSize for more information.