帮看下这段代码,详细点!

来源:百度知道 编辑:UC知道 时间:2024/06/15 12:12:19
BOOL CExifTestDlg::PromptForFileName(CString& fileName, UINT nIDSTitle,
DWORD dwFlags, BOOL bOpenFileDialog, int* pType)
{

CFileDialog dlgFile(bOpenFileDialog);
CString title;
if (bOpenFileDialog) title="Open file"; else title="Save file";

dlgFile.m_ofn.Flags |= dwFlags;

int nDocType = (pType != NULL) ? *pType : 0;

int nIndex = 0;

dlgFile.m_ofn.nFilterIndex = nIndex +1;
CString strDefExt = "pal";
dlgFile.m_ofn.lpstrDefExt = strDefExt;

CString strFilter = "*.jpg";
strFilter += (TCHAR)NULL;
strFilter += "*.jpg";
strFilter += (TCHAR)NULL;
strFilter += "*.*";
strFilter += (TCHAR)NULL;
strFilter += "*.*";
strFilter += (TCHAR)NULL;

dlgFile.m_ofn.lpstrFilter = strFilter;
dlgFile.m_ofn.lpstrTitle = title;
dlgFile.m_ofn.lpstrFile = fileName.GetBuffer

得到打开或者是保存的文件名fileName, 返回文件类型索引nIndex

BOOL CExifTestDlg::PromptForFileName(CString& fileName, UINT nIDSTitle,
DWORD dwFlags, BOOL bOpenFileDialog, int* pType)
{

CFileDialog dlgFile(bOpenFileDialog); // 文件打开或保存对话框,根据bOpenFileDialog来区分
CString title;
if (bOpenFileDialog) title="Open file"; else title="Save // 设置显示标题file";

dlgFile.m_ofn.Flags |= dwFlags; // 文件打开属性

int nDocType = (pType != NULL) ? *pType : 0;

int nIndex = 0;

dlgFile.m_ofn.nFilterIndex = nIndex +1;
CString strDefExt = "pal"; //默认扩展名
dlgFile.m_ofn.lpstrDefExt = strDefExt;

CString strFilter = "*.jpg"; // 打开类型
strFilter += (TCHAR)NULL;
strFilter += "*.jpg";
strFilter += (TCHAR)NULL;
strFilter += "*.*";
strFilter += (TCHAR)NULL;
strFilter += "*.*";
strFilter += (TCHAR)NULL;

dlgFile.m_ofn