Solved

TextOut problem

Posted on 2001-07-04
4
987 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
4 Comments
 
LVL 32

Expert Comment

by:jhance
Comment Utility
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
Comment Utility
use DrawText insatead of TextOut:

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

good luck
0
 
LVL 86

Expert Comment

by:jkr
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This video discusses moving either the default database or any database to a new volume.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now