CFileDialog FilePathDlg( TRUE, "ini", "*.ini", OFN_HIDEREADONLY, "ini", this ); //打开文件对话框
if ( FilePathDlg.DoModal( ) == IDOK )
{
m_ActionIni->FilePath = FilePathDlg.GetPathName( );
}
else
{
return;
}这段代码在打开对话框后(如我准备或正在选择文件时)有时整个程序会突然退出

解决方案 »

  1.   

    > ...OFN_HIDEREADONLY, "ini", this );
    -----------------------------
    如果是 CDialog, 把这个 this 改成 m_hWnd 试试 .
      

  2.   

    static char szFilter[] = "TXT Files (*.txt)|*.txt||";
    static DWORD dwFlags = OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST;
    CFileDialog dlg(true,NULL,NULL,dwFlags,szFilter,NULL);
      

  3.   

    把else
      {
        return;
       }
    去掉