4

I am working on a project that totally does not want to use the built-in window/dock state and position saving of MFC. This means that in my main frame, I set EnableLoadDockState(FALSE). As much as I love to change it back to TRUE, I can't.

I plan on getting the position where a CDockablePane was docked through onAfterDock() of my CDockablePane. My problem is I have no idea on how to get whether it was placed on the side, top or bottom, on another CDockablePane.

Is there a way to get this information?

Thanks!

Arpit Kulsreshtha
  • 2,452
  • 2
  • 26
  • 52
Detox
  • 71
  • 1
  • 5

2 Answers2

4

I think there is a way to get it, but it's not going to be easy or pretty.

A you're trapping the OnAfterDock, I guess you're not interested in floating panes. So, for docked panes, you can use CDockablePane::GetDefaultPaneDivider (MSDN here), which returns - as MSDN says:

A valid CPaneDivider object if the dockable pane is docked to the main frame window, or NULL if the dockable pane is not docked or if it is floating.

The CPaneDivider object (MSDN here)

...divides two panes, divides two groups of panes, or separates a group of panes from the client area of the main frame window

The following partial screenshot says more:

cpanedivider

So, for a regular pane divider, you can use the methods available on CPaneDivider to find the other pane, or another embedded CPaneDivider (so recursive interrogation necessary here) and check if the divider is horizontal or vertical etc.

For the other case described above, look at the CPaneContainerManager class, which (again as MSDN says)

...manages the storage and display of the current docking layout

From here, you can again drill down through the whole docking hierarchy that starts from your original docked pane.

If I were you, I would really really look again at using EnableLoadDockState or at least browse the MFC source code to see if there are any internal helper classes/functions that you can reuse.

Roger Rowland
  • 25,885
  • 11
  • 72
  • 113
  • Thanks! I will look into it. I really hate it that EnableLoadDockState was set to false, I can't even make my tabbed docks untab correctly when more than 2 are docked. I will update this once I make any real progress. – Detox May 15 '13 at 09:41
  • After trying to make it work, I more or less gave up. I was able to get dock size and window size and position by modifying the savestate of the derived cDockablePane class but docking position was too difficult and complicated to save since these are stored in CDockingManager and the attributes needed are protected. – Detox May 30 '13 at 06:27
4

I've just solved this issue. I can check CDockablePane's dwStyle (GetPaneStyle()) for CBRS_ALIGN_LEFT, CBRS_ALIGN_RIGHT, etc. No complex methods. Simple.

Dmitry K.
  • 313
  • 3
  • 17
  • So does the style change dynamically when it's docked? Also, this doesn't help to find the object it was docked to, which AIUI was part of the OP's problem. – Roger Rowland Jan 22 '14 at 11:06
  • 1
    @RogerRowland Yes, the style changes dynamically. And you are right. Finally, I have switched to `EnableLoadDockState(TRUE)`. I have found `protected` code within docking manager object and made a hack to call it. But some minutes later I gave up. Sorry. Maybe you can copy that code to your own docking manager hacking class. – Dmitry K. Jan 31 '14 at 13:44