OK... here goes.... your dialog based app opens in an SDI window - well, which resource is named ID_APP_EXIT ?? Is it the close button on the dialog? These are usually named IDCANCEL - even in pure dialog based apps?
Now I do know that if you have a dialog based app and try and intercept a click on the close button that the application will still exit. I also know that the way to stop this is to not have your p_mMainWnd pointing to the dialog. If you point it to your MainFrame instead then you'll be able to use clas wizard to override the OnCancel() on your dialog and you can do whatever in there.
For your second question, to make a new document open when you launch your application, use the CCommandLineClass. When you create a new MDI project, you'll see an example of this class in use in the InitInstance() function of your app.
You can use this class to open/print any of your app's documents whether they be templates or whatever, and all this without opening another instance of your app like ShellExecute does.
You can also prevent your app from opening a blank document at launch by doing this:
[tt]
CCommandLineInfo cmdInfo;
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo)) return FALSE;
[/tt]
programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.