MFC位图的显示分为4步:
1)创建位图,可以用CBitmap构造位图对象;
2)创建兼容DC,可以用CreateCompatibleDC;
3)将位图设置到兼容DC;
4)将该兼容DC显示到当前DC;
void DrawBitmap(int iBitmapID)
{
CBitmap bitmap;
bitmap.LoadBitmap(iBitmapID);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
CDC dcCompatible;
CDC *pDC = GetDC();
dcCompatible.CreateCompatibleDC(&pDC);
dcCompatible.SelectObject(&bitmap);
CRect rect;
GetClientRect(&rect);
pDC->StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
}