Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make a Delphi TPanel caption wrap

Is there a way to wrap the text in a TPanel.Caption in Delphi (in my case Delphi 6)?

like image 739
wonderer Avatar asked Aug 13 '09 20:08

wonderer


1 Answers

Not by default, I'm afraid. As you can see from the sourcecode for TPanel, the text is drawn by the DrawText( )-windows API:

procedure TCustomPanel.Paint;
{snip}
begin
  {snip}
  Flags := DT_EXPANDTABS or DT_SINGLELINE or
    VerticalAlignments[FVerticalAlignment] or Alignments[FAlignment];
  Flags := DrawTextBiDiModeFlags(Flags);
  DrawText(Handle, PChar(Caption), -1, Rect, Flags);
end;

You can either derive and override the Paint-method, or you could just use a label instead.

like image 87
Vegar Avatar answered Sep 22 '22 06:09

Vegar