使用 MFC 功能包 1 对接 VS2008 中的选项卡式窗格位置

发布于 2024-09-11 23:47:11 字数 266 浏览 2 评论 0原文

使用命名来自 http://msdn.microsoft.com/en-us/library/cc309030。 aspx

当我将 CPaneDialog 与另一个 CDockablePane 对接时,选项卡式窗格位置 始终位于停靠区域的底部,如何将选项卡式窗格位置设置为顶部 像普通选项卡式控件一样的停靠区域?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

踏雪无痕 2024-09-18 23:47:11

好吧,我已经弄清楚了,所以我来回答我自己的问题:)

当 CDockablePane 相互对接时,MFC 会创建 CBaseTabbedPane 来保存 CDockablePanes。 在 CDockablePane 派生类中重写此方法

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

要将默认为底部(如在 Visual Studio 中)的选项卡位置更改为顶部(如在普通选项卡中),您需要使用以下代码

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

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

tabCtrl->SetLocation(CMFCBaseTabCtrl::LOCATION_TOP);

:或者

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

您需要在所有 CDockablePane 派生类中重写此方法类才能正常工作,否则选项卡位置将取决于您拖动以停靠其他窗格的窗格。

例如:PaneA 具有将选项卡位置设置为顶部的代码,但 PaneB 没有。

如果拖动 PaneA 与 PaneB 对接,选项卡位置将位于顶部。

如果拖动 PaneB 与 PaneA 对接,选项卡位置将默认位于底部。

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.

过气美图社 2024-09-18 23:47:11

通过修改CTabbedPane::m_bTabsAlwaysTop,我得到了满意的结果。

I got satisfactory results by modifying CTabbedPane::m_bTabsAlwaysTop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文