示例:
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
王海光 閱讀(2919)
評論(0) 編輯 收藏 引用