Solved

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

Posted on 1998-10-10
1
2,006 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

23 Experts available now in Live!

Get 1:1 Help Now