Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delphi textrect wordwrap

I am using Canvas.TextRect in Delphi 7 to output something on the screen.

I need my text to be word wrapped in the rectangle.

like image 402
rahim asgari Avatar asked Oct 13 '25 07:10

rahim asgari


2 Answers

You need to use DrawText (or DrawTextEx) with the DT_WORDBREAK flag.

See the sample in this thread.

like image 157
Jeroen Wiert Pluimers Avatar answered Oct 15 '25 15:10

Jeroen Wiert Pluimers


Use

DrawText( hdc, pchar(s), length(s), rcRect, DT_NOPREFIX or DT_WORDBREAK);

where

s : string to print

rcRect : TRect the rect wherein the string should be printed.

like image 31
Аров Марат Avatar answered Oct 15 '25 14:10

Аров Марат