Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting dock area where an MFC CDockablePane was docked

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!

like image 515
Detox Avatar asked Feb 17 '23 13:02

Detox


2 Answers

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.

like image 83
Roger Rowland Avatar answered Feb 23 '23 19:02

Roger Rowland


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.

like image 44
Dmitry K. Avatar answered Feb 23 '23 19:02

Dmitry K.