DT_WORDBREAK and DT_VCENTER don’t work together. So here is an alternative:
void CEMCHotButton::DrawCaption (CDC* pDC, LPDRAWITEMSTRUCT
lpDrawItemStruct,
{
// Get caption text
CString strCaption;
GetWindowText (strCaption);
if(!strCaption.IsEmpty())
{
if((GetStyle() & BS_MULTILINE) == BS_MULTILINE)
{
dwFormat &= ~DT_SINGLELINE;
dwFormat &= ~DT_VCENTER;
dwFormat |= DT_WORDBREAK;
RECT rct = rectCaption;
int height = ::DrawText(pDC->m_hDC, (LPCTSTR) strCaption, strCaption.GetLength(), &rct, DT_CALCRECT | DT_WORDBREAK);
rectCaption.top = rectCaption.CenterPoint().y - height / 2;
::DrawTextEx (pDC->m_hDC, strCaption.GetBuffer(0),
strCaption.GetLength(), &rectCaption,
dwFormat, NULL);
}
}
