• WTL里双缓冲避免闪烁


     1///////////////////////////////////////////////////////////////////////////////
     2// CDoubleBufferImpl - Provides double-buffer painting support to any window
     3
     4template <class T>
     5class CDoubleBufferImpl
     6{
     7public:
     8// Overrideables
     9    void DoPaint(CDCHandle /*dc*/)
    10    {
    11        // must be implemented in a derived class
    12        ATLASSERT(FALSE);
    13    }

    14
    15// Message map and handlers
    16    BEGIN_MSG_MAP(CDoubleBufferImpl)
    17        MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackground)
    18        MESSAGE_HANDLER(WM_PAINT, OnPaint)
    19#ifndef _WIN32_WCE
    20        MESSAGE_HANDLER(WM_PRINTCLIENT, OnPaint)
    21#endif // !_WIN32_WCE
    22    END_MSG_MAP()
    23
    24    LRESULT OnEraseBackground(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    25    {
    26        return 1;   // no background painting needed
    27    }

    28
    29    LRESULT OnPaint(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    30    {
    31        T* pT = static_cast<T*>(this);
    32        ATLASSERT(::IsWindow(pT->m_hWnd));
    33
    34        if(wParam != NULL)
    35        {
    36            RECT rect = 0 };
    37            pT->GetClientRect(&rect);
    38            CMemoryDC dcMem((HDC)wParam, rect);
    39            pT->DoPaint(dcMem.m_hDC);
    40        }

    41        else
    42        {
    43            CPaintDC dc(pT->m_hWnd);
    44            CMemoryDC dcMem(dc.m_hDC, dc.m_ps.rcPaint);
    45            pT->DoPaint(dcMem.m_hDC);
    46        }

    47
    48        return 0;
    49    }

    50}
    ;
  • 相关阅读:
    OpenCV && C++ 01
    图像矩的理解
    Halcon Example
    LabVIEW
    Working Experience
    Working Experience
    Working Experience
    C++
    Trigger,Cursor
    Paging
  • 原文地址:https://www.cnblogs.com/javado/p/1424176.html
Copyright © 2020-2023  润新知