Delphi7 Canvas.TextOut无法写新行 [英] Delphi7 Canvas.TextOut can't write new lines

查看:165
本文介绍了Delphi7 Canvas.TextOut无法写新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用新行替换所有#"以绘制:

I am trying to replace all "#" with new lines to draw:

Canvas.TextOut(0,0,''+StringReplace('a#b','#',#13#10,[rfReplaceAll]));

但是什么也没有.
TextOut打印"a#b",就像被替换的部分甚至不存在一样(但是它确实存在):ab
代替这个:

but nothing.
TextOut prints "a#b" like the the replaced part doesn't even exist (But it does exist ofcourse): ab
Instead of this:

a
b

#13#10是换行符(Windows)吗?
那为什么这不起作用呢?

#13#10 is the new line (Windows) right?
Then why this isn't working?

谢谢.

推荐答案

您需要使用DrawText生成多行文本:

You need to use DrawText to produce multi-line text:

var
  R: TRect;
....
R := Rect(0, 0, Width, Height);
DrawText(
  Canvas.Handle,
  PChar(StringReplace('a#b','#',#13#10,[rfReplaceAll])),
  -1,
  R,
  0
);

您可能非常想在最终参数中使用不同的标志,但是我敢肯定您可以阅读

You may very well want to use different flags in the final parameter, but I'm sure you can read the documentation and work out what you need.

这篇关于Delphi7 Canvas.TextOut无法写新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆