Question

I am trying to draw a multiline text using drawText. I am able to keep the width constant by passing DT_WORD_ELLIPSIS | DT_WORDBREAK flags but if the string is long the text is getting cut vertically in the last line.

How to ensure that drawText doesn't draw the last line if it it can't fit the whole height ?

Currently I am passing these flags to drawText - DT_NOPREFIX | DT_WORD_ELLIPSIS | DT_LEFT | DT_WORDBREAK | DT_EXTERNALLEADING

Was it helpful?

Solution

Specify the DT_EDITCONTROL flag. According to the MSDN documentation:

DT_EDITCONTROL

Duplicates the text-displaying characteristics of a multiline edit control. Specifically, the average character width is calculated in the same manner as for an edit control, and the function does not display a partially visible last line.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top