简体   繁体   中英

DrawText VS TextOut Win32

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?

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

DrawText() is User32.dll

TextOut() is Gdi32.dll

DrawText is most likely calls TextOut in its implementation.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM