Problem with displaying text using DrawText
Maria
21
Reputation points
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.
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);
Sign in to answer