将控制栏/窗格停靠到 CMDIFrameWndEx?

发布于 2024-07-16 10:51:03 字数 820 浏览 9 评论 0原文

在我们的一个应用程序中,我使用了一些 MFC 类来允许停靠侧边栏窗口,大致如下:

CDialogBar* bar = new CDialogBar;
bar->Create(this, IDD, WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_TOOLTIPS, IDD));
bar->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
DockControlBar(bar, AFX_IDW_DOCKBAR_RIGHT);

这一切都工作正常。

我现在想在另一个应用程序中做类似的事情。 不幸的是,它已更改为使用 MFC“功能包”中的一些类,这些类非常漂亮,但这种方法不再有效(它断言,我可以通过一些小的修改来修复它,但侧边栏不会出现)。 这些新类的文档很糟糕,所以我在弄清楚我应该做什么时遇到了很大的困难。 我尝试过似乎是“新”的方法:

  CPaneDialog* pane = new CPaneDialog;
  pane->Create("pane", this, TRUE, IDD, WS_VISIBLE | WS_CHILD, IDD);
  EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
  AddPane(pane);
  DockPane(pane);

这可以工作,因为会出现一个侧边栏窗口,但它似乎不可移动并且无法正确绘制。

我感觉这一切都是在黑暗中拍摄的。 有谁知道正确的方法是什么?

In one of our applications I've used some of the MFC classes to allow docking a sidebar window, approximately like so:

CDialogBar* bar = new CDialogBar;
bar->Create(this, IDD, WS_CHILD | WS_VISIBLE | CBRS_RIGHT | CBRS_TOOLTIPS, IDD));
bar->EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
DockControlBar(bar, AFX_IDW_DOCKBAR_RIGHT);

This all works fine.

I want to do a similar thing now in another application. Unfortunately it has been changed to use some classes from the MFC "feature pack", which are very pretty but this approach no longer works (it asserts, which I can fix with some minor modification but then the sidebar doesn't appear). The documentation for these new classes is woeful, so I'm having quite a bit of trouble figuring out what I'm supposed to do. I've tried what seems to be the "new" approach:

  CPaneDialog* pane = new CPaneDialog;
  pane->Create("pane", this, TRUE, IDD, WS_VISIBLE | WS_CHILD, IDD);
  EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT);
  AddPane(pane);
  DockPane(pane);

This works in that a sidebar window appears, but it doesn't seem to be movable and isn't getting drawn properly.

I feel like I'm shooting in the dark with all this. Does anybody know what the right approach to it is?

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

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

发布评论

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

评论(4

白首有我共你 2024-07-23 10:51:03

这就是我在 CMainFrame::OnCreate 中所做的事情:

if (!m_projectsPane.Create(L"Projects", this, CRect(0,0,0,0), true, IDD_PROJECTSPANE, WS_CHILD|WS_VISIBLE))
    return -1;
AddDockSite();
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
m_projectsPane.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
DockPane(&m_projectsPane, AFX_IDW_DOCKBAR_RIGHT);

我的 m_projectsPane 是一个类,然后捕获 ON_WM_GETMINMAXINFO 来填充 ptMinTrackSize (以确保用户无法将对话框的大小调整到低于某个最小值)。 我在代码中没有看到任何其他内容,并且停靠窗格的大小调整工作正常。

This is what I do as part of my CMainFrame::OnCreate:

if (!m_projectsPane.Create(L"Projects", this, CRect(0,0,0,0), true, IDD_PROJECTSPANE, WS_CHILD|WS_VISIBLE))
    return -1;
AddDockSite();
EnableDocking(CBRS_ALIGN_ANY);
EnableAutoHidePanes(CBRS_ALIGN_ANY);
m_projectsPane.EnableDocking(CBRS_ALIGN_LEFT|CBRS_ALIGN_RIGHT);
DockPane(&m_projectsPane, AFX_IDW_DOCKBAR_RIGHT);

My m_projectsPane is a class that then catches ON_WM_GETMINMAXINFO to fill ptMinTrackSize (to make sure the user can't resize the dialog below a certain minimum). I don't see anything else in my code and the resizing of the docked pane works fine.

如梦 2024-07-23 10:51:03

如果我们都在黑暗中射击,我们击中物体的机会就会加倍。

查看 CDockablePane (CPaneDialog 的父类)的文档,我注意到一个名为 EnableGripper 的方法。 尝试一下。

If we both shoot in the dark, we double our chances of hitting something.

Looking at the documentation for CDockablePane (the parent class of CPaneDialog), I notice a method called EnableGripper. Try that.

过期以后 2024-07-23 10:51:03

我仍然无法将 CDialogBox 停靠到主框架。 当我这样做时,它只是显示为浮动的空迷你框架框。 在盒子内部,存在刷新问题,屏幕上剩余的任何内容都会绘制在那里。

我注意到的是:如果 CPaneDialog 停靠到其他 CDockablePane,它会正确显示。 但如果对接MainFrm则不然。 这很有趣,因为 CPaneDialog 也是 CDockablePane 的子类。 其他CDockablePane停靠到MainFrm上是没有问题的。 (使用 MFC 功能包示例中的 SetPaneSize 示例进行测试。)

I still can't make a CDialogBox docked to main frame. When I did so, it just is displayed as floating empty mini-framed box. Inside of the box, there is a refresh issue and anything remained on the screen is drawn there.

What I noticed is : If a CPaneDialog is docked to other CDockablePane, it is displayed correctly. But if it is docked to MainFrm, it is not. It is interesting because CPaneDialog is also a child class of CDockablePane. There is no problem in that other CDockablePane is docked to MainFrm. (Tested with SetPaneSize sample from MFC Featurepack sample. )

酸甜透明夹心 2024-07-23 10:51:03

虽然这可能无法再到达原来有需要的人手中。
问题可能是您在 Visual Studio 中添加的资源对话框上的设置。
由于此控件会创建对话框,因此您可能提供给 Create() 方法的任何/所有样式都将被资源文件中的设置覆盖。 确保将可见属性设置为 True,并将透明属性设置为 False。 我这样做了,并且通过 DockPane() 将 CPaneDialog 添加到主框架没有任何问题。

While this may not reach the original people in need anymore.
The issue is likely the settings on the resource dialog you added within Visual Studio.
Since this control results on the creation of a dialog, any/all styles you may have supplied to the Create() method will be overwritten by settings in the resource file. Make sure the visible property is set to True along with Transparent set to False. I did this and had no problems adding a CPaneDialog to the Main Frame via DockPane().

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