Solved

TextOut problem

Posted on 2001-07-04
4
993 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
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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CRON statement to run every 3 minutes except on Monday morning 12am to 2am 7 94
sumDigits challenge 9 150
notReplace  challenge 53 128
How to convert MFC::CString to UTF8 wchar_t* 10 210
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli‚Ķ
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 Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

777 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