Solved

TextOut problem

Posted on 2001-07-04
4
999 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:
sedgwick earned 50 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

705 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