CMemDC Class Reference

A class for flicker-free drawing in the window. More...

#include <memdc.h>

List of all members.

Public Member Functions

 CMemDC (CDC *pDC, const CRect *pRect=NULL)
 ~CMemDC ()
CMemDCoperator-> ()
 operator CMemDC * ()

Private Attributes

CBitmap m_bitmap
CBitmap * m_oldBitmap
CDC * m_pDC
CRect m_rect
BOOL m_bMemDC


Detailed Description

A class for flicker-free drawing in the window.

Definition at line 31 of file memdc.h.


Constructor & Destructor Documentation

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         }


Member Function Documentation

CMemDC* CMemDC::operator-> (  )  [inline]

Definition at line 100 of file memdc.h.

00101         {
00102                 return this;
00103         }       

CMemDC::operator CMemDC * (  )  [inline]

Definition at line 106 of file memdc.h.

00107         {
00108                 return this;
00109         }


Member Data Documentation

CBitmap CMemDC::m_bitmap [private]

Definition at line 33 of file memdc.h.

Referenced by CMemDC().

CBitmap* CMemDC::m_oldBitmap [private]

Definition at line 34 of file memdc.h.

Referenced by CMemDC(), and ~CMemDC().

CDC* CMemDC::m_pDC [private]

Definition at line 35 of file memdc.h.

Referenced by CMemDC(), and ~CMemDC().

CRect CMemDC::m_rect [private]

Definition at line 36 of file memdc.h.

Referenced by CMemDC(), and ~CMemDC().

BOOL CMemDC::m_bMemDC [private]

Definition at line 37 of file memdc.h.

Referenced by CMemDC(), and ~CMemDC().


The documentation for this class was generated from the following file:

Generated on Wed Aug 20 00:48:45 2008 for EvolveTraffic by  doxygen 1.5.6