in MDI in MDI how do I get correct DC

m_hgldc = ::GetDC(m_hWnd);
if(!SetPixelformat(m_hgldc)) // set pixel format
::MessageBox(::GetFocus(),“SetPixelformat Failed!”,“Error”,MB_OK);


When I try to OpenGL SwapBackBuffer the whole screen goes black, this code works with one window. But not MDI. Can someone help me, much thanks and God bless ya.

Oh and its in MFC.

Do you have that code in the CView derived classes?

Also, be sure and use wglMakeCurrent when you redraw the scenes for each CView.

Also, you should make sure that in the PreCreateWindow, you create a new window class to use which has the CS_OWNDC flag set.