Getting the Device Context

I’m trying to create an opengl window with mfc. When I write “GetDC(hWnd)” in Oncreate, the compiler says “function does not take 1 parameters.” Can anybody tell me what I might have done wrong?

I presume this comes from a CWindow or derivative…

In the MSDN docs it says this…

HDC GetDC(HWND)

and in the class CWindow

HDC GetDC()

you are calling the latter in your class, which is fine omit the parameter unless the hwnd is not the CWindow. In that case call

::GetDC(HWND) (notice particularly the “::”) to get to global scope

There’s also

CDC* CWnd::GetDC();

In that case if you want an HDC for that particular window, you can do something like this…

HDC hDC = GetDC()->GetSafeHdc();