選擇目錄對話框
//選擇目錄按鈕
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("無效的目錄,請重新選擇");
}
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("無效的目錄,請重新選擇");
}
選擇文件對話框
CString CDcPackerDlg::BootOpenDialog() //返回選擇的文件名稱
{
CString strFile = _T("");
CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.cfg)|*.cfg|All Files (*.*)|*.*||"), NULL);
if (dlgFile.DoModal())
{
strFile = dlgFile.GetPathName();
}
return strFile;
}
//加載文件按鈕
void CDcPackerDlg::OnBnClickedSelectdec()
{
// TODO: Add your control notification handler code here
m_strDescPath = ""; //類的成員變量
//"打開文件"對話框,選擇文件,返回其路徑
m_strDescPath = BootOpenDialog();
}
{
CString strFile = _T("");
CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.cfg)|*.cfg|All Files (*.*)|*.*||"), NULL);
if (dlgFile.DoModal())
{
strFile = dlgFile.GetPathName();
}
return strFile;
}
//加載文件按鈕
void CDcPackerDlg::OnBnClickedSelectdec()
{
// TODO: Add your control notification handler code here
m_strDescPath = ""; //類的成員變量
//"打開文件"對話框,選擇文件,返回其路徑
m_strDescPath = BootOpenDialog();
}