In CMyAPP::InitInstacne () after m_pMainWnd->ShowWindow(),Add SendMessage(null,WM_COMMAND,ID_FILE_CLOSE,0);

解决方案 »

  1.   

    你自己可以实现,在App中响应New的消息。
      

  2.   

    在CMyAPP::InitInstacne ()函数中加以下代码:
    // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    //新增加的代码
    cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    //增加完成
    // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE;
      

  3.   

    void CCcccApp::OnFileNew() 
    {
    // TODO: Add your command handler code here

    CCcccApp * pApp = (CCcccApp *)AfxGetApp();
    CMultiDocTemplate * pDocTemplate = pApp->m_pCcccDocTemplate;//模板 CCcccDoc * pDocument = (CCcccDoc *)pDocTemplate->CreateNewDocument(); //产生编辑文档
    if (pDocument == NULL)
    {
    TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
    AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
    return ;
    }
    ASSERT_VALID(pDocument); BOOL bAutoDelete = pDocument->m_bAutoDelete;
    pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
    CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(pDocument, NULL);
    pDocument->m_bAutoDelete = bAutoDelete;
    if (pFrame == NULL)
    {
    AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
    delete pDocument;       // explicit delete on error
    return ;
    }
    ASSERT_VALID(pFrame); BOOL bMakeVisible = TRUE; pDocTemplate->SetDefaultTitle(pDocument); // avoid creating temporary compound file when starting up invisible
    if (!bMakeVisible)
    pDocument->m_bEmbedded = TRUE; if (!pDocument->OnNewDocument())
    {
    // user has be alerted to what failed in OnNewDocument
    TRACE0("CDocument::OnNewDocument returned FALSE.\n");
    pFrame->DestroyWindow();
    return ;
    } // it worked, now bump untitled count
    //pDocTemplate->m_nUntitledCount++; pDocTemplate->InitialUpdateFrame(pFrame, pDocument, bMakeVisible);
    }
      

  4.   

    同意River_H(小河):
    ......
    ParseCommandLine(cmdInfo);//MFC加的//{{你应插入的地方
    if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) 
        cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
    //}}你应插入的地方完if (!ProcessShellCommand(cmdInfo))//MFC加的
    .....
      

  5.   

    后半部分你要自己创建模版。
    建立文档后用指定的模版打开视图
    比如:
    BOOL CHmidesApp::InitInstance()
    {
    .................
    pDocTemplate = new CMultiDocTemplate(
    IDR_HMIDESTYPE,
    RUNTIME_CLASS(CHmidesDoc),
    RUNTIME_CLASS(CPicFrm), // custom MDI child frame
    RUNTIME_CLASS(CPicView));
    m_pPicDocTemplate=pDocTemplate;
    ....................
    }void CHmidesDoc::OpenPicView(CPicObj *pPic)
    {
    POSITION posview;
    CView *pView;
    CPicView *pPicView;
    posview=this->GetFirstViewPosition();
    while(posview!=NULL)
    {
    pView=this->GetNextView(posview);
    if(pView->IsKindOf(RUNTIME_CLASS(CPicView)))
    {
    pPicView=(CPicView *)pView;
    if(pPicView->m_pPic==pPic)
    {
    ((CPicFrm *)(pView->GetParent()))->ActivateFrame();
    return;
    }
    }
    } CPicFrm* pFrame = (CPicFrm*)((CHmidesApp *)AfxGetApp())->m_pPicDocTemplate->CreateNewFrame(this, NULL);
    if (pFrame == NULL)
    {
    TRACE0("Warning: failed to create new frame.\n");
    return;     // command failed
    }

    pPicView=(CPicView *)pFrame->GetWindow(GW_CHILD);
    pPicView->m_pPic=pPic;
    pPicView->m_pCurLayer=pPic->m_Layer.GetHead();

    ((CHmidesApp *)AfxGetApp())->m_pPicDocTemplate->InitialUpdateFrame(pFrame, this);
    }自己建立的模版不要加入到模版表,
    退出视将模版删掉,免得内存遗留。