将控制栏/窗格停靠到 CMDIFrameWndEx?
在我们的一个应用程序中,我使用了一些 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这就是我在
CMainFrame::OnCreate
中所做的事情:我的
m_projectsPane
是一个类,然后捕获ON_WM_GETMINMAXINFO
来填充ptMinTrackSize
(以确保用户无法将对话框的大小调整到低于某个最小值)。 我在代码中没有看到任何其他内容,并且停靠窗格的大小调整工作正常。This is what I do as part of my
CMainFrame::OnCreate
:My
m_projectsPane
is a class that then catchesON_WM_GETMINMAXINFO
to fillptMinTrackSize
(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.如果我们都在黑暗中射击,我们击中物体的机会就会加倍。
查看 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.
我仍然无法将 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. )
虽然这可能无法再到达原来有需要的人手中。
问题可能是您在 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().