CWinApp::OpenDocumentFile creates a new window

久未见 提交于 2019-12-24 00:55:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!