我创建一个mfc 工程, 如何通过checkbox控件弹出一个对话框选择文件夹路径,并获取该文件夹的路径。求大神指导
1条回答 默认 最新
- oyljerry 2015-07-17 08:00关注
勾上check box后,就调用跳出文件选择对话框
CString strFilePath; TCHAR pszBuffer[_MAX_PATH]; BROWSEINFO bi; LPITEMIDLIST pidl; bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = pszBuffer; bi.lpszTitle = _T("&NCString strFilePath; TCHAR pszBuffer[_MAX_PATH]; BROWSEINFO bi; LPITEMIDLIST pidl; bi.hwndOwner = NULL; bi.pidlRoot = NULL; bi.pszDisplayName = pszBuffer; bi.lpszTitle = _T("Ñ¡Ôñ²¥³ö±í·¾¶"); bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; if((pidl = SHBrowseForFolder(&bi)) != NULL) { if(SHGetPathFromIDList(pidl, pszBuffer)) { CString strTemp(pszBuffer); strFilePath = strTemp; if (strFilePath.GetLength() <= 1) { } else if (strFilePath.Right(1) != _T("\\")) strFilePath += _T("\\"); } } GetDlgItem(IDC_STATIC_PATH)->SetWindowText(strFilePath);tilde;¡Ôñ²¥³ö±í·¾¶"); bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; bi.lpfn = NULL; bi.lParam = 0; if((pidl = SHBrowseForFolder(&bi)) != NULL) { if(SHGetPathFromIDList(pidl, pszBuffer)) { CString strTemp(pszBuffer); strFilePath = strTemp; if (strFilePath.GetLength() <= 1) { } else if (strFilePath.Right(1) != _T("\\")) strFilePath += _T("\\"); } } GetDlgItem(IDC_STATIC_PATH)->SetWindowText(strFilePath);
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 2无用