MFC MDI 选项卡式应用程序 - 想要将非文档窗口添加到选项卡组
我有一个在 Visual Studio 中开发的具有选项卡式界面的 MFC MDI 应用程序。我想在选项卡组中打开非文档视图的视图 - 即它们没有关联的文档,无需保存它们等。在某种程度上,它们的行为类似于非模式对话框,但带有选项卡。 [这些窗口只是为了显示信息和接受命令]
MDI 应用程序的内部机制似乎非常适合使用 DocTemplate – 文档 – 框架 – 视图对象结构及其关联的窗口。
Q1) 有人知道如何创建此类窗口并将它们添加到已经建立的 MDI 选项卡组中吗?我尝试创建一个 RichEdit 窗口并将其添加到其中:
// m_wndListingView will be a non-editable CRichEditCtrl
m_wndListingView->Create(WS_CHILD | WS_VISIBLE | ES_WANTRETURN | WS_VSCROLL |
WS_HSCROLL | ES_MULTILINE | ES_LEFT | ES_AUTOHSCROLL | ES_SAVESEL |ES_READONLY,
CRect(0, 0, 20, 20), pMainFrame, 1234);
// get Tab control and add a new tab
CMFCTabCtrl *mm_wndTabCtrl = &pMainFrame->GetMDITabs();
mm_wndTabCtrl->AddTab (m_wndListingView, _T("LISTING"));
这创建并显示了窗口..但它没有添加到选项卡组中。
Q2)如果我设法在选项卡组中正确显示一个窗口(也许它需要是一个框架窗口),我如何告诉“系统”当用户关闭它时,我不希望应用程序提示用户保存文档?也许我可以重载“OnClose”方法...但它不能是 document::OnClose(),因为没有文档。
感谢您的任何想法, 中科院
I have an MFC MDI application I've developed in Visual Studio with a tabbed interface. I would like to open views in the tab group that are non-document views – i.e. they have no associated document, no need to save them, etc. In a way they would behave like a non-modal dialog, but tabbed. [These windows are simply to display information and take commands]
The internal machinery of the MDI apps seems very geared toward working with the DocTemplate – Document – Frame – View object structures along with their associated windows.
Q1) Anybody got any ideas on how to create such windows and add them into the already-established MDI tab group? I’ve tried to create a RichEdit window and added it in, with:
// m_wndListingView will be a non-editable CRichEditCtrl
m_wndListingView->Create(WS_CHILD | WS_VISIBLE | ES_WANTRETURN | WS_VSCROLL |
WS_HSCROLL | ES_MULTILINE | ES_LEFT | ES_AUTOHSCROLL | ES_SAVESEL |ES_READONLY,
CRect(0, 0, 20, 20), pMainFrame, 1234);
// get Tab control and add a new tab
CMFCTabCtrl *mm_wndTabCtrl = &pMainFrame->GetMDITabs();
mm_wndTabCtrl->AddTab (m_wndListingView, _T("LISTING"));
This created and displayed the window .. but it was not added to the tab group.
Q2) If I managed to get a window (perhaps it needs to be a frame window) displayed properly in the tab group, how do I tell the ‘system’ that when the user closes it, I do not want the app to prompt the user to Save the document ? Perhaps I can overload an 'OnClose' method ... but it can't be document::OnClose(), because there is no document.
Thanks for any ideas,
CAS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要创建一个框架和视图来托管丰富的编辑。这可以在没有文档的情况下完成。该视图将是 richedit 的父视图(而不是 pMainFrame)。
沿着这些思路(警告,未经测试):
You need to create a frame and view on which to host your rich edit. This can be done without a document. The view will be the parent of the richedit (rather than pMainFrame).
Something along these lines (warning, untested):