Jak
Jak

Reputation: 499

DockPaneLeftOf in CMDIChildWndEx Frame

I have the following code and I want to dock the CMFCToolBars in one row, but using DockPaneLeftOf does not result in any toolbars, except MainTools, displaying. Using only DockPane results in the toolbars displaying below each other. Any ideas?

BOOL CFloorFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{

    if ((!m_ctlMainTools.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER, 2)) ||
        (!m_ctlMainTools.LoadToolBar(IDR_FA_SC_TBAR)))
    {
        return FALSE;
    }

    if ((!m_ctlObjects.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER, 1)) ||
        (!m_ctlObjects.LoadToolBar(IDR_FLOOR_OBJECTS)))
    {
        return FALSE;
    }

    if ((!m_ctlTools.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER, 3)) ||
        (!m_ctlTools.LoadToolBar(IDR_FLOOR_TOOLS)))
    {
        return FALSE;
    }

    m_ctlMainTools.EnableDocking(CBRS_ALIGN_ANY);
    m_ctlObjects.EnableDocking(CBRS_ALIGN_ANY);
    m_ctlTools.EnableDocking(CBRS_ALIGN_ANY);
    m_ctlLegend.EnableDocking(CBRS_ALIGN_ANY);
    EnableDocking(CBRS_ALIGN_ANY);

    DockPane(&m_ctlMainTools);
    DockPaneLeftOf(&m_ctlObjects, &m_ctlMainTools);
    DockPaneLeftOf(&m_ctlTools, &m_ctlObjects);
    DockPaneLeftOf(&m_ctlLegend, &m_ctlTools);

    DragAcceptFiles(TRUE);
    return TRUE;
}

Upvotes: 1

Views: 562

Answers (1)

diox8tony
diox8tony

Reputation: 346

Maybe you are missing the ShowPane call. this works for me

DockPane(&m_wndEditBar);
m_wndEditBar.ShowPane(TRUE, FALSE, TRUE);
DockPaneLeftOf(&m_wndMainBar, &m_wndEditBar);
m_wndMainBar.ShowPane(TRUE, FALSE, TRUE);

The m_wndEditBar appears to the right of the m_wndMainBar.

Also, The CMDIFrameWndEx::LoadFrame function, eventually, calls CDockingManager::LoadState which reads registry data saved. It can overwrite all the toolbar settings that you changed. Clearing your programs registry might do the trick. Anytime we change a button or state of a toolbar we have to clear registry to make it appear.

Upvotes: 1

Related Questions