Canvas的TextOut如何自动换行 ( 积分: 50 )

  • 主题发起人 主题发起人 catcatdogdog
  • 开始时间 开始时间
C

catcatdogdog

Unregistered / Unconfirmed
GUEST, unregistred user!
在Canvas中TextOut时,如果Text很长,需要自动换行。如何能实现?
 
在Canvas中TextOut时,如果Text很长,需要自动换行。如何能实现?
 
自己用程序判断
Canvas.TextWidth(str)
 
可以直接使用DrawText:
procedure TForm1.Button1Click(Sender: TObject);
const
Str = 'DrawText(Canvas.Handle, PChar(Text), Length(Text), Rect, Flags);This is a test This is a test This is a test This is a test This is a test This is a test ';
var
R: TRect;
begin
R.Left := 0;
R.Top := 0;
R.Right := Width;
R.Bottom := Height;
DrawText(Canvas.Handle, Str, Length(Str), R, DT_WORDBREAK);
end;
 
接受答案了.
 
后退
顶部