'The parameter is incorrect' - LoadImage

This is a discussion on 'The parameter is incorrect' - LoadImage within the Windows Programming forums, part of the Platform Specific Boards category; I'm working on a DirectX-based project, and I am having problems with my graphics code. The code works fine on ...

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    2

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

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

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21