While CDockablePane does not move remaining elements in a MainFrame to right ?
-
I have created "empty" MFC application (C++, Visual Studio, type - MDI, style = MFC Standard). In original it simply creates empty documents.
Then I have added CDockablePane with a tree (CMainFrame::mmm_wndTreeView).
I have expected the CDockablePane will be placed at left side and documents (see tabs in screenshot) - at right.
In fact the CDockablePane with the tree has appeared not at left side - it overrides documents areas. See "before_dragging.png".
If I drag the CDockablePane then I can get it left and documents at right. See "after_dragging.png".The question is: how can I place CDockablePane at left side moving documents window (with tabs) to the right at start of my program (as in "after_dragging" screenshot)?
Initialization of main frame:
// ----------------- MainFrm.h: CMainFrame class ----------------- // #include "TestMFC_MyTreeView.h" // MyTreeView #pragma once class CMainFrame : public CMDIFrameWndEx { DECLARE_DYNAMIC(CMainFrame) public: CMainFrame() noexcept; public: public: public: virtual BOOL PreCreateWindow(CREATESTRUCT& cs); public: virtual ~CMainFrame(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: CToolBar m_wndToolBar; CStatusBar m_wndStatusBar; // it's my tree MyTreeView mmm_wndTreeView; protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); DECLARE_MESSAGE_MAP() }; // --------------------- MainFrm_Empty.cpp: implementation of CMainFrame ------------------- // #include "pch.h" #include "framework.h" #include "TestMFC_Empty.h" #include "MainFrm_Empty.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMainFrame IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWndEx) BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWndEx) ON_WM_CREATE() END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; CMainFrame::CMainFrame() noexcept { } CMainFrame::~CMainFrame() { } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; CDockingManager::SetDockingMode(DT_SMART); EnableAutoHidePanes(CBRS_ALIGN_ANY); CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; mdiTabParams.m_bActiveTabCloseButton = TRUE; mdiTabParams.m_bTabIcons = FALSE; mdiTabParams.m_bAutoColor = TRUE; mdiTabParams.m_bDocumentMenu = TRUE; EnableMDITabbedGroups(TRUE, mdiTabParams); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Error1\n"); return -1; } if (!m_wndStatusBar.Create(this)) { TRACE0("Error2\n"); return -1; } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // @+++++++++++++++ code to display the tree +++++++++++++++++++++++++ CString strTreeClassView = _T("TreeWinName"); if (!mmm_wndTreeView.Create(strTreeClassView, this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_MYTREEVIEW, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Error3\n"); return FALSE; } mmm_wndTreeView.EnableDocking(CBRS_ALIGN_ANY); DockPane(&mmm_wndTreeView, AFX_IDW_DOCKBAR_LEFT); ModifyStyle(0, FWS_PREFIXTITLE); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIFrameWndEx::PreCreateWindow(cs) ) return FALSE; return TRUE; }
-
Perhaps something useful in the following article?
https://www.codeproject.com/articles/Understanding-CDockablePane