- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在我的 MFC(功能包)应用程序中,可以动态创建停靠 Pane 以显示图表/表格等。
但是,我不想让用户打开同一个东西两次。
我创建了这样一个 Pane :
// Create CMyDockablePane pPane
pPane->Create(...);
pPane->EnableDocking(CBRS_ALIGN_ANY);
// Create CRect rcPane
pPane->FloatPane(rcPane);
这似乎工作正常。
这就是我尝试检查 Pane 是否已存在的方式。 Pane 由其类型(类)和参数标识。
BOOL CanOpenPane(const type_info & paneType, const CMyParameter & parameter) const
{
CMainFrame* pFrm = GetMainFrame();
CDockingManager* pDockMan = pFrm->GetDockingManager();
// Check if there already is a pane of the same type which also has the same parameter.
bool canOpen = true;
CObList panes;
pDockMan->GetPaneList(panes);
POSITION pos = panes.GetHeadPosition();
while (pos)
{
CMyDockablePane* pPane = dynamic_cast<CMyDockablePane*>(panes.GetNext(pos));
if (NULL == pPane) { continue; }
if (paneType == typeid(*pPane) &&
pPane->GetParameter() == parameter)
{
canOpen = false;
break;
}
}
return canOpen;
}
问题是当我关闭一个 Pane 时,它无法被识别。 CDockingManager 对象仍然在 GetPanes() 调用中返回 Pane 。
我如何告诉经理不要返回已关闭的 Pane ?
或
当 Pane 关闭时,如何从 Pane 列表中删除该 Pane ?
我深入研究后发现,当单击标题栏中的“x”按钮时,CWnd 对象实际上并未关闭,而只是关闭了它们的容器。
所以真正的问题似乎是真正关闭 Pane 。
我还更改了问题以更好地反射(reflect)问题。
最佳答案
如我的更新所述,停靠管理器给我关闭 Pane 的问题是这些 Pane 实际上并未关闭。只有他们的容器是封闭的; Pane 本身只是隐藏起来的。
因此,为了真正关闭 Pane ,我在 CMDIFrameWndEx
派生的主框架类中覆盖了以下方法:
BOOL CMainFrame::OnCloseMiniFrame(CPaneFrameWnd* pWnd)
{
if(0 == pWnd->GetPaneCount()) { return TRUE; } // No panes.. allow closing
// Close all child panes of the miniframe that is about to be closed.
//
// Panes are placed inside a mini frame when they have the "floating" status.
// Since I didn't find a way to iterate over the panes of a mini frame
// (CMultiPaneFrameWnd can have several panes), we iterate over all panes
// and close those whose parent frame is pWnd.
CDockingManager* pDockMan = GetDockingManager();
if(NULL != pDockMan)
{
CObList allPanes;
pDockMan->GetPaneList(allPanes, TRUE, NULL, TRUE);
for(POSITION pos = allPanes.GetHeadPosition(); pos != NULL;)
{
CDockablePane* pPane = dynamic_cast<CDockablePane*>(allPanes.GetNext(pos));
if (NULL == pPane) { continue; }
if(pWnd == pPane->GetParentMiniFrame())
{
pPane->PostMessage(WM_CLOSE); // Note: Post instead of Send
}
}
}
return TRUE; // Allow closing
}
第二个:
BOOL CMainFrame::OnCloseDockingPane(CDockablePane* pWnd)
{
CObList paneList;
// We can get CDockablePanes and CTabbedPanes here.
// The tabbed panes contain dockable panes.
CTabbedPane* pTabbed = dynamic_cast<CTabbedPane*>(pWnd);
CDockablePane* pDockable = dynamic_cast<CDockablePane*>(pWnd);
if(NULL != pTabbed)
{
pTabbed->GetPaneList(paneList);
}
else if(NULL != pDockable)
{
paneList.InsertAfter(paneList.GetHeadPosition(), pDockable);
}
// Whatever it was, we now have a list of dockable panes, which we will close.
for(POSITION pos = paneList.GetHeadPosition(); NULL != pos;)
{
CDockablePane* pPane = dynamic_cast<CDockablePane*>(paneList.GetNext(pos));
ASSERT(NULL != pPane);
// Let the window disappear and then recalculate the layout.
// Not doing this causes problems with panes grouped together in a tabbed pane.
pPane->ShowWindow(SW_HIDE);
RecalcLayout();
// Really close the window so the docking manager also doesn't know of it anymore.
pPane->Reset();
pPane->PostMessage(WM_CLOSE); // Note: Post instead of Send
}
return TRUE; // Allow closing
}
关于c++ - 如何关闭动态创建的 CDockablePane 窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1333801/
我有 3 个可停靠 Pane ,每个 Pane 包含 1 张图像。一个在左边,一个在右边,一个不可见。问题是,我想默认隐藏右边的那个,让左边的占据整个空间。我搜索了文档,发现我应该在我的 Pane 中
我可以从CDockablePane 中隐藏关闭按钮 并防止它关闭吗?我在刚刚用谷歌搜索的 header 中找不到 CanBeClosed 方法。我想我可以使用 PreTranslateMessage
我启动了一个单文档 MFC 项目,并创建了两个 CDockablePane。 我遇到的问题是,如果我移动或调整 Pane 大小并退出程序,当我重新启动程序时它们的布局不会重置。他们的布局保持修改。 我
我有一个使用 Visual Studio 2008 实现的单文档 MFC 项目。 这是我遇到的问题的图片。为了您的安全,此图像已被编辑。 如果图像没有加载到您的网络浏览器中,这里是它的 ASCII 渲
我正在升级一个旧的 MFC 项目以使用 MFC 功能包和功能区。我将派生自 CControlBar 的 Pane 更改为派生自 CDockablePane 并且效果很好,但它看起来仍然很旧并且不与功能
我正在移植一个 MFC 应用程序以使用 Ribbon UI 和 MFC 功能包,并希望有一个不包含标题的停靠水平 Pane 。我希望像 MyPane.ModifyStyle(WS_CAPTION, 0
我正在 Visual Studio 2012 上编写 SDI 应用程序。MFC 向导生成了两个 CDockablePane 派生对象。右侧的 CPropertiesWnd(CDockablePane
我想在我的 MDI 子窗口中创建两个 CDockablePane 对象。最初,它们应该停靠在底部,但用户可以 float 它们。我从 MFC 项目向导创建的代码开始。然后,我将代码从表示主框架的类移动
在我的 MFC(功能包)应用程序中,可以动态创建停靠 Pane 以显示图表/表格等。 但是,我不想让用户打开同一个东西两次。 我创建了这样一个 Pane : // Create CMyDockable
我想在 CDockablePane 中托管对话框项目,例如 slider 、按钮和编辑框。我想将它们分组,每个都有单独的下拉列表,如下图所示。 MFC中是否有一些类来实现它? 最佳答案 CMFCTas
我需要将 CView 派生类放入 CDockablePane 中。某处有任何代码示例,或者有人可以提供这样的代码吗? 我尝试过的: 显然应该很简单,我在网上找到了诸如“只需创建 View 并将其父项设
我正在做一个完全不想使用MFC内置的window/dock状态和位置保存的项目。这意味着在我的主框架中,我设置了 EnableLoadDockState(FALSE)。尽管我很想将其改回 TRUE,但
如何强制刷新 MFC 功能包中 CDockablePane 的标题?我正在使用选项卡式 Visual Studio 样式示例,并且我想更改选项卡的标题。 这些似乎被缓存在某个地方,因为当我更改默认值时
我有一个 CDockablePane,它包含一个基于 CTreeCtrl 的自定义控件。 当我移动 CDockablePane 时,所有内容都会正确刷新。当我调整 CDockablePane 的大小时
所以我想采用我正在处理的当前程序并使所有内部窗口都可以停靠。唯一的问题是它们扩展了一个名为 CFBView 的类,该类扩展了 CView。如果我也扩展 CDockablePane,它将导致无法正确编译
我在 CDockablePane 中创建了 CMFCPropertyGridCtrl,我想用一个新的替换这个 CMFCPropertyGridCtrl,然后我覆盖 OnEraseBkgnd。OnEra
如何将 MFC CFormView 放置在 VS 2008 MFC 功能包中引入的 CDockablePane 中? 最佳答案 检查 BCGSoft使用 cview 执行此操作的示例。类名略有不同,但
我是一名优秀的程序员,十分优秀!