views:

58

answers:

1

Use naming from http://msdn.microsoft.com/en-us/library/cc309030.aspx

When I docking CPaneDialog with another CDockablePane the Tabbed Pane position is always at bottom of dock area, How to set Tabbed Pane position to top of dock area like normal tabbed control?

A: 

Ok, I have figured it out, so I will answer my own question :)

When CDockablePane docking to each other, MFC will create CBaseTabbedPane to hold CDockablePanes. To change tab position which default is bottom (like in Visual Studio) to top (like in normal tab) you need to overrides this method in your CDockablePane-derived class

void CDockablePane::OnAfterDock(CBasePane* /*pBar*/, LPCRECT /*lpRect*/, AFX_DOCK_METHOD /*dockMethod*/);

with this codes :

CBaseTabbedPane* tabbedPane = GetParentTabbedPane();
if (!tabbedPane) return;

CMFCBaseTabCtrl* tabCtrl = tabbedPane->GetUnderlyingWindow();
if (!tabCtrl) return;

tabCtrl->SetLocation(CMFCBaseTabCtrl::LOCATION_TOP);

OR

HWND hWndTab = NULL;
CMFCBaseTabCtrl* parent = GetParentTabWnd(hWndTab);
if (parent)
{
    parent->SetLocation(CMFCBaseTabCtrl::LOCATION_TOP);
}

You need to overrides this method in all CDockablePane-derived classes to work properly, otherwise tab position will depend on the Pane that you dragging to dock the other pane.

For example : PaneA has code to set tab position to top but PaneB doesn't.

If you dragging PaneA to dock with PaneB, tab position will be at top.

If you dragging PaneB to dock with PaneA, tab position will be at bottom which is default.

Por