Mega Code Archive

 
Categories / Delphi / VCL
 

Prevent labels from being cut

Title: Prevent labels from being cut Question: When switching between small fonts and large fonts, the AutoSize property of TLabel components does not work properly. As work-around, call the following procedure within the form's OnCreate event: Answer: procedure LabelsAutoSizeCorrect (Form: TForm); var i: integer; Component: TComponent; begin for i := 0 to Form.ComponentCount - 1 do begin Component := Form.Components [i]; if (Component is TLabel) and TLabel (Component).AutoSize then begin TLabel (Component).AutoSize := false; TLabel (Component).AutoSize := true; end; end; end;