基于单文档应用程序背景的修改

重写虚函数:OnEraseBkgnd(CDC *pDC)

 

BOOL CCodeCaculatorView::OnEraseBkgnd(CDC* pDC)
{
 // TODO: Add your message handler code here and/or call default

 CBitmap bitmap;
 bitmap.LoadBitmapW(IDB_BLACK);//加载位图
 BITMAP bmp;
 bitmap.GetBitmap(&bmp);

 CDC dcComptiable;
 dcComptiable.CreateCompatibleDC(pDC);
 dcComptiable.SelectObject(&bitmap);//选入设备描述表

 CRect rect;
 GetClientRect(&rect);//获得当前窗口的大小
 pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcComptiable, 0,0,
  bmp.bmWidth, bmp.bmHeight, SRCCOPY);//根据窗口大小调整位图
 return true; //返回真s
/*CView::OnEraseBkgnd(pDC);*/
}

你可能感兴趣的:(文档)