Controls.TControl.CanAutoSize

From RAD Studio VCL Reference
Jump to: navigation, search

Contents

Delphi Information

From Controls.pas

	function CanAutoSize(var NewWidth: Integer; var NewHeight: Integer): Boolean; virtual;


Unit: Controls

Type: method

Visibility: protected

Member Of: TControl

C++ Information

From Controls.hpp

	virtual bool __fastcall CanAutoSize(int & NewWidth, int & NewHeight);


Unit: Controls

Type: method

Visibility: protected

Member Of: TControl

Description

Indicates whether the control can resize itself automatically to accommodate its contents.


CanAutoSize is called automatically when the AutoSize property is true and an attempt is made to resize the control. It allows controls to implement the AutoSize property before the resize sequence that begins with the OnCanResize and OnConstrainedResize events and ends with the OnResize event.

When CanAutoSize is called, the NewWidth and NewHeight parameters indicate the proposed new dimensions of the control. CanAutoSize adjusts these values so that the control's size adjusts to its contents. If the adjustment results in values of NewWidth and NewHeight that differ from the control's current width and height, CanAutoSize returns true, indicating that the resize sequence should proceed. If, after adjustment, NewWidth and NewHeight equal Width and Height, CanAutoSize returns false, and the resize sequence is aborted.

As implemented in TControl, CanAutoSize always returns true without changing NewWidth or NewHeight. Override CanAutoSize to implement the AutoSize property for a particular control class's contents.

See Also

Personal tools
Translations
Newest Version