Solved

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

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

623 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