A device-context class derived from CDC.
class CPaintDC : public CDC
Public Data Members
|CPaintDC::m_ps||Contains the PAINTSTRUCT used to paint the client area.|
Protected Data Members
|CPaintDC::m_hWnd||The HWND to which this
CPaintDC object can only be used when responding to a WM_PAINT message, usually in your
OnPaint message-handler member function.
For more information on using
CPaintDC, see Device Contexts.
explicit CPaintDC(CWnd* pWnd);
Points to the
CWnd object to which the
CPaintDC object belongs.
An exception (of type
CResourceException) is thrown if the Windows GetDC call fails. A device context may not be available if Windows has already allocated all of its available device contexts. Your application competes for the five common display contexts available at any given time under Windows.
// Get a dc for a CWnd pointer. CPaintDC dc(pWnd); // Get a dc for a HWND. CPaintDC dc2(CWnd::FromHandle(hWnd));
HWND to which this
CPaintDC object is attached.
m_hWnd is a protected variable of type HWND.
// Get a dc for a CWnd object pointer. CPaintDC dc(pWnd); // Send my private massage. ::SendMessage(pWnd->m_hWnd, WM_MYMESSAGE, (LPARAM)& dc.m_ps, 0);
m_ps is a public member variable of type PAINTSTRUCT.
It is the
PAINTSTRUCT that is passed to and filled out by CWnd::BeginPaint.
PAINTSTRUCT contains information that the application uses to paint the client area of the window associated with a
Note that you can access the device-context handle through the
PAINTSTRUCT. However, you can access the handle more directly through the
m_hDC member variable that
CPaintDC inherits from CDC.
See the example for CPaintDC::m_hWnd.