If the operation is completing successfully then you are loading a valid bitmap. I'd be tempted to look to variable declaration/naming - with some fonts hndl and hnd1 are indistinguishable to the eye. Do you have any other similar and compatible type variable declarations in the same scope as this bitmap handle?
Perhaps it would be prudent at this point to post a complete, minimal compilable example that replicates the problem so that we can better help you?
edit:
Try this and see if this helps. It should open a selected bitmap from file and briefly display it in a static control.
Code:
#include <windows.h>
#include <tchar.h>
int WINAPI WinMain(HINSTANCE hInst,HINSTANCE hPrev,PSTR pStr,int nCmd)
{
OPENFILENAME ofn;
TCHAR szFile[MAX_PATH]=_T("");
ZeroMemory(&ofn,sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.lpstrTitle = _T("Open bitmap...");
ofn.lpstrFile = szFile;
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = _T("Bitmap\0*.bmp\0");
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if(GetOpenFileName(&ofn) == TRUE)
{
HBITMAP hBmp=LoadImage(0,szFile,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
if (hBmp)
{
HWND hStatic=CreateWindowEx(WS_EX_CLIENTEDGE,_T("static"),0,
WS_CHILD|WS_VISIBLE|SS_BITMAP,
0,0,400,400,GetDesktopWindow(),0,hInst,0);
SendMessage(hStatic,STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)hBmp);
Sleep(1000);
}
else
{
TCHAR errbuff[64];
DWORD dw=GetLastError();
wsprintf(errbuff,_T("LoadImage failed with error code: %d"),dw);
MessageBox(0,errbuff,_T("LoadImage Failed"),MB_OK|MB_ICONERROR);
}
}
return 0;
}