class double_buffer : public CDC { int m_Mode; CBitmap m_MemBitmap; CWnd *mp_wnd; CDC *mp_Dc; CRect m_Rect; CBitmap *m_oldbitmap; public: double_buffer(CWnd *p_wnd) : mp_wnd(p_wnd) { mp_Dc = mp_wnd->GetDC(); mp_wnd->GetWindowRect(&m_Rect); CreateCompatibleDC(mp_Dc); m_MemBitmap.CreateCompatibleBitmap(mp_Dc, m_Rect.Width(), m_Rect.Height()); m_oldbitmap = SelectObject(&m_MemBitmap); BitBlt(0,0, m_Rect.Width(), m_Rect.Height(),mp_Dc,0,0,SRCCOPY); } void inverse(){m_Mode = SetROP2(R2_XORPEN);} ~double_buffer() { mp_Dc->BitBlt(0,0, m_Rect.Width(), m_Rect.Height(),this,0,0,SRCCOPY); SelectObject(m_oldbitmap); m_MemBitmap.DeleteObject(); DeleteDC(); mp_wnd->ReleaseDC(mp_Dc); } };