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?
Re: ChoosePixelFormat NULL handle?
Have you checked in the debugger that m_hdc variable is a valid handle and not NULL?
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...!?
Re: ChoosePixelFormat NULL handle?
Quote:
Originally Posted by
TubularX
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
Re: ChoosePixelFormat NULL handle?
OK, that makes sense. Thank you! I will investigate and debug on some other hardware as well.
Re: ChoosePixelFormat NULL handle?
Quote:
Originally Posted by
TubularX
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