I'm working on a DirectX-based project, and I am having problems with my graphics code. The code works fine on my development system (Win2k), and when I run the EXE from outside my IDE (VC++ 6) it works fine also. But when I tried to run it from my other machine (W98SE), the program just boots back to the desktop.
When I am loading the BMP's for my level, at around the 400th tile (some random position), the function fails. I logged the following error message which appears after my LoadImage call: 'The parameter is incorrect'. There is no documentation entailing the specifics of this error.
I really can't understand what the error is. I have passed all non-local variables by reference. A memory problem?
Any help is *greatly* appreciated .
Where it says 'error handling' I jump out of the program and log the error (I've omitted the code to save some space).
Code:
HBITMAP hBmp; // A bitmap handle
BITMAP bmp; // A bitmap structure
HDC hSourceDC; // The source device context
extern HDC hDC; // Our window's device context
extern HINSTANCE hinstance; // Our window's instance handle
// Here's the line that fails
// Load the image into the bitmap handle
if ( (hBmp = (HBITMAP)LoadImage(hinstance, cFilePath,
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE |
LR_CREATEDIBSECTION)) == NULL)
{
LogErrorMsg("Unable to load image into DIB section");
LogInfo(cFilePath);
return (1);
}
// Make the source DC represent the whole screen
if (!(hSourceDC = CreateCompatibleDC(NULL)))
// Error handling..
// Blitting - omitted
// Now comes the housekeeping, we must free all memory
// Deletes the bitmap handle
if (!(DeleteObject(hBmp)))
// Error handling..
// Releases our device context from the main window
if (FAILED(lpddSurface->ReleaseDC (hDC)))
// Error handling..
// Deletes the source DC as we do not need it anymore
if (!(DeleteDC(hSourceDC)))
// Error handling..
return(0);