views:

237

answers:

1

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

thanks!

+7  A: 

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.

Vegar
+1 for suggesting using a label. Just drop it inside the TPanel (if you want the borders) and set the anchors.
Bruce McGee
+1 for showing that many questions can be answered easily by just having a quick look at the VCL source code.
mghie
yeap. I am going to use a label.thanks for the help!
wonderer