Losing Windows DC ?

I posted this a while ago … never got a solution to it …

After running my OpenGL application, I sometimes find that following a timeout on the power management monitor the screen is either corrupted or more often just a plain cyan color. I’ve found that other OpenGL apps do the same but not all of them. It looks as though Windows is being assigned an incorrect DC after the monitor is restored after the power down … obviously my fault !

Anyway, here’s the code that I’m using to close the OpenGL application … as I said, it all works fine … unless the power management kicks in !


procedure FinalizeOpenGL;
wglMakeCurrent(fGLDC, 0);
ReleaseDC(fWindow, fGLDC);
if (fPalette <> 0) then
end; {FinalizeOpenGL}

I really would be grateful if anyone could shed some light on what I’m doing … or not doing !



If i were you I would search the msdn (http://msdn.microsoft.com)

search for “power management” + “screen coruption”

I think that every window gets a message (in windows anyway) when power managment is about to kick in, and you just return a value to prevent that from happening.


Power management does not shut down your application, so I don’t see why you’re posting that code.

Look for PBT_APMSUSPEND and friends on MSDN to figure out how to handle power status changes, if you want to nicely suspend your app.

Sorry for not making the problem 100% clear. Power management kicking is fine … no problems at all … that is until I’ve run my OpenGL application and then terminated it. Then everything’s OK until power management kicks in and upon restoring I then get this cyan screen.