Home
What's New
Delphi 3.0 Tips
Questions
Development Tools
Links

Great Solution for Labels that are too long

uses stdctrls;
.
.
.
{if label will run off the edge of its parent, crop label
 will make the label fit on its parent and set the hint to
 it's caption; ShowHint will be true iff label was cropped}
procedure CropLabel (var lab : TLabel);
begin
  with lab do begin
    ShowHint := Left + Width > Parent.Width - 4;
    if not ShowHint then exit;
    Hint := Caption;
  end;
end;