Unit 'Controls' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#lcl]


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


Source position: controls.pp line 2117

protected procedure TWinControl.CalculatePreferredSize(

  var PreferredWidth: Integer;

  var PreferredHeight: Integer;

  WithThemeSpace: Boolean

); override;




Indicates if additional space is reserved for theme services.


Calls the inherited method to calculate the default / preferred width and height for a TWinControl instance. It is used by the LCL auto-sizing algorithms as the default size. Only positive values are valid. Negative or 0 (Zero) values are treated as undefined, and the LCL uses other values to perform auto-sizing.

TWinControl overrides this:

For example the preferred size of a TButton is the size, where the label fits exactly. This relies on the current theme and widgetset.

This value is independent of constraints and siblings, only the inner parts are relevant for the calculates values.

WithThemeSpace adds space for stacking when set to True. For example: TRadioButton has a minimum size. But for stacking multiple TRadioButtons there should be space around each control. This space is theme- dependent, so it is passed as a parameter to the widgetset.

See also



Override this method to return the preferred height and width for the control.

CT Web help

CodeTyphon Studio