2
votes

I want to create two CDockablePane objects in my MDI child window. Initally, they should be docked to the bottom but the user shall have the possibility to float them. I started with the code created by the MFC project wizard. Then I moved the code from the class representing the main frame to the class representing the child frame (CChildFrame). I ended up with this:

int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) {
        return -1;
    }

    EnableDocking(CBRS_ALIGN_ANY);
    EnableAutoHidePanes(CBRS_ALIGN_ANY);

    // Create left window and dock to ChildFrame
    m_wndOutput.Create(_T("Left pane"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_OUTPUTWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI);
    m_wndOutput.EnableDocking(CBRS_ALIGN_ANY);
    DockPane(&m_wndOutput);

    // Create right window and dock to the left pane
    m_wndProperties.Create(_T("Right pane"), this, CRect(0, 0, 200, 200), TRUE, ID_VIEW_PROPERTIESWND, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_RIGHT | CBRS_FLOAT_MULTI);
    m_wndProperties.EnableDocking(CBRS_ALIGN_ANY);
    m_wndProperties.DockToWindow (&m_wndOutput, CBRS_ALIGN_RIGHT);

    return 0;
}

First of all, the panes were not able to float. I could fix this by adding the following statement to my CChildFrame constructor:

CMDIChildWndEx::m_bEnableFloatingBars = TRUE;

This solved the not-floating problem, but I doubt that this is the canonical solution for the problem. Can anyone judge that? How do you solve that problem?

The problem I was not able to solve is that the panes initially have height = 0. Interestingly, if I open a second or third child frame of the same class, it works and they are initially visible (with height = 200). If I close them all and open a new one, the height is 0 again and only the slider appears which I can use for adjusting the height. However, I need to be able to really see the panels also for the first child frame.

If I shall provide more sample code, please let me know. If I'm doing something completely wrong (is it supported to have panes in a child frame?), please also let me know.

I guess that the problem described in the following link is the same. But there is no answer to that question. https://social.msdn.microsoft.com/forums/en-US/7494e84f-e5fd-4726-b8fe-9c702c7e25f1/cmdichildwndex-and-cdockablepane-issue

2
Have you read this: codeproject.com/Articles/493218/Understanding-CDockablePane ? I found it cleared up many things that were fuzzy for me about CDockablePane, although I had gotten most things to work with trial and error over the years.Roel
Yes, I read that. All the samples there use the main frame for adding the dockable panes.JohnQQ

2 Answers

1
votes

sadly this is coming 2 years later =)

but I just solved the problem using the method SetMinSize, that is inherited from CPane, after the pane's creation.

m_wndProperties.SetMinSize(CSize(200,200));
0
votes

I couldn't completely solve the problem and eventually I ended up in creating my dockable panes in the main frame and hiding them until my child frame is opened. A partial solution for the problem was to set a minimal size for the panes. This lead to the situation that they were not hidden anymore.

My conclusion is that dockable panes are not meant to be created for (or controlled by) child frames.