1,文件对话框
//1,弹出文件打开对话框
CString strFileName = "";
char szFilter[] = {"exe files(*.exe)|*.exe|All Files(*.*)|*.*|"};
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,szFilter,NULL);
if(dlg.DoModal() == IDOK)
{
strFileName = dlg.GetPathName();
CString strNewFileName;
strNewFileName.Format("%s",strFileName);
//SetDlgItemText(IDC_EditLongRangeCall,strNewFileName);
}
2,文件目录选择对话框
增加定义
#define BIF_NEWDIALOGSTYLE 0x40
#define BIF_USENEWUI (BIF_NEWDIALOGSTYLE|BIF_EDITBOX)
CString strPath;
char szDir[MAX_PATH];
BROWSEINFO bi;
ITEMIDLIST *pidl;
bi.hwndOwner = this->m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szDir;
bi.lpszTitle = "请选择目录";
bi.ulFlags = BIF_STATUSTEXT | BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
pidl = SHBrowseForFolder(&bi);
if(pidl == NULL)
{
return;
}else
{
if(!SHGetPathFromIDList(pidl, szDir))
{
return;
}else
{
SetDlgItemText(IDC_EDIT_Path,szDir);
//strPath.Format("%s\\duplicate_files",szDir);
//SetDlgItemText(IDC_EDIT_Move_Path,strPath);
}
}