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