0

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!

3
  • 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. Nov 27, 2013 at 1:24
  • 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 Nov 27, 2013 at 7:26
  • @Servé CPaintDC is a convenience, not a necessity. No application is ever required to instantiate a CPaintDC. Nov 27, 2013 at 16:30

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.