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