0
votes

In one of our applications I've used some of the MFC classes to allow docking a sidebar window, approximately like so:

CDialogBar* bar = new CDialogBar;
bar->Create(this, IDD, WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_TOOLTIPS, IDD));
bar->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
DockControlBar(bar, AFX_IDW_DOCKBAR_RIGHT);

This all works fine.

I want to do a similar thing now in another application. Unfortunately it has been changed to use some classes from the MFC "feature pack", which are very pretty but this approach no longer works (it asserts, which I can fix with some minor modification but then the sidebar doesn't appear). The documentation for these new classes is woeful, so I'm having quite a bit of trouble figuring out what I'm supposed to do. I've tried what seems to be the "new" approach:

  CPaneDialog* pane = new CPaneDialog;
  pane->Create("pane", this, TRUE, IDD, WS_VISIBLE | WS_CHILD, IDD);
  EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
  AddPane(pane);
  DockPane(pane);

This works in that a sidebar window appears, but it doesn't seem to be movable and isn't getting drawn properly.

I feel like I'm shooting in the dark with all this. Does anybody know what the right approach to it is?

4

4 Answers

2
votes

This is what I do as part of my CMainFrame::OnCreate:

if (!m_projectsPane.Create(L"Projects", this, CRect(0,0,0,0), true, IDD_PROJECTSPANE, WS_CHILD|WS_VISIBLE))
    return -1;
AddDockSite();
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
m_projectsPane.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
DockPane(&m_projectsPane, AFX_IDW_DOCKBAR_RIGHT);

My m_projectsPane is a class that then catches ON_WM_GETMINMAXINFO to fill ptMinTrackSize (to make sure the user can't resize the dialog below a certain minimum). I don't see anything else in my code and the resizing of the docked pane works fine.

1
votes

If we both shoot in the dark, we double our chances of hitting something.

Looking at the documentation for CDockablePane (the parent class of CPaneDialog), I notice a method called EnableGripper. Try that.

0
votes

I still can't make a CDialogBox docked to main frame. When I did so, it just is displayed as floating empty mini-framed box. Inside of the box, there is a refresh issue and anything remained on the screen is drawn there.

What I noticed is : If a CPaneDialog is docked to other CDockablePane, it is displayed correctly. But if it is docked to MainFrm, it is not. It is interesting because CPaneDialog is also a child class of CDockablePane. There is no problem in that other CDockablePane is docked to MainFrm. (Tested with SetPaneSize sample from MFC Featurepack sample. )

0
votes

While this may not reach the original people in need anymore. The issue is likely the settings on the resource dialog you added within Visual Studio. Since this control results on the creation of a dialog, any/all styles you may have supplied to the Create() method will be overwritten by settings in the resource file. Make sure the visible property is set to True along with Transparent set to False. I did this and had no problems adding a CPaneDialog to the Main Frame via DockPane().