在一个MDI应用程序中,如果创建了多个模板,那么在应用程序运行之后会弹出一个显示模板名字的列表对话框。现在我想让这个对话框不显示,该怎么做?(所有模板中的文档都来自同一类)
      ----------------向最聪明的人请教

解决方案 »

  1.   

    class CSDI_Two_DocApp : public CWinApp
    {
    public:
    CSDI_Two_DocApp();

    CSingleDocTemplate* pDocTemplate;
    CSingleDocTemplate* pDocTemplate2;// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CSDI_Two_DocApp)
    public:
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL// Implementation
    //{{AFX_MSG(CSDI_Two_DocApp)
    afx_msg void OnAppAbout();
    afx_msg void OnFileNew();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
    ----------------------------
    BOOL CSDI_Two_DocApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
    SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings();  // Load standard INI file options (including MRU) // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views. pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CSDI_Two_DocDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CSDI_Two_DocView));
    AddDocTemplate(pDocTemplate); pDocTemplate2=new CSingleDocTemplate(
      IDR_MENU_EDITVIEW,
      RUNTIME_CLASS(CSDI_Two_DocDoc),
      RUNTIME_CLASS(CEditFrame),
      RUNTIME_CLASS(CWriteEdit));
    AddDocTemplate(pDocTemplate2); // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
    if (!ProcessShellCommand(cmdInfo))
    return FALSE; // The one and only window has been initialized, so show and update it.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow(); return TRUE;
    }
      

  2.   

    关键是:
    void CSDI_Two_DocApp::OnFileNew() 
    {
    // TODO: Add your command handler code here
    //you should specify the document template in here!
    pDocTemplate->OpenDocumentFile(NULL)//avoid displaying the selection dialog
    }