郁郁思扬
du51
全部博文(2)
2011年(1)
2009年(1)
分类: WINDOWS
2009-03-29 03:29:08
///////////////////////////////////////////////////////////////////////////////// CDoubleBufferImpl - Provides double-buffer painting support to any windowtemplate <class T>class CDoubleBufferImpl{public:// Overrideables void DoPaint(CDCHandle /*dc*/) { // must be implemented in a derived class ATLASSERT(FALSE); }// Message map and handlers BEGIN_MSG_MAP(CDoubleBufferImpl) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground) MESSAGE_HANDLER(WM_PAINT, OnPaint)#ifndef _WIN32_WCE MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)#endif // !_WIN32_WCE END_MSG_MAP() LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { return 1; // no background painting needed } LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) { T* pT = static_cast<T*>(this); ATLASSERT(::IsWindow(pT->m_hWnd)); if(wParam != NULL) { RECT rect = { 0 }; pT->GetClientRect(&rect); CMemoryDC dcMem((HDC)wParam, rect); pT->DoPaint(dcMem.m_hDC); } else { CPaintDC dc(pT->m_hWnd); CMemoryDC dcMem(dc.m_hDC, dc.m_ps.rcPaint); pT->DoPaint(dcMem.m_hDC); } return 0; }};
上一篇:没有了
下一篇:博客已升级,请注意变更地址
登录 注册