可以用函数 HANDLE LoadImage( HINSTANCE hinst, // handle of the instance containing the image LPCTSTR lpszName, // name or identifier of image UINT uType, // type of image int cxDesired, // desired width int cyDesired, // desired height UINT fuLoad // load flags ); 例子: HBITMAP bitmap; bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(), filename,IMAGE_BITMAP, m_rectDst.right-m_rectDst.left,m_rectDst.bottom-m_rectDst.top, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
使用到那些对象和方法?
GDI函数
HBITMAP LoadBitmap(
HINSTANCE hInstance, // handle to application instance
LPCTSTR lpBitmapName // address of bitmap resource name
);
等。
CRect rect;
GetClientRect(&rect);//得到窗体的大小
CDC dcMem;
dcMem.CreateCompatibleDC(&dc);
CBitmap bmpBackground;
bmpBackground.LoadBitmap(IDB_BITMAPBACKGROUND);//加载背景图片
BITMAP bitMap;
bmpBackground.GetBitmap(&bitMap);
CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);//画窗体如果相同大小可用BitBlt
HANDLE LoadImage(
HINSTANCE hinst, // handle of the instance containing the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);
例子:
HBITMAP bitmap;
bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),
filename,IMAGE_BITMAP,
m_rectDst.right-m_rectDst.left,m_rectDst.bottom-m_rectDst.top,
LR_LOADFROMFILE|LR_CREATEDIBSECTION);