La afirmación falla con GetDC () (usando mfc)

So, I keep getting an assertion fail:

_AFXWIN_INLINE CDC* CWnd::GetDC()
    { ASSERT(::IsWindow(m_hWnd)); return CDC::FromHandle(::GetDC(m_hWnd)); }

And I checked the call stack and the method called before the method above is:

CDC *pDC = GetDC();

I'm not sure what is wrong with any of this, but I would like some help. Thanks!

preguntado el 27 de noviembre de 13 a las 01:11

Can you post a little more context? Looks like m_hWnd is bad but without seeing how it was created and such it's just a guess. -

its been a while but if I remember correctly, if you are getting the DC in OnPaint you need to create a CPaintDC. But more context is needed on when you are calling GetDC -

@Servé CPaintDC is a convenience, not a necessity. No application is ever required to instantiate a CPaintDC. -

1 Respuestas

If you get this Assertion you use the CWNd::GetDC function without having a created window. Or the window is already destroyed.

respondido 27 nov., 13:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.