How to handle WM_DISPLAYCHANGE?

Ok, my OpenGL app starts up and runs fine in either 16 or 32 bpp modes. But when the display mode is switched, say colordepth changed from 16 to 32 bpp or vice versa, my app loses the rendering context and ends up drawing nothing. Ok, so I figure just destroy the old rendering context and reinitialize the graphics pipeline. Problem is when I attempt to set the pixel format, it fails saying the format is invalid, even though according to ChoosePixelFormat (thats what gave me the pixel format) its valid.
I’m at my wits end here, is there some trick to setting the pixel format a second time?

Well I know this may sound really obvious but make sure you do a wglMakeCurrent(NULL,NULL) or whatever it is, in different places of the code and see if it works.

That is how I fixed one of my problems a few months back. I was actually doing that command in the wrong place

Nope, thats not it. That is the first thing I do after detecting the message. Thanks though.

You can only call SetPixelformat ONCE for the lifetime of a window (see MS help).
If you want to select a new pixelformat for the same window you’ll get this error.
Completely destroy the window and create a new one.

Yes, you are right, I should have read the Remarks for SetPixelFormat. Thanks.