void CMainFrame::OnNcPaint()
{
// TODO: 在此处添加消息处理程序代码
// 不为绘图消息调用
CFrameWnd::OnNcPaint();
myDrawCaption(this);
}
//得分榜
void CMainFrame::myDrawCaption(CWnd* pWnd)
{
CDC* pWinDC = pWnd->GetWindowDC();
CRect rtWnd, rtTitle, rtScore;
pWnd->GetWindowRect(&rtWnd);
//标题栏大小
rtTitle.left = GetSystemMetrics(SM_CXFRAME);
rtTitle.top = GetSystemMetrics(SM_CYFRAME);
rtTitle.right = rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME);
rtTitle.bottom = rtTitle.top + GetSystemMetrics(SM_CYSIZE) ;
//得分栏大小
rtScore.left = rtTitle.right - 75;
rtScore.top = rtTitle.top + GetSystemMetrics(SM_CYCAPTION)+4;
rtScore.right = rtTitle.right - 4;
rtScore.bottom = rtTitle.bottom + GetSystemMetrics(SM_CYCAPTION);
//写入得分
CString strScore ;
CFreecellView* pwt = (CFreecellView*)GetActiveView();
int j = pwt->FreecellGame->m_RestNum;
if (j<1 || j>52)
j = 0;
strScore.Format("剩余纸牌:%#2d", j);
CFont fntZdy, *pfntOld;
VERIFY(fntZdy.CreatePointFont(100, "宋体", pWinDC));
pfntOld = pWinDC->SelectObject(&fntZdy);
pWinDC->DrawText(strScore, &rtScore, DT_CENTER);
pWinDC->SelectObject(pfntOld);
fntZdy.DeleteObject();
}
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
myDrawCaption(this);
}