修改完毕:
CMemDC::CMemDC(CDC* pDC, const CRect& rcBounds) : CDC()
{
CreateCompatibleDC(pDC);
m_pBitmap = new CBitmap(); int nWidth=rcBounds.Width();
int nHeight=rcBounds.Height();
m_pBitmap->CreateCompatibleBitmap(pDC, nWidth, nHeight);
m_pOldBitmap = SelectObject(m_pBitmap); m_pDC = pDC;
m_rcBounds = rcBounds;
}CMemDC::~CMemDC()
{
int nWidth=m_rcBounds.Width();
int nHeight=m_rcBounds.Height();
m_pDC->BitBlt(m_rcBounds.left, m_rcBounds.top, nWidth, nHeight, this, m_rcBounds.left, m_rcBounds.top, SRCCOPY);
SelectObject(m_pOldBitmap);
if (m_pBitmap != NULL) delete m_pBitmap;
}

解决方案 »

  1.   

    修改完毕:
    CMemDC::CMemDC(CDC* pDC, const CRect& rcBounds) : CDC()
    {
    CreateCompatibleDC(pDC);
    m_pBitmap = new CBitmap(); int nWidth=rcBounds.Width();
    int nHeight=rcBounds.Height();
    m_pBitmap->CreateCompatibleBitmap(pDC, nWidth, nHeight);
    m_pOldBitmap = SelectObject(m_pBitmap); m_pDC = pDC;
    m_rcBounds = rcBounds;
    }CMemDC::~CMemDC()
    {
    int nWidth=m_rcBounds.Width();
    int nHeight=m_rcBounds.Height();
    m_pDC->BitBlt(m_rcBounds.left, m_rcBounds.top, nWidth, nHeight, this, m_rcBounds.left, m_rcBounds.top, SRCCOPY);
    SelectObject(m_pOldBitmap);
    if (m_pBitmap != NULL) delete m_pBitmap;
    }