#include <memdc.h>
Public Member Functions | |
CMemDC (CDC *pDC, const CRect *pRect=NULL) | |
~CMemDC () | |
CMemDC * | operator-> () |
operator CMemDC * () | |
Private Attributes | |
CBitmap | m_bitmap |
CBitmap * | m_oldBitmap |
CDC * | m_pDC |
CRect | m_rect |
BOOL | m_bMemDC |
Definition at line 31 of file memdc.h.
CMemDC::CMemDC | ( | CDC * | pDC, | |
const CRect * | pRect = NULL | |||
) | [inline] |
Definition at line 40 of file memdc.h.
References m_bitmap, m_bMemDC, m_oldBitmap, m_pDC, and m_rect.
00040 : CDC() 00041 { 00042 ASSERT(pDC != NULL); 00043 00044 // Some initialization 00045 m_pDC = pDC; 00046 m_oldBitmap = NULL; 00047 m_bMemDC = !pDC->IsPrinting(); 00048 00049 // Get the rectangle to draw 00050 if (pRect == NULL) { 00051 pDC->GetClipBox(&m_rect); 00052 } else { 00053 m_rect = *pRect; 00054 } 00055 00056 if (m_bMemDC) { 00057 // Create a Memory DC 00058 CreateCompatibleDC(pDC); 00059 pDC->LPtoDP(&m_rect); 00060 00061 m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height()); 00062 m_oldBitmap = SelectObject(&m_bitmap); 00063 00064 SetMapMode(pDC->GetMapMode()); 00065 00066 SetWindowExt(pDC->GetWindowExt()); 00067 SetViewportExt(pDC->GetViewportExt()); 00068 00069 pDC->DPtoLP(&m_rect); 00070 SetWindowOrg(m_rect.left, m_rect.top); 00071 } else { 00072 // Make a copy of the relevent parts of the current DC for printing 00073 m_bPrinting = pDC->m_bPrinting; 00074 m_hDC = pDC->m_hDC; 00075 m_hAttribDC = pDC->m_hAttribDC; 00076 } 00077 00078 // Fill background 00079 FillSolidRect(m_rect, pDC->GetBkColor()); 00080 }
CMemDC::~CMemDC | ( | ) | [inline] |
Definition at line 82 of file memdc.h.
References m_bMemDC, m_oldBitmap, m_pDC, and m_rect.
00083 { 00084 if (m_bMemDC) { 00085 // Copy the offscreen bitmap onto the screen. 00086 m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(), 00087 this, m_rect.left, m_rect.top, SRCCOPY); 00088 00089 //Swap back the original bitmap. 00090 SelectObject(m_oldBitmap); 00091 } else { 00092 // All we need to do is replace the DC with an illegal value, 00093 // this keeps us from accidently deleting the handles associated with 00094 // the CDC that was passed to the constructor. 00095 m_hDC = m_hAttribDC = NULL; 00096 } 00097 }
CMemDC* CMemDC::operator-> | ( | ) | [inline] |
CMemDC::operator CMemDC * | ( | ) | [inline] |
CBitmap CMemDC::m_bitmap [private] |
CBitmap* CMemDC::m_oldBitmap [private] |
CDC* CMemDC::m_pDC [private] |
CRect CMemDC::m_rect [private] |
BOOL CMemDC::m_bMemDC [private] |