CDC * pDC ??? How do I make a duplicate of it?
Images in MFC are created in the OnDraw function. We have to give "pDC->m_hDC" as the parameter if we want to draw an image...
The problem is that we can get pDC only in our OnDraw function. Now if we want to draw images outside that OnDraw then we need to create a pointer to "CDC" type to get "m_hDC" from it.
Some people said use this code:
CDC * dc = getDC();
But it says getDC() is undefined. What should I do?
The main point is that I want an initialized pointer to CDC in order to use it anywhere.
Outside of the OnDraw function you can create a CDC with
CClientDC dc;
You very rarely need the m_hDC because CDC encapsulates almost all of the drawing functions. Like
dc.DrawIcon(x, y, m_hIcon);