Here is the OnPaint handler
that was created to handle
the
WM_PAINT
message:
Collapse
Copy Code
LRESULT OnPaint (HWND hWnd)
{
PAINTSTRUCT ps;
HDC hdc;
hdc = ::BeginPaint(hWnd, &ps);
UINT index;
for (index = 0; index < SHAPE_COUNT; index++)
{
if (ID_SHAPE_RECTANGLE == Shapes[index].shapeID)
{
::Rectangle (
hdc,
Shapes[index].rect.left,
Shapes[index].rect.top,
Shapes[index].rect.right,
Shapes[index].rect.bottom
);
}
else
{
::Ellipse (
hdc,
Shapes[index].rect.left,
Shapes[index].rect.top,
Shapes[index].rect.right,
Shapes[index].rect.bottom
);
}
}
::EndPaint(hWnd, &ps);
return 0;
}
CPaintDC::CPaintDC(CWnd* pWnd)
{
...
if (!Attach(::BeginPaint(m_hWnd = pWnd->m_hWnd, &m_ps)))
AfxThrowResourceException();
}
CPaintDC::~CPaintDC()
{
...
::EndPaint(m_hWnd, &m_ps);
Detach();
}
CClientDC::CClientDC(CWnd* pWnd)
{
...
if (!Attach(::GetDC(m_hWnd = pWnd->GetSafeHwnd())))
AfxThrowResourceException();
}
CClientDC::~CClientDC()
{
...
::ReleaseDC(m_hWnd, Detach());
}
|
|