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

# TWSWinControl.GetPreferredSize

Returns the preferred size of a widget, independent of current Width, Height, child controls and scrollbars.

## Declaration

Source position: wscontrols.pp line 110

`published class procedure TWSWinControl.GetPreferredSize(`
`const AWinControl: TWinControl;`
`var PreferredWidth: Integer;`
`var PreferredHeight: Integer;`
`WithThemeSpace: Boolean`
`); virtual;`

## Description

Values <=0 mean there is no preferred size. If the control.ControlStyle has the flag csAutoSize0x0 then 0 is allowed for this control. At the moment only TPanel has this flag.

The values must be independent of the current Width or Height, because the LCL resizes them depending on these values (circle). The values must be independent of the child controls, because the LCL moves and resizes them depending on these values (circle). The values must be independent of scrollbars, because the LCL hides them depending on these values (circle). The values are only taken if no other constraint/anchor was applied.

If the widgetset does not support some sizes, then it should set interface constraints.