123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #include "StdAfx.h"
- #include "XTMemDC.h"
- #ifdef _DEBUG
- #undef THIS_FILE
- static char THIS_FILE[]=__FILE__;
- #define new DEBUG_NEW
- #endif
- IMPLEMENT_DYNAMIC(CXTMemDC, CDC);
- CXTMemDC::CXTMemDC(CDC* pDC, const CRect& rect, COLORREF clrColor)
- {
- ASSERT(pDC != NULL);
- m_pDC = pDC;
-
-
- if (rect.IsRectEmpty())
- m_pDC->GetClipBox(&m_rc);
- else
- m_rc.CopyRect(&rect);
-
- if (CreateCompatibleDC(m_pDC))
- {
- SetMapMode(m_pDC->GetMapMode());
-
-
- m_bitmap.CreateCompatibleBitmap(m_pDC, m_rc.Width(), m_rc.Height());
-
-
- m_pOldBitmap = SelectObject(&m_bitmap);
-
-
- if (clrColor != -1)
- FillSolidRect(m_rc, clrColor);
-
- m_bValid = TRUE;
- }
-
- else
- {
- m_bValid = FALSE;
- m_pOldBitmap = NULL;
- }
- }
- CXTMemDC::~CXTMemDC()
- {
- if (m_bValid)
- {
-
- m_pDC->BitBlt(m_rc.left, m_rc.top, m_rc.Width(), m_rc.Height(),
- this, 0, 0, SRCCOPY);
- }
-
- if (m_pOldBitmap != NULL)
- SelectObject(m_pOldBitmap);
- DeleteDC();
- }
|