C++在窗口上输出文本
简单的问题,从性能角度来看,使用 TextOut 或 DrawText 等函数绘制文本是否比创建静态控件更好?
TextOut 和 DrawText 哪个性能更好?
Simple question, is drawing text using functions like TextOut or DrawText better then creating a static control, performance wise?
And which has better performance TextOut or DrawText?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
先说第二个问题:
DrawText
调用TextOut
,所以如果不需要DrawText
的格式化功能,可以直接进入文本输出
。如果您只关心原始性能,那么直接绘制会更快。然而,原始性能不应该是您唯一关心的问题。它还需要更多工作,并且不支持可访问性(这意味着您必须编写额外的代码来支持
IAccessible
)。Second question first:
DrawText
callsTextOut
, so if you don't need the formatting capabilities ofDrawText
, you can go straight toTextOut
.If raw performance is all you care about, then drawing directly will be faster. However, raw performance should not be your sole concern. It is also more work and does not support accessibility (which means you have to write additional code to support
IAccessible
).DrawText 看起来更强大、更灵活,可能它会做更多的工作。关于 HDC 绘图与静态控制:它们用于不同的目的。例如,最好在对话框中使用静态控件。但如果你想在图表中绘制一些文本 - 动态文本会更好。
DrawText looks more powerful and flexible, possibly it makes more work. Regarding HDC drawing vs. static control: they are used for different purposes. For example, it is better to use static control in a dialog. But if you want to draw some text in a graph - dynamic text is much better.