本段代码在VC6.0中调试通过,希望对大家能有所帮助!
CDC * pDC = GetDC();
HBITMAP bitmap1;
CBitmap itmap;
bitmap1=(HBITMAP)LoadImage(AfxGetInstanceHandle(), "che.bmp ",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); if (bitmap1)
{
//ASSERT(bitmap1);
itmap.Attach(bitmap1);
}
else
{
ReleaseDC(pDC);
//ReleaseDC(&memdc);
return;
}
HBITMAP oldbitmap;
CDC memdc;
CRect rect;
memdc.CreateCompatibleDC(pDC);
//GetClientRect(rect);
oldbitmap=(HBITMAP)memdc.SelectObject(bitmap1);
BITMAP bm;
itmap.GetBitmap(&bm);
//pDC-> BitBlt(0,0,rect.Width(),rect.Height(),&memdc,0,0,SRCCOPY);
pDC-> BitBlt(0,0,bm.bmWidth,bm.bmHeight,&memdc,0,0,SRCCOPY);
memdc.SelectObject(oldbitmap);
ReleaseDC(pDC);
memdc.DeleteDC();//ReleaseDC(&memdc);