Sign in to follow this  

MFC program asking for "New..." (instance?) upon startup?

This topic is 3774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

OK... I've got an odd problem that is bugging the hell outta me. Recently, my MFC program has started doing something I haven't seen before. When I run from within VC++ 6, it pops up a dialog asking me for "New". That's it. It doesn't say what is supposed to be "new." It lists 2 things for me to select from - one of which is the actual exe and project name ("ATM"). The other seems to be related, but I can't figure out where it is getting the string from ("Gameln"). Regardless, the program only works properly when I select the real name, otherwise it hangs. I've traced execution from the beginning and found that it pops up this dialog at the following location in WINMAIN.CPP - (line 39) if (!pThread->InitInstance()) It seems that whatever "InitInstance" is doing, it needs to ask me for that instance in order for it to continue. Another odd issue, however, is that I can't set a debug breakpoint anywhere in the program other than in WINMAIN.cpp. If I try, it gives me the error of "One or more breakpoints have been disabled." This means that I can't debug anything in the actual execution of my program. What "instance" is it creating, why is it asking me for it and how do I make it go away? [Edited by - InnocuousFox on August 14, 2007 10:08:49 PM]

Share this post


Link to post
Share on other sites
Ah, this sounds like the doc template manager jumping in.

Did you recently play with AddDocTemplate? If there's more than one and you choose "New Document" (which MFC apps can do on startup automatically) it doesn't know which document type it's supposed to open. That's where this fugly Dialog comes up.

If you still have only one AddDocTemplate call maybe the string table for the document descriptions is messed up. If i recall right there's a string table entry carrying the default extension, document description and such. There's a page in the MSDN telling which of the parts of that string mean what.

Share this post


Link to post
Share on other sites
It may very well have started when I was dorking with a new document. The question is, how do I get it to go away? I HATE MFC but had a contractor build this framework for me as a test bed. Now I'm stuck maintaining it which I can do for the most part, but I get lost at times. At least I know about where to look - but not what I'm looking for necessarily. Any thoughts?

Share this post


Link to post
Share on other sites
As said, try if you can find that other AddDocTemplate call (probably in the InitInstance function of the App). It has to be a second document type being added.
Alternatively look where that template is created, search for "new CMultiDocTemplate(".

If you want to go hardcode you could try to mess up the resource string entry for that second template. It does display a name in the dialog box? Look for it in the resource explorers string table. Rename it's ID constant. If i remember right the document manager will ASSERT if it can't find the string entry. The stack trace at that point should show you where that template is added.

Do you have the MFC source code installed? If so, it'll help tremendously to step into the InitInstance function down where it starts the dialog. There code is commented so you might find the cause better that way. - Nevermind, just read, that there's a problem with debugging.

Share this post


Link to post
Share on other sites

This topic is 3774 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this