此方法需要加入静态库Msimg32.lib 。
1.建立bitmap资源
2.增加CBitmap对象在类中
3.在对话框OnPaint()中
CDC ImageDC;
bmpSoftVer.LoadBitmap(IDB_CN_ABOUT);
BITMAP bm;
bmpSoftVer.GetBitmap(&bm);
iSoftVerWidth = bm.bmWidth;
iSoftVerHeight = bm.bmHeight;
ImageDC.CreateCompatibleDC(&dc);
CBitmap *pOldImageBMP = ImageDC.SelectObject(&bmpSoftVer);
dc.BitBlt(0, 0, m_iSoftVerWidth, m_iSoftVerHeight, &ImageDC, 0, 0, SRCCOPY);
COLORREF crMask = RGB(0xFF, 0xFF, 0xFF); //此处颜色为背景颜色的反色
bmpBeyondLogo.LoadBitmap(IDB_CN_BEYOND);
bmpBeyondLogo.GetBitmap(&bm);
iBeyondLogoWidth= bm.bmWidth;
iBeyondLogoHeight= bm.bmHeight;
ImageDC.SelectObject(&bmpBeyondLogo);
TransparentBlt(dc.m_hDC, 40, 230, iBeyondLogoWidth,iBeyondLogoHeight, ImageDC.m_hDC, 0, 0, iBeyondLogoWidth, iBeyondLogoHeight,crMask); ImageDC.SelectObject(pOldImageBMP);