Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. While CDockablePane does not move remaining elements in a MainFrame to right ?

While CDockablePane does not move remaining elements in a MainFrame to right ?

Scheduled Pinned Locked Moved C / C++ / MFC
mfc
3 Posts 2 Posters 27 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    progman99
    wrote last edited by
    #1

    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;
    }
    

    before_dragging.PNG after_dragging.PNG

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jeron1
      wrote last edited by
      #2

      Perhaps something useful in the following article?
      https://www.codeproject.com/articles/Understanding-CDockablePane

      1 Reply Last reply
      0
      • P Offline
        P Offline
        progman99
        wrote last edited by
        #3

        jeron1, thank you, but I have started with that acticle :)
        It was useful but didn't helped me.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups