2

VS2008(およびFeature Pack)のAppWizardを使用して「VisualStudio」スタイルのMDIアプリケーションを作成する場合、CMainFrameクラスはメソッドを取得しCreateDockingWindows()ます。

すべてのペインを常に表示するのではなく、アクティブなドキュメントのタイプに応じて表示する必要があるため、これらのウィンドウをビューのメンバーに作成し、作成をに移動しましたOnInitialUpdate()CMainFrameメインフレームを親ウィンドウとして設定するなどして行ったのと同じ方法で、これらのペインを作成します。

ドッキングウィンドウの位置はレジストリに自動的に保存されますが、フレームの初期化時にドッキングウィンドウがまだ存在しないため、復元されません。

ビューを使用してドッキングウィンドウを作成することをお勧めしますか、それともさらに問題が発生する可能性がありますか?私が望むことを達成するためのより良い方法はありますか?

前もって感謝します!

4

1 に答える 1

1

次の解決策は、私にとってはかなりうまくいくことがわかりました。

MainFrame は引き続きすべてのペインを所有しているため、既存のすべてのフレームワーク機能が維持されます。

必要な「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;
};
于 2009-02-24T12:31:16.333 に答える