CWinApp::OpenDocumentFile creates a new window

2019-07-20 03:02发布

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?

2条回答
Anthone
2楼-- · 2019-07-20 03:07

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

查看更多
Lonely孤独者°
3楼-- · 2019-07-20 03:26

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.

查看更多
登录 后发表回答