Search code examples
c++visual-studio-2010visual-studio-2008mfcmdi

CWinApp::OpenDocumentFile creates a new window


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?


Solution

  • 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