Everhart,Glenn From: Lee Abrahamson [labraham@sntc.com] Sent: Wednesday, April 15, 1998 6:44 PM To: Sherri Scharf-ESS013 Cc: ntdev@atria.com Subject: RE: [ntdev] SDI app opening doc on startup I had the same problem, I looked for some set amount of time throughout the MFC code for a way to turn this off but did not find any good way. After stepping through this code I found that an OnFileNew is auto-generated at the beginning. I subclassed CDocManager (called it DocManager) and overrode (is that a word?) the OnFileNew method. Basically I let the first OnFileNew arrive and ignored it. I also set a boolean in my subclass to remember that 1 OnFileNew has arrived and subsequent OnFileNew's should behave as expected. Here's the code example: MYDOCMGR.H class DocManager : public CDocManager { DECLARE_DYNAMIC(DocManager) public: DocManager(); ~DocManager(); // Override. void OnFileNew(); private: BOOL bOFNarrived; }; MYDOCMGR.CPP DocManager::DocManager() { bOFNarrived = FALSE; } void DocManager::OnFileNew() { // We have subclassed the Document Manager in order to control // the way documents are created. if (!bOFNarrived) // Let the app init OnFileNew be ignored bOFNarrived = TRUE; else { if (m_templateList.IsEmpty()) { TRACE0("Error: no document templates registered with CWinApp.\n"); AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC); return; } CDocTemplate* pTemplate; pTemplate = (CDocTemplate*)m_templateList.GetHead(); ASSERT(pTemplate != NULL); ASSERT_KINDOF(CDocTemplate, pTemplate); pTemplate->OpenDocumentFile(NULL); } } Look in DOCMGR.CPP in DEVSTUDIO\VC\MFC\SRC for their version of this method. I also removed the check for multiple document templates. I have a few more things in here that don't apply to your problem so I left them out of this example. My app is an MDI app so I give this solution no absolute guarantees. I think if you see their OnFileNew code you will figure out what you have to do. Lee Abrahamson Switched Network Technologies Labraham@sntc.com ---------- From: Sherri Scharf-ESS013 [SMTP:Sherri_Scharf-ESS013@email.mot.com] Sent: Wednesday, April 15, 1998 1:21 PM To: 'ntdev@atria.com' Subject: [ntdev] SDI app opening doc on startup Hi, please forgive a newbie MFC question. I am developing an SDI application, and when the application opens, by default it seems to create an empty doc and come up with it open. I do not want that to happen--I want it to come up empty so the user has to explicitly do something to create a doc. We were able to partially solve this by replacing if (!ProcessShellCommand(cmdInfo)) return FALSE; in InitInstance with if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; but the problem now is that when I open a file, it brings up a whole new main frame instead of opening it within the same window. Is what I am trying to do even possible? Any suggestions would be greatly appreciated! Thanks, Sherri Sherri Scharf Software Engineer Motorola, Land Mobile Products Sector - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ To unsubscribe, send email to ntdev-request@atria.com with body UNSUBSCRIBE (the subject is ignored). ]