Solved

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

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

840 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