BOOL CCxSkinButtonDemoApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CCxSkinButtonDemoDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
} // Since the dialog has been closed, return FALSE so that we exit the
//  application, rather than start the application's message pump.
return FALSE;
}

解决方案 »

  1.   

    App文件里的初始化函数。
    CCxSkinButtonDemoDlg dlg;     //为打开对话框设置一个对话框变量
    m_pMainWnd = &dlg;            //m_pMainWnd是“Microsoft Visual Studio\VC98\MFC\Include\AFXWIN.H”里的CWinThread类的一个公共变量
    //以后直接用m_pMainWnd,就是对话框的CWnd*类句柄了。
    int nResponse = dlg.DoModal();     //打开对话框
    if (nResponse == IDOK)     
    {     }     
    else if (nResponse == IDCANCEL)     
    {     } 
      

  2.   

    MSDN上关于m_pMainWnd有段说明:
    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*. 
      

  3.   

    //m_pMainWnd = &dlg;去掉这句话下面if(nResponse == IDOK)语句就会弹出对话框,不去掉这句话,就弹不出来
    之前,看msdn的解释是,应用程序线程会代替cwinapp对象,来释放线程? 
    int nResponse = dlg.DoModal();     //打开对话框
    if (nResponse == IDOK)     
    {  AfxMessageBox("upspring!");   }     
    else if (nResponse == IDCANCEL)     
    {     } 
      

  4.   

    m_pMainWnd 你可理解为C程序的main(其实不是)。你建立的是MFC对话框,所以,肯定要找到入口嘛,m_pMainWnd是主窗口指针,可以找到主窗口(窗口有函数入口和对应的函数相应路径)