?
Solved

TextOut problem

Posted on 2001-07-04
4
Medium Priority
?
1,000 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 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

770 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