#include "stdafx.h"
|
#include "ServoMemDC.h"
|
|
CServoMemDC::CServoMemDC(CDC* pDC, const CRect* pRect)
|
: CDC(), m_pOldBitmap(nullptr), m_pDC(pDC), m_bMemDC(FALSE)
|
{
|
ASSERT(pDC != nullptr);
|
|
if (pRect == nullptr)
|
pDC->GetClipBox(&m_rect);
|
else
|
m_rect = *pRect;
|
|
if (CreateCompatibleDC(pDC)) {
|
m_bMemDC = TRUE;
|
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
|
m_pOldBitmap = SelectObject(&m_bitmap);
|
SetWindowOrg(m_rect.left, m_rect.top);
|
}
|
}
|
|
CServoMemDC::~CServoMemDC()
|
{
|
if (m_bMemDC) {
|
// ½«ÄÚ´æ DC ¿½±´»ØÔʼ´°¿Ú DC
|
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
|
this, m_rect.left, m_rect.top, SRCCOPY);
|
SelectObject(m_pOldBitmap);
|
}
|
}
|
|
CServoMemDC* CServoMemDC::operator->()
|
{
|
return this;
|
}
|
|
CServoMemDC::operator CDC* ()
|
{
|
return this;
|
}
|