在VC8中,我用了:USES_CONVERSION;
Bitmap * m_bmpSurface = Bitmap::FromResource( AfxGetApp()->m_hInstance, A2W((LPCSTR)MAKEINTRESOURCE(IDB_BITMAP1)));
//???????????
if(!m_bmpSurface) {
AfxMessageBox(_T("fail to load bitmap"));
return;
}
跟踪程序后;程序进入到函数:
inline LPWSTR WINAPI AtlA2WHelper(__out_ecount(nChars) LPWSTR lpw, __in LPCSTR lpa, __in int nChars, __in UINT acp) throw()
{
ATLASSERT(lpa != NULL);
ATLASSERT(lpw != NULL);
if (lpw == NULL || lpa == NULL)
return NULL;
// verify that no illegal character present
// since lpw was allocated based on the size of lpa
// don't worry about the number of chars
lpw[0] = '\0';
??????????int ret = MultiByteToWideChar(acp, 0, lpa, -1, lpw, nChars);
if(ret == 0)
{
ATLASSERT(FALSE);
return NULL;
}
return lpw;
}
其中:lpa为空,从而产生错误
请教,怎么解决; 谢谢

解决方案 »

  1.   

    又用了
    Bitmap *m_bmpSurface = Bitmap::FromResource( AfxGetApp()->m_hInstance, (WCHAR *)(LPCTSTR)MAKEINTRESOURCE(IDB_BITMAP1));m_bmpSurface 是空的,好象就是找不到这个资源:IDB_BITMAP1谁帮忙解答一下,不胜感激
      

  2.   

    感谢zhejiang9(Why not?) 的回答,实际上已经通过资源管理器,导入了一个图片了,IDB_BITMAP1
      

  3.   


    那就奇怪了
    VC8中MAKEINTRESOURCE返回LPTSTR,所以无须转换!
    Bitmap *m_bmpSurface = Bitmap::FromResource( AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
      

  4.   

    请问一下:
    Bitmap *m_bmpSurface = Bitmap::FromResource( AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
    MSDN中有:
    Res
    This method works only with bitmaps that are named resources in a DLL.有人在VC8 中存取过自己的资源的吗,上面的REMARKS 是什么意思