Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Print Newlines

Status
Not open for further replies.

jdogg1

Technical User
Nov 18, 2001
8
0
0
US
Hi,

Please help me. I figured out how to print but whenever a newline character is supposed to print, it prints two square boxes. How would I go about fixing that?

Thanks
 
I presume you're using TextOut()?

You could use DrawText() instead, which is much more powerful but much less efficient.

You could also process the string yourself. When you encounter a newline, print only up to one less than the newline, then reset your pointer to AFTER the newline, move your X-coord variable back to 0, add the line height to your Y-coord variable, then search again for a newline or a terminating null.

To get the line height, use the GetTextMetrics() API. Add the tmHeight and tmExternalLeading returned by GetTextMetrics together to get the line height.

Or like I said you could just use DrawText... "Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
In some text editors '\n' is processed as a new line, but notepad needs the "\r\n" sequence to start a new line.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top