请在主窗口框架中加以下代码:
void CMainFrame::AdjustClientArea()
{
// TODO: 在此添加专用代码和/或调用基类
CMDIFrameWndEx::AdjustClientArea();
if (m_wndClientArea.GetSafeHwnd() != NULL)
{
m_wndClientArea.Invalidate();
}
}
BOOL CMainFrame::OnEraseMDIClientBackground(CDC* pDC)
{
if ((m_wndClientArea.GetSafeHwnd() != NULL)&& (pDC->GetSafeHdc()!=NULL))
{
CDC menDc;
HGDIOBJ pObj;
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP2);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
menDc.CreateCompatibleDC(pDC);
pObj = menDc.SelectObject(bitmap);
CRect rect;
m_wndClientArea.GetClientRect(&rect);
pDC->SetStretchBltMode(COLORONCOLOR);
pDC->StretchBlt(0, 0, rect.Width(), rect.Height(), &menDc, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
menDc.SelectObject(pObj);
menDc.DeleteDC();
return TRUE;
}
return FALSE;
}