fileSave,fileOpen,fileSaveAs

How to invoke OnFileSaveAs() instead of OnFileSave() for the first Save of a New file?

http://social.msdn.microsoft.com/Forums/vstudio/en-US/685ad2b9-700c-4fa1-9c02-a47954baa7ae/how-to-invoke-onfilesaveas-instead-of-onfilesave-for-the-first-save-of-a-new-file?forum=vcmfcatl

 

DoFileSave sometimes display a Save As dialogbox.

To decide whether a File Save Dialog should be displayed or not, CDocument::DoFileSave checks is m_strFileName is an existing file name, and if it has write access to this file.

For a new document, m_strFileName is empty the first time Save is called. So, DoFileSave displays a File Save dialog since m_strFileName isn't an existing valid file name with write access.

 

 TN022: Standard Commands Implementation

http://msdn.microsoft.com/en-us/library/vstudio/11861byt(v=vs.100).aspx

 

OnFileNew()/OnFileOpen()的MFC代码跟踪简析

http://blog.csdn.net/hczhiyue/article/details/6227997

 

M​F​C​ ​O​n​F​i​l​e​N​e​w​ ​O​n​F​i​l​e​O​p​e​n​过​程​分​析

http://wenku.baidu.com/view/bef3981a6bd97f192279e9f9.html

 

关于OnFileNew()的定制(转) 

http://zhichengma2007.blog.163.com/blog/static/5892162920091110105153995/

 

http://www.itlisting.org/5-windows/50d8b6221018bd19.aspx

I think your missing the point a little bit. 

quick overview: 

your CWinApp object contains a member variable called m_pDocManager which 
is a pointer to a CDocManager object. your documents are Managed by this 
class and actually created by the CDocTemplate class. CDocManager contains 
a list of CDocTemplate objects that have been created using the 
SingleDocTemplate() or MultiDocTemplate() functions. Once these templates 
have been created, they must be registered using the AddDocTemplate() 
function of CWinApp. the CWinApp::AddDocTemplate() simply adds your newly 
created CDocTemplate to the list in CDocManager. 

The OnFileNew() virtual function exists in both CWinApp and CDocManager. 
CWinApp::OnFileNew actually calls the CDocManager::OnFileNew who then 
determines which CDocTemplate object to use. The actual document is the 
created with a call to CDocTemplate::OpenDocumentFile(NULL). OnFileNew() 
does NOT exist in any of your CDocument objects. 
Do not get OnFileNew() confused with CDocument::OnNewDocument(). The 
OnNewDocument() function gets called during the construction process I 
outlined above. 

For combining the Two apps, you have to create two CMultiDocTemplate 
objects and the register them using the AddDocTemplate(). this is usually 
done in you CWinApp::InitInstance() virtual function. Once registered you 
can either customize construction of the CDocument object by overriding 
CWinApp::OnFileNew() or use the framework. I think the framework will 
prompt you for the CDocument type you want to create if you have 
registered more that one CMultiDocTemplate. If this is not the 
functionality you desire, override the CWinApp::OnFileNew(). 

One last thing, CDocManager is not documented anywhere, but thats not too 
important because you still do everything through the CWinApp. 

I suggest reading up in the Doc/View architecture of MFC. 
regards, 

 

MFC教程(5)-- MFC对象的创建(1)(11)

http://www.bianceng.cn/Programming/vc/201003/16103_11.htm

 

 

 

转载于:https://www.cnblogs.com/guxue365/p/3703805.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值