void ClassName::showSelectFileDlgAndGetPath(CString &returnPathName, CString &returnFileName, CString fileExtension, CString initPath)
{
TRACE(_T("%s:%d,
initPath:%s\n"), __FUNCTIONW__, __LINE__, initPath);
CString csType;
if (fileExtension.GetLength() > 0)
{
csType.Format(_T("%s
file (*.%s)|*.%s|All (*.*)|*.*||"), fileExtension, fileExtension, fileExtension);
}
else
{
csType = _T("All
(*.*)|*.*||");
}
CFileDialog fOpenDlg(
TRUE, fileExtension, _T(""), OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
csType, NULL);
fOpenDlg.m_pOFN->lpstrTitle = _T("Select
File Dialog");
CString csTemp;
csTemp.Format(_T("%s"), initPath);
fOpenDlg.m_pOFN->lpstrInitialDir =
csTemp;
if (fOpenDlg.DoModal() == IDOK)
{
TRACE(_T("%s:%d,
GetPathName:%s\n"), __FUNCTIONW__, __LINE__,
fOpenDlg.GetPathName());
TRACE(_T("%s:%d,
GetFileName:%s\n"), __FUNCTIONW__, __LINE__,
fOpenDlg.GetFileName());
returnPathName =
fOpenDlg.GetPathName();
returnFileName =
fOpenDlg.GetFileName();
}
}
沒有留言:
張貼留言