| description | Learn more about: CPaintDC Class | |||||
|---|---|---|---|---|---|---|
| title | CPaintDC Class | |||||
| ms.date | 11/04/2016 | |||||
| f1_keywords |
|
|||||
| helpviewer_keywords |
|
A device-context class derived from CDC.
class CPaintDC : public CDC
| Name | Description |
|---|---|
CPaintDC::CPaintDC |
Constructs a CPaintDC connected to the specified CWnd. |
| Name | Description |
|---|---|
CPaintDC::m_ps |
Contains the PAINTSTRUCT used to paint the client area. |
| Name | Description |
|---|---|
CPaintDC::m_hWnd |
The HWND to which this CPaintDC object is attached. |
It performs a CWnd::BeginPaint at construction time and CWnd::EndPaint at destruction time.
A 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.
CPaintDC
Header: afxwin.h
Constructs a CPaintDC object, prepares the application window for painting, and stores the PAINTSTRUCT structure in the m_ps member variable.
explicit CPaintDC(CWnd* pWnd);
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.
[!code-cppNVC_MFCDocView#97]
The HWND to which this CPaintDC object is attached.
HWND m_hWnd;
m_hWnd is a protected variable of type HWND.
[!code-cppNVC_MFCDocView#98]
m_ps is a public member variable of type PAINTSTRUCT.
PAINTSTRUCT m_ps;
It's the PAINTSTRUCT that is passed to and filled out by CWnd::BeginPaint.
The PAINTSTRUCT contains information that the application uses to paint the client area of the window associated with a CPaintDC object.
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.