首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

LoadImage传参有关问题

2012-10-23 
LoadImage传参问题win32应用项目 loadImage函数返回值为空错误Environment://VS2005 + SDK-WINCE5.0m_hBmp

LoadImage传参问题
win32应用项目 loadImage函数返回值为空错误 
Environment:
// VS2005 + SDK-WINCE5.0


  m_hBmpPush1=LoadImage(m_hInst,_T("D:\\testgid\ccc.bmp"),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR);
  if(m_hBmpPush1==NULL)
  {

  DrawText(hdc,_T("加载失败"),-1,&buttonimg1,m_uFormat);  
  }


[解决办法]
GetLastError看看是什么原因
[解决办法]

C/C++ code
        HBITMAP bmp =(HBITMAP)::LoadImage(AfxGetInstanceHandle(),str_path,IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);                if(bmp==NULL)        {            MessageBox("LoadImage Error !");            return FALSE;        }
[解决办法]
Try this 

m_hBmpPush1=LoadImage(NULL,_T("\\StaticStore\\testbutton\\ccc.bmp"),IMAGE_BITMAP,0,0,LR_DEFAULTCOLOR|LR_LOADFROMFILE);

[解决办法]
http://msdn.microsoft.com/en-us/library/ms915412.aspx看看这个
[解决办法]
对了,楼主,你的BMP文件是不是有效的BMP啊?
得是规范的bmp了,别直接修改一个扩展名比如1.png -> 1.bmp就直接拿来用了
[解决办法]
我试了下 的确有些问题 我用VS2008和VC6.0虽然句柄不为0 但还是显示不出来 大家还是试一下 成功了再发代码
这是VS2008的MSDN

hinst
[in] Handle to the module of either a DLL or executable (.exe) that contains the image to be loaded. For more information, see GetModuleHandle. Note that as of 32-bit Microsoft Windows, an instance handle (HINSTANCE), such as the application instance handle exposed by system function call of WinMain, and a module handle (HMODULE) are the same thing. 

To load an OEM image, set this parameter to NULL. 

To load a stand-alone resource (icon, cursor, or bitmap file)—for example, c:\myimage.bmp—set this parameter to NULL.
[解决办法]
是不是写在DLL里面的?

热点排行