Problem with displaying text using DrawText

Maria 21 Reputation points
2023-05-05T08:55:27.0466667+00:00

In my MDI application I use CDC::DrawText to draw ordinary and multiline text. Most of the time it works well, but for some documents text disapeare (look at pictures). Did anyone face the same? Unfortunately, I have no idea, how to solve it.

User's image

User's image


CString m_str = _T("MULTILINE TEXT");
CRect rcCalc = rcText;
int nHight = pDC->DrawText(m_str, &rcCalc, DT_CENTER | DT_CALCRECT | DT_WORDBREAK);
rcText.top += (rcText.Height() - nHight) / 2;
rcText.bottom = rcText.top + nHight;
pDC->Rectangle(rcCalc);
pDC->DrawText(m_str, &rcText, DT_CENTER | DT_WORDBREAK );

CString m_str = _T("TEXT");
UINT nFormat = DT_CENTER|DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX;
CSize size = pDC->GetOutputTextExtent(m_str);
if ( size.cx >= rcText.Width())
		nFormat |= DT_END_ELLIPSIS;

pDC->DrawText(m_str, &rcText, nFormat);

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,636 questions
{count} votes