I'm pretty new to Windows programming and have been following theForger's Win32 API Programming Tutorial. I've been trying to draw an image inside a window.
Having looked at similar problems, this code seems to be correct for loading a bitmap:
HBITMAP testImage == NULL;
case WM_CREATE:
testImage = (HBITMAP)LoadImage(NULL, L"C:\\ScreenSnip.bmp", IMAGE_BITMAP, 498, 304, LR_LOADFROMFILE);
if(testImage == NULL) {
MessageBox(NULL, L"NO IMAGE LOADED!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
}
break;
I have an image called ScreenSnip.bmp at the location above, and its dimensions are 498*304. However, LoadImage doesn't work and the value of testImage is always null.
I have tried loading an image as a resource using LoadBitmap() and that works, which is why I haven't included the rest of my code. It seems to be LoadImage() above that's causing the problem, but I can't figure out why.
Anyone have any ideas? I'm running this using VC++ on Windows 7 64bit.