如何以编程方式关闭MFC中的当前视图 [英] How to programatically close a current view in MFC

查看:125
本文介绍了如何以编程方式关闭MFC中的当前视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在启动时以编程方式关闭MFC中的当前视图?

How to programatically close a current view in MFC at Start up?

推荐答案


而不是关闭它,为什么不首先创建它呢?如果您确实必须进行整个文档/视图操作,则将第一个文档的创建推迟到用户从菜单中选择文件"->新建"或文件"->打开".没有文档,将不会创建视图(和MDI子框架窗口).

文章codeBegins应该为您提供从哪里开始的一些线索,并且,关于MFC的一些好处是,它附带了完整的源代码,因此您可以算出程序初始空文档的创建位置,重写进行创建并停止创建的函数.
Instead of closing it why not create it in the first place? If you really must have the whole document/view thing happening then defer the creation of the first document until the user choose File->New or File->Open from the menu. Without a document the view (and MDI child frame window) won''t be created.

The article codeBegins should give you some clues as to where to start and, one of the few good thing about MFC, is that it comes with full source code so you can work out where program''s initial empty document is created, override the function that does the creation and stop it happening.


尝试一下..

AfxGetMainWnd()-> SendMessage(WM_CLOSE);

AfxGetApp()-> m_pMainWnd-> SendMessage(WM_CLOSE);

PostMessage(hWnd,WM_CLOSE,NULL,NULL);
Try this..

AfxGetMainWnd()->SendMessage(WM_CLOSE);
or
AfxGetApp()->m_pMainWnd->SendMessage(WM_CLOSE);
or
PostMessage(hWnd, WM_CLOSE, NULL, NULL);


这篇关于如何以编程方式关闭MFC中的当前视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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