问题
Recently we moved our C++ project, which uses MFC, from VS2008 to VS2010.
And there is a small issue: in our MDI interface, after we call a function CWinApp::OpenDocumentFile, the app not only opens the file, but also creates a new empty MDI window.
If we change the toolset (Project properties -> General -> Platform toolset) back to v90 (VS2008), we do not experience this problem.
Maybe someone saw the same issue and knows, what we are doing wrong?
回答1:
Solved. maybe the explanation will help someone:
The problem was in MFC function:
CDocument* CDocManager::OpenDocumentFile(LPCTSTR lpszFileName)
in VS2008 it called a function
return pBestTemplate->OpenDocumentFile(szPath);
in VS2010 it calls another function (with different number of parameters)
return pBestTemplate->OpenDocumentFile(szPath, bAddToMRU, TRUE);
which we didn't override in our own implementation of CMultiDocTemplate
回答2:
effectively there is a change in the file docmgr.cpp which calls the opendocumentfile function.
if you derived a class from CMultiDocTemplate watch out for this changes.
In fact your post helped me to find an error in my application.
来源:https://stackoverflow.com/questions/14363383/cwinappopendocumentfile-creates-a-new-window