如何将 CPaneDialog 停靠到 MainFrm 并..?

发布于 2024-08-13 23:15:46 字数 448 浏览 2 评论 0原文

我的 CPaneDialog 有问题。 我使用 SetPaneSize MFC 功能包示例项目进行了测试。奇怪的是 CPaneDialog 不能停靠到 MainFrm,而 CDockablePane 可以。 CPaneDialog 也是 CDockablePane 的子类,但事实并非如此。 只有 DockToWindow( &other_CPaneDialog_instance... ) 是可能的。 如果我调用 DockToPane(),CPaneDialog 的内容不会正确绘制或刷新。

如何将 CPaneDialog 停靠到 MainFrm 窗口?

另一个问题是关于绘图。如果删除 SetPaneSize 示例中树控件的代码,则 view1(CDockablePane 的实例)的内容不会正确重绘。 经过一些实验后,我决定应该在其 OnSize 和 OnPaint 方法中做一些事情。 (OnSize 更为关键。)这是预期的行为吗?

I have problem with CPaneDialog.
I tested with SetPaneSize MFC feature pack sample projects. What is weird is that CPaneDialog can't be docked to MainFrm while CDockablePane can be. The CPaneDialog is also a child class of the CDockablePane, but it can't be.
Only DockToWindow( &other_CPaneDialog_instance... ) is possible.
If I call DockToPane(), the content of the CPaneDialog is not drawn or refreshed correctly.

How can a CPaneDialog be docked to MainFrm window?

Another problem is about drawing. If remove codes for tree control in the SetPaneSize sample, the content of the view1 ( an instance of CDockablePane) is not redrawn properly.
After doing some experiment, I decided that something should be done in its OnSize and OnPaint method. (OnSize is more critical. ) Is this expected behaviour?

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

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

发布评论

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

评论(2

儭儭莪哋寶赑 2024-08-20 23:15:46

在转换较旧的 MFC 应用程序时,我遇到了与功能包类似的问题。我没有时间正确解决它,但我使用了以下解决方法:

  1. 获取对话框资源并将其放入 CDialogBar 类中。
  2. 现在在窗格的 OnCreate 方法中从 CDockablePane 派生一个类
  3. ,创建对话框。

还有两件事:

void CInputPane::OnSize(UINT nType, int cx, int cy)
{
    CDockablePane::OnSize(nType, cx, cy);
    m_pInputBar->SetWindowPos(NULL,0,0,cx,cy,SWP_NOACTIVATE | SWP_NOZORDER);
}

BOOL CInputPane::OnBeforeFloat(CRect& /*rectFloat*/,AFX_DOCK_METHOD /*dockMethod*/)
{
    return FALSE;
}

这可以确保对话框的大小正确并防止用户拖动栏。

HTH,这对我有用。

While converting an older MFC-application I ran into similar problems with the feature pack. I didn't have the time to solve it correctly, but I used following workaround:

  1. take your dialog resource and put it in a CDialogBar class.
  2. now derive a class from CDockablePane
  3. in the OnCreate-method of the pane, create your dialogbar.

2 more things:

void CInputPane::OnSize(UINT nType, int cx, int cy)
{
    CDockablePane::OnSize(nType, cx, cy);
    m_pInputBar->SetWindowPos(NULL,0,0,cx,cy,SWP_NOACTIVATE | SWP_NOZORDER);
}

BOOL CInputPane::OnBeforeFloat(CRect& /*rectFloat*/,AFX_DOCK_METHOD /*dockMethod*/)
{
    return FALSE;
}

This assures proper sizing of the dialog and preventing the user from dragging the bar around.

HTH, it worked for me.

记忆之渊 2024-08-20 23:15:46

将 HexEdit 转换为 MFC9(请参阅 http://www.hexedit.com)我遇到了这个问题。我在VS2010(MFC10)中测试过,这个bug似乎已经被修复了。

另请注意,这个问题并不是主要问题,因为您可以在 CMainFrame::OnCreate 中使用 DockToWindow 来停靠到 CDockablePane(如果有的话)。用户可以浮动窗口或将其停靠在其他位置,重新打开程序时将记住并恢复该位置。

我很确定有人对 MFC9 中的这个错误不熟悉 - 因此 SetPaneSize 演示中的明显解决方法(调用 CDockablePane::DockToWindow 而不是用于所有其他可停靠窗口的 DockPane)。但至少在MFC10中是固定的。

我发现的另一个错误是,如果 CPaneDialog 在关闭(隐藏)时浮动,那么当您重新启动应用程序时,窗格将重新打开,而不是恢复到正确(隐藏)状态。如果窗格在关闭时停靠,则不会发生这种情况。 MFC10 中也已修复此问题。

Converting HexEdit to MFC9 (see http://www.hexedit.com) I ran into this problem. I tested in VS2010 (MFC10) and this bug appears to have been fixed.

Also note that this problem is not a major thing as you can just use DockToWindow in CMainFrame::OnCreate to dock to a CDockablePane (if you have one). The user can float the window or dock it elsewhere and the position will be remembered and restored when the program is re-opened.

I am pretty sure someone new about this bug in MFC9 - hence the obvious workaround in the SetPaneSize demo (calling CDockablePane::DockToWindow rather than DockPane as was used for all the other dockable windows). But at least it is fixed in MFC10.

Another bug I found is that if a CPaneDialog is floating when closed (hidden), then when you restart the application the pane is reopened, rather than being restored in the correct (hidden) state. This does not occur if the pane is docked when closed. This has also been fixed in MFC10.

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