C++技巧之四(MFC)

字號:

代碼清單2 window_redraw_scope的節(jié)略本
    /* /////////////////////////////////
     *
     * ...
     *
     * Extract from winstl_window_redraw_scope.h
    *摘錄自winstl_window_redraw_scope.h
     *
     * www: http://www.synesis.com.au/winstl
     * http://www.winstl.org/
     *
     * Copyright (C) 2002, Synesis Software Pty Ltd.
     *版權(quán)所有(C) 2002, Synesis Software Pty Ltd公司
     * (Licensed under the Synesis Software Standard Source License:
     * http://www.synesis.com.au/licenses/ssssl.html)
    * (由Synesis Software Standard Source License授權(quán)許可:
     * http://www.synesis.com.au/licenses/ssssl.html)
     *
     * ...
     *
     * /////////////////////////////// */
    ...
    namespace winstl
    {
     class window_redraw_scope
     {
    // Construction
    // 構(gòu)造
     public:
     // Takes a HWND and changes it's current redraw-status,
     // which is set back to the original state in the
     // destructor.
     //取得HWND 句柄并改變其當(dāng)前重畫狀態(tài),在析構(gòu)器中設(shè)置其回到初始狀態(tài)。
     ws_explicit_k window_redraw_scope(HWND hwnd,
     ws_bool_t bInvalidateOnUnlock = true)
     : m_hwnd(hwnd)
     , m_bInvalidateOnUnlock(bInvalidateOnUnlock)
     {
     ::SendMessage(m_hwnd, WM_SETREDRAW, false, 0L);
     }
     ~window_redraw_scope() winstl_throw_0()
     {
     ::SendMessage(m_hwnd, WM_SETREDRAW, true, 0L);
     if(m_bInvalidateOnUnlock)
     {
     ::InvalidateRect(m_hwnd, NULL, true);
     }
     }
    // Members
    // 成員變量
     protected:
     HWND m_hwnd;
     ws_bool_t m_bInvalidateOnUnlock;
    // Not to be implemented
    // 不被實(shí)現(xiàn)
     private:
     window_redraw_scope(window_redraw_scope const &rhs);
     window_redraw_scope const
     &operator =(window_redraw_scope const &rhs);
     };
    } // namespace winstl 名稱空間