InitInstance中可以返回参数的,我不知道你的程序是怎么样的。

解决方案 »

  1.   

    非模态对话框需要存在一个父窗口,你可以创建一个父窗口,然后将父窗口隐藏,在cmydlg.Create()创建对话框后,调用cmydlg.ShowWindow(SH_SHOW);即可。
      

  2.   

    需要做几件事!
    1.cmydlg必须是具有全局生命期的(或者与App的生命期内)有效的变量(App成员变量)
      或者采用指针动态生成(new CMyDlg的方式);
    2.InitInstance必须return TRUE;
    3.必须为App的m_pMainWnd赋值如m_pMainWnd = &cmydlg;
    4.对话框的退出代码中要调用PostQuitMessage(your exit code)或者发送WM_QUIT消息;
    5.如果采用指针动态分配(new CMyDlg)的方式,要记得在ExitInstance中将指针删除;
      

  3.   

    需要做几件事!
    1.cmydlg必须是具有全局生命期的(或者与App的生命期内)有效的变量(App成员变量)
      或者采用指针动态生成(new CMyDlg的方式);
    2.InitInstance必须return TRUE;
    3.必须为App的m_pMainWnd赋值如m_pMainWnd = &cmydlg;
    4.对话框的退出代码中要调用PostQuitMessage(your exit code)或者发送WM_QUIT消息;
    5.如果采用指针动态分配(new CMyDlg)的方式,要记得在ExitInstance中将指针删除;
      

  4.   

    需要做几件事!
    1.cmydlg必须是具有全局生命期的(或者与App的生命期内)有效的变量(App成员变量)
      或者采用指针动态生成(new CMyDlg的方式);
    2.InitInstance必须return TRUE;
    3.必须为App的m_pMainWnd赋值如m_pMainWnd = &cmydlg;
    4.对话框的退出代码中要调用PostQuitMessage(your exit code)或者发送WM_QUIT消息;
    5.如果采用指针动态分配(new CMyDlg)的方式,要记得在ExitInstance中将指针删除;
      

  5.   

    把dlg看作一个正常窗口即可,例子代码如下:
    BOOL CDlgApp::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 CDlgDlg *dlg;
    dlg=new CDlgDlg();
    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
    }
    */
    dlg->Create(IDD_DLG_DIALOG,NULL);
    dlg->UpdateWindow();
    dlg->ShowWindow(SW_SHOW);
    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return TRUE;
    }
      

  6.   

    需要做几件事!
    1.cmydlg必须是具有全局生命期的(或者与App的生命期内)有效的变量(App成员变量)
      或者采用指针动态生成(new CMyDlg的方式);
    2.InitInstance必须return TRUE;
    3.必须为App的m_pMainWnd赋值如m_pMainWnd = &cmydlg;
    4.对话框的退出代码中要调用PostQuitMessage(your exit code)或者发送WM_QUIT消息;
    5.如果采用指针动态分配(new CMyDlg)的方式,要记得在ExitInstance中将指针删除;
      

  7.   

    试一下在你的模态对话框OnInitDialog()中激活非模态对话框.
      

  8.   

    ??
    Why? I can't ....
      

  9.   

    不一定需要父窗口!可以在cmyapp类里添加一cmydlg的指针成员,在Cmyapp::InitInstance里为该指针new一把,再Create和ShowWindow,最后在Cmyapp::ExitInstance中释放对话框指针即可!
      

  10.   

    不一定需要父窗口!你可以为Cmyapp添加一个cmydlg的指针成员,在Cmyapp::InitInstance中将该指针new一把,再Create和ShowWindow,并将m_pMainWnd指向该指针即可!最后别忘了在Cmyapp::ExitInstance中释放指针!
      

  11.   

    将Dialog的模板属性改为Visible(在属性框的MoreStyles中)
      

  12.   

    还有一点忘了,你必须在对话框的关闭函数(OnOk、OnCancel)中PostQuitMessage,否则程序无法退出!
      

  13.   

    需要做几件事!
    1.cmydlg必须是具有全局生命期的(或者与App的生命期内)有效的变量(App成员变量)
      或者采用指针动态生成(new CMyDlg的方式);    hjcao_wei的代码就是new出来的;2.InitInstance必须return TRUE;
        hjcao_wei做到;3.必须为App的m_pMainWnd赋值如m_pMainWnd = &cmydlg;
        hjcao_wei做到;4.对话框的退出代码中要调用PostQuitMessage(your exit code)或者发送WM_QUIT消息;
        a8e的方法不全面,最好在重载的EndModalLoop()函数中;5.如果采用指针动态分配(new CMyDlg)的方式,要记得在ExitInstance中将指针删除;
        hjcao_wei没有提出如何删除new的窗口;
    在ExitInstance中加入;
    delete m_pMainWnd;
    m_pMainWnd = NULL;
    (除非你能想办法将Dialog也做成View之类的动态创建删除的类否则就要自己删除以避免Memory Leak,注意:Dialog没有PostNcDestroy的调用)