目前正在使用canvas.textout在TGraphicControl组件中显示一些文本,但我需要将文本保留在某个区域内。有什么像单词包装之类的东西我可以用..。还是设置textout区域的方法?就像这样
var
r: TRect
s: string
begin
s := 'some long text that takes up about 3-4 lines';
r.Left := 10;
r.Top := 10;
r.Right := 20;
r.bottom := 50;
textout(r,s);
end;发布于 2013-10-19 10:36:56
您可以为此使用DrawText函数:
procedure TForm1.FormPaint(Sender: TObject);
const
S = 'This is some sample text. It is very long. Very long, indeed.' +
'Very, very, long.';
var
R: TRect;
begin
R := Rect(100, 100, 200, 200);
DrawText(Canvas.Handle, S, length(S), R, DT_WORDBREAK);
end;https://stackoverflow.com/questions/19465069
复制相似问题