部分代码:
1.
BOOL CSoft1App::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
 Login *dlg=new Login;
 
 m_pMainWnd = dlg;
 int nResponse = dlg->DoModal();
 if (nResponse != IDOK)
 {
  return FALSE;
 }
 delete dlg;
 CSoft1Dlg dlg2;
 m_pMainWnd=&dlg2;
 dlg2.DoModal();
 return FALSE;
}
2.
void Login::OnOK() 
{
 UpdateData(TRUE);
 if(m_name!="admin"&&m_pas!="888")
 {
 // MessageBox("ok");
  return;
 }
 CDialog::OnOK();
}

解决方案 »

  1.   

    void Login::OnOK() 
    {
     UpdateData(TRUE);
     if(m_name!="admin"&&m_pas!="888")
     {
     // MessageBox("ok");
      return;
     }
     CDialog::OnOK();// 把这个注释掉
    }
      

  2.   

    CWinThread::m_pMainWnd
    Use this data member to store a pointer to your thread’s main window object. The Microsoft Foundation Class Library will automatically terminate your thread when the window referred to by m_pMainWnd is closed. If this thread is the primary thread for an application, the application will also be terminated. If this data member is NULL, the main window for the application’s CWinApp object will be used to determine when to terminate the thread. m_pMainWnd is a public variable of type CWnd*.Typically, you set this member variable when you override InitInstance. In a worker thread, the value of this data member is inherited from its parent thread.      用该成员变量去存储你的线程主窗口对象。当和m_pMainWnd 相关的窗口被关闭后,MFC会自动终止你的线程。如果该线程是应用程序主线程,程序也将会被终止。如果该数据成员为NULL,应用程序CWinApp对象的主窗口将用来决定什么时候去终止线程。m_pMainWnd是一个CWnd*类型的public变量。
      很明显,你需要在重载InitInstance是为m_pMainWnd赋值。在工作线程中,m_pMainWnd自动继承其父线程的值。
      

  3.   

    Sorry,看错了, m_pMainWnd = dlg;这个注释掉
      

  4.   

    不行啊,注释后点击Login对话框的OK按钮就没反应了
      

  5.   

    http://topic.csdn.net/u/20100420/15/a1a07197-8e08-41d6-b4b7-313a73a1492e.html一样的
      

  6.   

    不是注释这个,是把上面的那个
    Login *dlg=new Login;
     
     m_pMainWnd = dlg;注释掉
      

  7.   

    dlg2只是个对话框,什么也没做