在view中添加消息处理函数OnEraseBkgnd()
BOOL CMy123View::OnEraseBkgnd(CDC* pDC)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CBitmap bit;
bit.LoadBitmap(IDB_BITMAP1);
BITMAP bm;
bit.GetBitmap(&bm);
CDC memDc;
memDc.CreateCompatibleDC(pDC);
CBitmap* pOldBitmap = memDc.SelectObject(&bit);
CRect rect;
GetClientRect(&rect);
pDC->SetStretchBltMode(COLORONCOLOR);//这个模式不设置的话会导致图片严重失真
pDC->StretchBlt(0,0,rect.Width() ,rect.Height(),
&memDc,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
memDc.SelectObject(pOldBitmap);
memDc.DeleteDC(); //删除DC
//bm.DeleteObject(); //删除位图
return TRUE;
// return CView::OnEraseBkgnd(pDC);
}