CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Posts
    231

    ChoosePixelFormat NULL handle?

    Code:
    PIXELFORMATDESCRIPTOR pfd = {
    		sizeof (PIXELFORMATDESCRIPTOR),             // Size of this structure
    		1,                                          // Version number
    		PFD_DRAW_TO_WINDOW |                        // Flags
    		PFD_SUPPORT_OPENGL,
    		PFD_TYPE_RGBA,                              
    		24,                                         // 24-bit color
    		0, 0, 0, 0, 0, 0,                           // Don't care about these
    		0, 0,                                       // Alpha buffer
    		0, 0, 0, 0, 0,                              // No accumulation buffer
    		32,                                         // 32-bit depth buffer
    		0,                                          // No Stencil buffer
    		0,                                          // No auxiliary buffers
    		PFD_MAIN_PLANE,                             // Layer type
    		0,                                          // Reserved (must be 0)
    		0, 0, 0                                     // No layer masks
    	};
    	
    if( m_hdc != NULL )
    {
    	int pixelFormat = ChoosePixelFormat(m_hdc, &pfd);
    }
    When calling ChoosePixelFormat I get this warning:

    "VERIFIER STOP 00000303: pid 0x1994: NULL handle passed as parameter. A valid handle must be used."

    The function succeeds, but why this complaint about NULL handle?

  2. #2
    Join Date
    May 2007
    Posts
    811

    Re: ChoosePixelFormat NULL handle?

    Have you checked in the debugger that m_hdc variable is a valid handle and not NULL?

  3. #3
    Join Date
    Aug 2006
    Posts
    231

    Re: ChoosePixelFormat NULL handle?

    It's not NULL. The device context is retrieved from a window and should be valid. I can use the handle later with DrawText and see the results. ChoosePixelFormat returns a non-zero value, so everything seems fine except this annoying warning that AppVerifier shows every time. I don't understand why...!?

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ChoosePixelFormat NULL handle?

    Quote Originally Posted by TubularX View Post
    It's not NULL. The device context is retrieved from a window and should be valid. I can use the handle later with DrawText and see the results. ChoosePixelFormat returns a non-zero value, so everything seems fine except this annoying warning that AppVerifier shows every time. I don't understand why...!?
    Please realize that any function that requires a device context such as ChoosePixelFormat will at some point get to the device's own internal functions. The issue is probably not your call to the function, but an internal call from the driver that is misbehaving.

    If you ran your program on different video hardware (if it is video), it won't be surprising to see the program work correctly. So you need to investigate what device the m_hdc represents and inspect whether there is an issue with the driver for the device with respect to ChoosePixelFormat.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; August 11th, 2012 at 06:39 AM.

  5. #5
    Join Date
    Aug 2006
    Posts
    231

    Re: ChoosePixelFormat NULL handle?

    OK, that makes sense. Thank you! I will investigate and debug on some other hardware as well.

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: ChoosePixelFormat NULL handle?

    Quote Originally Posted by TubularX View Post
    OK, that makes sense. Thank you! I will investigate and debug on some other hardware as well.
    Does the program work, even if you get the AppVerifier warning? If so, then more than likely your driver has not been run through AppVerifier or similar program by the manufacturer. Not surprising, as many third-party commercial libraries are not thoroughly put through this type of testing.

    Regards,

    Paul McKenzie

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured