描述:
我使用MFC 生成一个ActiveX工程,在OnDraw中添加画图片的代码,
bitmap.LoadBitmap(strUpPicName);使用路径则不可以,而使用
bitmap.LoadBitmap(IDB_BITMAP1);//使用ID则可以
请高手指教,谢谢
代码如下:
CBitmap *pOldBitmap;
CBitmap bitmap;
CRect rect;
GetClientRect(rect);
CDC ppdc;
ppdc.CreateCompatibleDC(pdc);
//使用图片
strUpPicName = _T( "D:\\1.bmp");
if ( m_strUpPicName != "" )
{
bitmap.LoadBitmap(strUpPicName);//使用路径则不可以
//bitmap.LoadBitmap(IDB_BITMAP1);//使用ID则可以
pOldBitmap=ppdc.SelectObject(&bitmap);
pdc->BitBlt(0,0,rect.Width(),rect.Height(),&ppdc,0,0,SRCCOPY);
ppdc.SelectObject(pOldBitmap);
}
解决方案1:
图片已经导入工程了,就用ID了
解决方案2: 是这样的!
LoadImage
The LoadImage function loads an icon, cursor, or bitmap.
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
);
使用见:
http://www.vckbase.com/document/viewdoc/?id=698