Hi,
I'm using a pane manager in my main childview, to house 2 main panes What I'd like to do now, is to insure one of the two main panes is always present in the main pane container, but it could be either one I'm guessing there's at least one way to do this in the XTP_DOCKINGPANE_ACTION event.
I may need to perform a few restrictions to achieve this goal...
1) Preventing floating of the pane container.
2) only allowing detaching of the panes.
3) not allowing detaching of a pane if the other pane is already floated.
I think I have a handle on #3 above, but am having problems with 1 and 2.
Thanks!
After a bit more work I was able to find a solution to my desired behavior. I thought I'd share my solution in case others needed the same kind of behavior. The solution includes creating a boolean class member to flag when one of the panes is just starting to be dragged. I'm guessing there's other solutions to achieving this behavior, so this is just one that works for me.
LRESULT CChildView::OnDockingPaneNotify(WPARAM wParam, LPARAM lParam) { if (wParam == XTP_DPN_SHOWWINDOW) { CXTPDockingPane* pPane = (CXTPDockingPane*)(lParam); return onDockingPaneShowWindow(pPane); } else if (wParam == XTP_DPN_ACTION) { XTP_DOCKINGPANE_ACTION* pAction = (XTP_DOCKINGPANE_ACTION*)lParam; return onDockingPaneAction(pAction); }
return 0; }
bool CChildView::onDockingPaneAction(XTP_DOCKINGPANE_ACTION* pAction) { if (pAction->action == xtpPaneActionDocking) { // limit docking to left and right if ((pAction->dockDirection != xtpPaneDockLeft && pAction->dockDirection != xtpPaneDockRight) || (pAction->pDockContainer->GetType() == xtpPaneTypeTabbedContainer)) { pAction->bCancel = true; return true; } paneFloatingStarted = false; } else if (pAction->action == xtpPaneActionDragging) { // check if other pane is already floated CXTPDockingPaneInfoList& list = paneManager.GetPaneList(); POSITION pos = list.GetHeadPosition(); for (int i = 0; i < list.GetCount(); ++i) { CXTPDockingPane* pPane = list.GetNext(pos); if (pPane->IsFloating()) { pAction->bCancel = true; // other pane already floated. Don't allow this one to float } } } else if (pAction->action == xtpPaneActionFloating) { if (paneFloatingStarted) { pAction->bCancel = true; // more than one pane trying to float. Don't allow } else { paneFloatingStarted = true; // flag this pane as currently being f } return true; } else if (pAction->action == xtpPaneActionFloated) { paneFloatingStarted = false; return true; } else if (pAction->action == xtpPaneActionDetaching) { paneFloatingStarted = false; return true; } else if (pAction->action == xtpPaneActionDocked) { paneFloatingStarted = false; return true; }
return false; }
|