急需vc++“显示资源中的一幅位图”的程序

来源:百度知道 编辑:UC知道 时间:2024/05/12 08:05:35

BOOL CGraphicView::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);

BITMAP bmp;
bitmap.GetBitmap(&bmp);

CDC dcCompatible;
dcCompatible.CreateCompatibleDC(pDC);

dcCompatible.SelectObject(&bitmap);

CRect rect;
GetClientRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,SRCCOPY); //原位图
// pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,
// 0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY); //可对位图进行伸缩
return TRUE;
return CView::OnEraseBkgnd(pDC);
}