示例:
CRect rc = CRect(0,0,0,0);
m_staticTime.GetClientRect(&rc);
CDC* pDC = m_staticTime.GetDC();
TEXTMETRIC tm;
pDC->GetTextMetrics(&tm);
int nFontHeight = tm.tmHeight + tm.tmExternalLeading;
int nTopBottom = (rc.Height() - nFontHeight) / 2;
int nLeftRight = (rc.Width() - nFontHeight) / 2;
rc.DeflateRect(nLeftRight, nTopBottom);
m_staticTime.SetRectNP(&rc);
m_staticTime.SetWindowText("45");
ReleaseDC(pDC);
posted on 2013-09-04 16:14
王海光 阅读(2776)
评论(0) 编辑 收藏 引用