做了个Dialog,没有用DoModal,采用无模式窗口。
可是执行完很快就退出了。
我希望它能保留在内存中,响应后面的事件。
谢谢大侠。我试者在App::InitInstance()中加入循环,但是效果不理想,而且不规范。

解决方案 »

  1.   

    CSimpleSignal m_pDlg; m_pDlg.Create(IDD_Signal_Simple);
    m_pDlg.ShowWindow(SW_HIDE);没有用啊。
      

  2.   

    new 一个于heap中就ok了不过要记得DestroyWindow();
    CSimpleSignal* m_pDlg=new CSimpleSignal ;
    m_pDlg.Create(IDD_Signal_Simple);
    m_pDlg.ShowWindow(SW_HIDE);
      

  3.   

    同意 flybusflybus(风) :CSimpleSignal* m_pDlg = new CSimpleSignal ;
    m_pDlg->Create(IDD_Signal_Simple);
    m_pDlg->ShowWindow(SW_HIDE);
      

  4.   

    为什么new就可以了?
    我用new没有任何改善。
    还产生内存泄漏。
      

  5.   

    声明为全局变量,写在InitInstance中也没用。
      

  6.   

    一个建议,把它当作模式对话框处理,结束时EndDialog结束不要用DestroyWindow,处理完你要做的事后再做最后处理工作。EndDialog在这里我把它定义为假关闭,看似结束,其实还在内存中.不妨试上一试.
      

  7.   

    我new咋没问题?另外why内存泄露了?why not delete?
      

  8.   

    CCardConfigApp theApp;
    CSimpleSignal *m_pDlg;BOOL CCardConfigApp::InitInstance()
    {
    TRACE("\n\r\n\rInitInstance()\n\r"); 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 m_pDlg=new CSimpleSignal;
    m_pDlg->Create(IDD_Signal_Simple);
    m_pDlg->ShowWindow(SW_HIDE);
     
    return FALSE;}
      

  9.   

    在DestroyWindow()中加入循环,就行了。
    BOOL CSimpleSignal::DestroyWindow() 
    {
    // TODO: Add your specialized code here and/or call the base class
    TRACE("Destroy Windows Begin\n\r");
    do
    {
    Sleep(100);
    }
    while(!m_Exit); if(m_Exit)
    {
    TRACE("Destroy Window Simple Signal Successful\n\r");
    delete this;
    return CDialog::DestroyWindow();
    }
    else
    {
    TRACE("Not Destroy Window\n\r");
    return FALSE;
    }
    TRACE("Destroy Windows End\n\r");
    }