|Sometimes I wonder whether I need a C++ geek or a shrink to solve my coding problems...
(info: I am using Visual Studio .NET 2003 7.1.3008 on Windows XP Pro SP 2)
With the project wizard of my Visual Studio I made an MFC application with multiple documents (MDI). I assigned a file type to my project: .nix (my .nix files are plain text files). In addition to the now automatically created code I added in the Doc an OnOpenDocument reading the first five lines of the openend file, storing them in a list of std::strings. I even added in the View in OnDraw a simple routine that prints those list of stings from the Doc straight to the pDC with TextOut. So far, nothing spectacular.
After starting the application the very first time my file type associations get registered. Afterwards my .nix files have the default icon of my application and are even named correctly. Now when I double-click those files in the Windows Explorer my application starts BUT the .nix file is never read and no document is opened. I can open those files manually with "File" -> "Open..." with my application but the double-click on the file itself never ever works.
When I start my application by double-clicking the .exe everything is fine. But when I start the application by double-clicking an associated file .nix (next to my problem #1) there is a very strange effect: when I simply close the application again the function CWinApp::ExitInstance throws an exception in line 661 of appcore.cpp because CWinapp::m_pCmdInfo has a value of 0x00000001 which obviously is a pointer no nowhere (and having a pointer address of exactly 1 is like winning the lottery, right?!).
As I said, next to my trivial code additions described above this all comes from MFC source files or automatically generated code by the project wizard. It's hard to believe that this code is so bad that it could go so horribly wrong.
I guess a huge amount of other people make MFC MDI applications with associated file types so all those other people should suffer from those problems, too, shouldn't they?! Or is it a problem only for me?! On the other hand I do have the same behaviour of my application on other PCs.
Help needed... (at least moral support...)
P.S.: my little example project can be found here
-- modified at 4:38 Wednesday 7th September, 2005