Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TextOut problem

Posted on 2001-07-04
4
Medium Priority
?
1,002 Views
Last Modified: 2013-11-20
DC.TextOut(
GridRect.left,
GridRect.top + 18,
"Hello\nWorld"
)

I wanna make a TextOut on my screen, but it will only print "Hello#World"

and I can't get the newline to work in the TextOut() function. I want to make use of the \n feature in CString, does I have to use another function to do so, or how can I solve my problem so I can make a print like this

Hello
World ?

CB.
0
Comment
Question by:win32
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6252844
See:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnprogwin/html/ch17-01.asp

for a good tutorial on how to do text.  But the bottom line is that TextOut does not understand the newline (\n) character.  Use DrawText instead as it's a higher-level text output function that has greater capabilities.
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 200 total points
ID: 6252952
use DrawText insatead of TextOut:

GetDC()->DrawText("hello\nWorld",CRect(100,100,150,200),0);

good luck
0
 
LVL 86

Expert Comment

by:jkr
ID: 6253457
You'll have to use "\r\n" to issue a line break, e.g.

DC.TextOut(
GridRect.left,
GridRect.top + 18,
"Hello\r\nWorld"
);
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 6253811
One very rarely needs to use TextOut when working with MFC.  

Unless you are writing the low-level guts of a special control, you are much better off creating an Edit Control  or a Static Control and just using SetWindowText().

-- Dan
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question