DrawText VS TextOut Win32

这一生的挚爱 提交于 2019-12-05 14:05:30

问题


I find have used both these functions before, but I don't quite see the the difference between them. Well, I know that DrawText requires a formatting rectangle,and can do some text formatting, and textout only the starting coordinates, are there any other differences?


回答1:


DrawText

  • It draws a text string into a rectangle region specified in logical coordinates.
  • It provides convenient ways of formatting multiline text.
  • It is mainly used for wordbreaking paragraph formatting, expanding tabs etc.

TextOut

  • It is a simple text-drawing function which is easy to use.
  • It draws a character string at a specified location, using the currently selected text attributes.
  • The text string to draw does not need to be zero terminated.

Also, take a look at ExTextOut and DrawTextEx




回答2:


DrawText() is User32.dll

TextOut() is Gdi32.dll

DrawText is most likely calls TextOut in its implementation.




回答3:


Draw text can be used to just give the length or size of text without actually displaying it. This is useful when you have to fine the maximum display length of a set of strings. Also if you supply a null terminated string as the input in DrawText, it is not necessary to supply the length of the string - that is automatically created.

Take a look at this and this.



来源:https://stackoverflow.com/questions/8090148/drawtext-vs-textout-win32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!