//选择文件对话框
CString Cmission_cDlg::BootOpenDialog() //返回选择的文件名称
{
CString strFile = _T("");
CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files All Files (*.*)|*.*||"), NULL);
if (dlgFile.DoModal())
{
strFile = dlgFile.GetFileName();
}
return strFile;
}
void Cmission_cDlg::OnBnClickedButton1()
{
//打开文件对话框,选择文件
filename = BootOpenDialog();
GetDlgItem(IDC_EDIT1)->SetWindowText(filename);
}
CString
CString
CString
//保存文件对话框
CString CTestDlg::SaveDialog()
{
CString strFile = _T("");
CFileDialog dlgFile(FALSE, NULL, NULL, OFN_HIDEREADONLY, _T("*.txt"),NULL);
if(dlgFile.DoModal())
{
strFile = dlgFile.GetPathName();
}
return strFile;
}
void CTestDlg::OnBnClickedSave()
{
CString csSaveFileName = SaveDialog();
if(csSaveFileName == "")
return;
}
//选择目录对话框
void CDcPackerDlg::OnBnClickedDecgen()
{
char szPath[MAX_PATH]; //存放选择的目录路径
CString str;
ZeroMemory(szPath, sizeof(szPath));
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szPath;
bi.lpszTitle = "请选择需要打包的目录:";
bi.ulFlags = 0;
bi.lpfn = NULL;
bi.lParam = 0;
bi.iImage = 0;
//弹出选择目录对话框
LPITEMIDLIST lp = SHBrowseForFolder(&bi);
if(lp && SHGetPathFromIDList(lp, szPath))
{
str.Format("选择的目录为 %s", szPath);
AfxMessageBox(str);
}
else
AfxMessageBox("无效的目录,请重新选择");
}