You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.1 KiB
C++
72 lines
1.1 KiB
C++
|
|
// MemDC.h : header file
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#pragma once
|
|
|
|
class CMemDC_Redefine : public CDC
|
|
{
|
|
public:
|
|
|
|
//¹¹ÔìÄÚ´æÉ豸³¡¾°
|
|
CMemDC_Redefine(CDC* pDC) : CDC()
|
|
{
|
|
ASSERT(pDC != NULL);
|
|
|
|
m_pDC = pDC;
|
|
m_pOldBitmap = NULL;
|
|
m_bMemDC = !pDC->IsPrinting();
|
|
|
|
if (m_bMemDC)
|
|
{
|
|
pDC->GetClipBox(&m_rect);
|
|
CreateCompatibleDC(pDC);
|
|
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
|
|
m_pOldBitmap = SelectObject(&m_bitmap);
|
|
SetWindowOrg(m_rect.left, m_rect.top);
|
|
}
|
|
else
|
|
{
|
|
m_bPrinting = pDC->m_bPrinting;
|
|
m_hDC = pDC->m_hDC;
|
|
m_hAttribDC = pDC->m_hAttribDC;
|
|
}
|
|
}
|
|
|
|
//Îö¹¹
|
|
~CMemDC_Redefine()
|
|
{
|
|
if (m_bMemDC)
|
|
{
|
|
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);
|
|
}
|
|
else
|
|
{
|
|
m_hDC = m_hAttribDC = NULL;
|
|
}
|
|
}
|
|
|
|
CMemDC_Redefine * operator->()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
operator CMemDC_Redefine *()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
private:
|
|
CBitmap m_bitmap;
|
|
CBitmap* m_pOldBitmap;
|
|
CDC* m_pDC;
|
|
CRect m_rect;
|
|
BOOL m_bMemDC;
|
|
};
|
|
|
|
|