Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 438
Alek86 Avatar asked Jul 24 '26 09:07

Alek86


1 Answers

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

like image 53
Alek86 Avatar answered Jul 26 '26 03:07

Alek86



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!