我定义了一个MFC基于对话框的工程并自行增加了不少对话框,问题是这些对话框
中哪个是主对话框?也就是说我想其中的一个对话框在我运行该工程时首先出现,
请问该在哪里添加代码以指明启动对话框?请赐教!

解决方案 »

  1.   

    BOOL CTreeApp::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 CTreeDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    // TODO: Place code here to handle when the dialog is
    //  dismissed with Cancel
    } // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
    }
    注意:
    CTreeDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    这三行便显示的是主对话框,
    以上代码都是模板自动生成的
      

  2.   

    MFC基于对话框的工程本身会自动生成一个对话框,那个就是你运行该工程时首先出现的对话框。
    其它的对话框一定需要你调用才能够出现。
      

  3.   

    MFC基于对话框的工程本身会自动生成一个对话框,那个就是你运行该工程时首先出现的对话框。
    其它的对话框一定需要你调用才能够出现。
    /*********************************************************************************/
    注意:
    CTreeDlg dlg;
    m_pMainWnd = &dlg;
    int nResponse = dlg.DoModal();
    /*********************************************************************************/
    同意以上两段。
      

  4.   

    MFC基于对话框的工程本身会自动生成一个对话框,这个就是你运行这个工程最先出现的对话
    框,其它的对话框一定要你调用它才能够出现.
      

  5.   

    其实,你想要做启动画面的时候,最好用它自带的一个控件,名字叫Splash screen。
      

  6.   

    或者你可以在CMyApp::InitInstance()中,在dlg.DoModal()之前调用你的对话框,然后通过点击、Esc或者时间来控制它消失。
      

  7.   

    首先,你要为你的对话框生成一个类,比如:CMyDlg.
    然后,把这行:
    CTreeDlg dlg;
    改为:
    CMyDlg dlg;
    再包含进相应的头文件:
    #include "MyDlg.h"
    就可以了。
    我试验过了,没问题。