Thread: 'The parameter is incorrect' - LoadImage

  1. #1
    Registered User
    Join Date
    Feb 2002

    'The parameter is incorrect' - LoadImage

    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).

        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");
            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..

  2. #2
    Join Date
    Jan 2002
    No idea but at a very wild and bad guess - are you compiling with UNICODE #defined in win2k?

    You could always try using the older obsolete LoadBitmap and see whether it replicates your error ( at least that will confirm if it's LoadImage that's responsible).

    Sorry for bad guesses....good luck anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. my error is storage class specified for parameter
    By meli in forum C Programming
    Replies: 5
    Last Post: 03-27-2009, 12:06 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. cannot start a parameter declaration
    By Dark Nemesis in forum C++ Programming
    Replies: 6
    Last Post: 09-23-2005, 02:09 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM