代码之家  ›  专栏  ›  技术社区  ›  foraidt

在CView而不是CMainFrame中创建停靠窗格

  •  1
  • foraidt  · 技术社区  · 16 年前

    CMainFrame CreateDockingWindows() .

    OnInitialUpdate() 框架类 包括将主框架设置为父窗口。

    对接窗口的位置会自动保存到注册表中,但不会恢复,因为框架初始化时对接窗口还不存在。

    用视图创建停靠窗口是一个好主意还是我应该期待更多的问题?有没有更好的方法来实现我的目标?

    提前谢谢!

    1 回复  |  直到 16 年前
        1
  •  1
  •   foraidt    16 年前

    我从一个类派生窗格,该类实现了我需要的“类CView”行为:

    /**
     * \brief Mimics some of the behavior of a CView
     *
     * CDockablePane derived class which stores a pointer to the document and offers
     * a behavior similar to CView classes.
     *
     * Since the docking panes are child windows of the main frame,
     * they have a longer live time than a view. Thus the (de-)initialization code
     * cannot reside in the CTor/DTor.
     */
    class CPseudoViewPane :
        public CDockablePane,
    {
        DECLARE_DYNAMIC(CPseudoViewPane)
    
    public:
        /// Initializes the pane with the specified document
        void Initialize(CMyDoc* pDoc);
    
        void DeInitialize();
    
        /// Checks if window is valid and then forwards call to pure virtual OnUpdate() method.
        void Update(const LPARAM lHint);
    
    protected:
        CPseudoViewPane();
        virtual ~CPseudoViewPane();
    
    
        CMyDoc* GetDocument() const { ASSERT(NULL != m_pDocument); return m_pDocument; }
    
        CMainFrame* GetMainFrame() const;
    
        /**
         * This method is called after a document pointer has been set with #Initialize().
         * Override this in derived classes to mimic a view's "OnInitialUpdate()-behavior".
         */
        virtual void OnInitialUpdate() = 0;
    
        /**
         * Called by #Update(). Overrider to mimic a view's "OnUpdate()-behavior".
         * This method has a simplified parameter list. Enhance this if necessary.
         */
        virtual void OnUpdate(const LPARAM lHint) = 0;
    
        DECLARE_MESSAGE_MAP()
    
    private:
        CMyDoc* m_pDocument;
    };