Solved

Can not get CDC::TextOut() to draw multi-line

Posted on 1998-10-10
1
2,031 Views
Last Modified: 2013-11-20
I am using CDC::TextOut successfully to draw text to the screen but I can not seem to get it to draw in word-wrap mode.

Every time I try to use ExtTextOut or DrawText it always draws blank.

Any thoughts as to how to or whether this can be achieved?
0
Comment
Question by:rascal
1 Comment
 
LVL 8

Accepted Solution

by:
Answers2000 earned 100 total points
ID: 1323171
TextOut doesn't do  word breaks

pDC->DrawText( strText, &rectTextBody, DT_NOPREFIX | DT_LEFT | DT_TOP | DT_WORDBREAK ) ;

where rectTextBody is the rectangle
strText is the text, lines separated with CR/LF pair e.g. "Hello\r\nWorld"

DT_NOPREFIX is optional, but means & are displayed as &, rather than underlining the next char

If you are still getting blank, check the color of the text is different from the background - before calling DrawText

pDC->SetText( RGB(0,0,0) ) ; // black text
pDC->SetBkColor( RGB(255,255,255) ) ; // white background

The background for the text is either filled in with the background color (OPAQUE mode)or left as it is (TRANSPARENT mode) - again set this before calling DrawText

pDC->SetBkMode( TRANSPARENT ) ; // transparent background#
or
pDC->SetBkMode( OPAQUE) ; // opaque background

Make sure the rectangle you use in DrawText is big enough


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

785 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