Trying to terminate the text drawn by drawText(Win32) if there is not enough height in the rect

StackOverflow https://stackoverflow.com/questions/10348344

سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top