Have you checked in the debugger that m_hdc variable is a valid handle and not NULL?