在MFC应用程序中创建视图窗口 [英] Creating a view window in a MFC application

查看:107
本文介绍了在MFC应用程序中创建视图窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我创建了一个MDI应用程序,我正在寻找一种方法在MDI框架内创建一个新的视图窗口以响应事件。这是"标准"。 MFC代码实现:

I've created a MDI application and I'm looking for a way to create a new view window inside the MDI frame in reaction to an event. Here is the "standard" MFC code to achieve that:

POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition();
CDocTemplate *pTemplate = AfxGetApp()->GetNextDocTemplate(pos);

CDocument* pDocument = pTemplate->CreateNewDocument();
CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, NULL);
pTemplate->InitialUpdateFrame(pFrame, pDocument, TRUE);

它有效,但我担心调用CreateNewFrame。我调试了它,它每次都会创建一个新的框架窗口。如果我错了,请纠正我,但根据我的理解,框架窗口是创建MDI子窗口的灰色窗格。
一旦应用程序启动,就会创建此框架窗口。那么,我们不应该每个MDI应用程序只有一个框架窗口吗?

It works but I'm concerned about the call to CreateNewFrame. I've debugged it and it creates everytime a new frame window. Correct me if I'm wrong but from what I understand, the frame window is the grey pane within which the MDI child windows are created. And this frame window has already been created once the application starts. So, aren't we supposed to have only one frame window per MDI application?

提前致谢,

Mark

Thanks in advance,
Mark

推荐答案

>它有效,但我担心对CreateNewFrame的调用。我调试了它,它每次都会创建一个新的框架窗口。纠正我,如果我错了,但根据我的理解,框架窗口是灰色窗格,在其中创建MDI子
窗口。一旦应用程序启动,就会创建此框架窗口。那么,我们不应该每个MDI应用程序只有一个帧窗口吗?

>It works but I'm concerned about the call to CreateNewFrame. I've debugged it and it creates everytime a new frame window. Correct me if I'm wrong but from what I understand, the frame window is the grey pane within which the MDI child windows are created. And this frame window has already been created once the application starts. So, aren't we supposed to have only one frame window per MDI application?

嗨Mark,

在MDI中有应用程序的主框架和每个子视图也有一个框架。参见

https://docs.microsoft.com/en-gb/cpp/mfc/tn025-document-view-and-frame-creation 了解更多信息。

In MDI there's the application's main frame and each child view has a frame too. See
https://docs.microsoft.com/en-gb/cpp/mfc/tn025-document-view-and-frame-creation for more information.

Dave


这篇关于在MFC应用程序中创建视图窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆