程序中按下按钮后的代码如下void CWizardStep1::OnBtnDir() 
{
// TODO: Add your control notification handler code here
BROWSEINFO  bi;
bi.hwndOwner=NULL;
bi.pidlRoot=NULL;
bi.pszDisplayName=NULL;
bi.lpszTitle=NULL;
bi.ulFlags=  BIF_EDITBOX| BIF_BROWSEFORCOMPUTER|
BIF_RETURNONLYFSDIRS| 0x00000040 |BIF_DONTGOBELOWDOMAIN
| 0x00000100 |0x00000200 | BIF_STATUSTEXT;
bi.lpfn =NULL;
bi.iImage =0;
LPCITEMIDLIST pidl=SHBrowseForFolder(&bi);
if(!pidl)
{
CString strTemp;
strTemp.LoadString(IDS_TST_WIZARD_ERROR_DIR);
AfxMessageBox(strTemp);
return;
}
TCHAR  szDisplayName[255];
SHGetPathFromIDList(pidl,szDisplayName);
CString str(szDisplayName);
MessageBox(str,NULL,MB_OK);
}这样打开的文件夹对话框,是无模态的,可以再在主界面上反复打开多个这个对话框。请问怎样才能改成有模态的?

解决方案 »

  1.   

    可以使用CFileDialog,然后DoModal() 生成模态对话框
      

  2.   

    TCHAR   pszBuffer[_MAX_PATH];
    BROWSEINFO   bi;
    LPITEMIDLIST pidl;
    bi.hwndOwner = this->GetSafeHwnd();   
    bi.pidlRoot = NULL;
    bi.pszDisplayName = pszBuffer;
    CString str = _T("Specify the UnZip Path:");
    bi.lpszTitle  = str;   
    bi.ulFlags = BIF_RETURNONLYFSDIRS;   
    bi.lpfn = NULL;
    bi.lParam = 0;
    pidl = SHBrowseForFolder(&bi);
    SHGetPathFromIDList(pidl, pszBuffer); m_strUnZipPath.Format(_T("%s"), pszBuffer);
    m_edtUnZipPath.SetWindowText(m_strUnZipPath);
    这个是模态的。