How to dock a CDockablePane to another floating CDockablePane in MFC?

petyer 0 Reputation points
2025-06-02T08:19:06.3133333+00:00

Hi,

I'm working on an MFC application using the MFC App Wizard (VS-generated template with docking panes), and I'm trying to float the Class View pane and then dock the File View pane into that floating Class View pane.

Here's what I currently have inside CMFCApplication1App::OnAppAbout():

void CMFCApplication1App::OnAppAbout()
{
    CMainFrame* mainFrm = (CMainFrame*)m_pMainWnd;

    CRect rect(500, 100, 800, 800); // x=500, y=100, width=300, height=700

    mainFrm->m_wndClassView.ShowPane(FALSE, FALSE, FALSE);
    mainFrm->m_wndFileView.ShowPane(FALSE, FALSE, FALSE);

    mainFrm->m_wndClassView.FloatPane(rect, DM_RECT);

    mainFrm->m_wndFileView.EnableDocking(CBRS_ALIGN_ANY);
    mainFrm->m_wndFileView.DockToFrameWindow(CBRS_ALIGN_BOTTOM, nullptr, DT_DOCK_LAST, &mainFrm->m_wndClassView);

    mainFrm->m_wndClassView.ShowPane(TRUE, FALSE, TRUE);
    mainFrm->m_wndFileView.ShowPane(TRUE, FALSE, TRUE);
}

The Class View floats correctly, but the File View doesn't dock into the floating Class View pane as expected. Instead, it docks back to the main frame or doesn't behave as intended.

Is there a correct way to programmatically dock one CDockablePane into another floating CDockablePane?
The result may looks like this
User's image

Any help or example would be greatly appreciated.
Thanks!

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,960 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.