unit AutoSize;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, 
  Controls, Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: AutoSize
// Property: StdCtrls.TCustomLabel.AutoSize
// Property: Controls.TControl.Caption

// BeginCode
{
The following code keeps the size of the label control 
constant, even though the length of the label’s caption 
changes. As a result, the caption of the label is probably 
too long to display in the label when the user clicks the 
button:
} 
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.AutoSize := False;
  Label1.Caption := 
    'This string is too long to be the caption of this label';
end;
// EndCode
// EndExample: AutoSize
end.
