I'm having issues displaying a bitmap on the screen. When I complile and run its not displaying anything so I tried debugging step by step and found that the below code is the issue.
HBITMAP hbm = (HBITMAP)LoadImage(hInstance,
"C:\\Users\\Jemma\\Desktop\\Maze Game\\Assets\\TILE_01.bmp",
IMAGE_BITMAP,
SWidth, SHeight,
LR_LOADFROMFILE | LR_CREATEDIBSECTION);
if (hbm == NULL || m_Surface == NULL)
{
DWORD lastError = GetLastError();
return 1;
}
When I get to this function under autos first it says hbm=0xcccccccc{unused=???} (I'm assuming it's due to not being initialised as this comes up when I get to the line so I haven't stepped into it at this point - Just thought I'd put it in just incase) after I've stepped into this line it says hbm = NULL, and the GetLastError function returns 0 which I've read means function was successful. I've tried passing NULL instead of hInstance, I've tried passing the filename in as LPCSTR szFileName -- I declared it as LPCSTR szFileName("C:\Users\Jemma\Desktop\Maze Game\Assets\TILE_01.bmp"). Absolutely no idea what to try next. Any help on this would be greatly appreciated.
0xccccccccis the standard value in debug builds for an uninitialized stack variable. Your code looks correct. I even tested it with my own image. WhenLoadImagereturns NULL You need to call GetLastError to get the error code for why it failed. Are you sure that TILE_01.bmp exists and is a real BMP file and not some other format? - selbie