问题
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