pbsmbc
asked on
dialog caption
Hi,
How do I make a dialog caption in the center of the dialog?
The problem we are having if we manually center the caption of the dialog it works in windows XP however, in NT it's
moving to the right.
Thanks
pbsmbc
How do I make a dialog caption in the center of the dialog?
The problem we are having if we manually center the caption of the dialog it works in windows XP however, in NT it's
moving to the right.
Thanks
pbsmbc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here's a draw text function for drawing centered text within a rect:
void DrawText(CDC* pdc, const CString& strText, CRect& rcRect)
{
CRect rcSavedRect = rcRect;
CRect rcNewRect = rcRect;
CRgn rgn;
rgn.CreateRectRgn(rcRect.l
// Call DrawText with DT_WORDBREAK | DT_CALCRECT flags, this will adjust the rectagle size
// after breaking it into lines but without drawing
pdc->DrawText(strText, &rcSavedRect, DT_WORDBREAK | DT_CALCRECT | DT_CENTER | DT_VCENTER);
// Modify the caption rectagle according to the new coordinates
rcNewRect.top = rcRect.top + (rcRect.Height() - rcSavedRect.Height()) / 2;
rcNewRect.bottom = rcRect.top + rcSavedRect.Height();
HRGN hrgnOld = NULL;
::GetClipRgn(pdc->m_hDC, hrgnOld);
pdc->SelectClipRgn(&rgn, RGN_COPY);
// Draw the caption
pdc->DrawText(strText, &rcNewRect, DT_WORDBREAK | DT_CENTER | DT_VCENTER);
::SelectClipRgn(pdc->m_hDC
DeleteObject(rgn);
}
https://www.experts-exchange.com/questions/21375994/DrawText-DT-CENTER-DT-SINGLELINE-DT-VCENTER.html?query=center+caption&clearTAFilter=true