Friday, January 21, 2011

Prevent labels from being cut

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:

procedure LabelsAutoSizeCorrect (Form: TForm);
var i: integer;
    Component: TComponent;
  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;

Twitter Delicious Facebook Digg Stumbleupon Favorites More

Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum