vc 文件对话框中设置文件类型的语句怎么写

来源:百度知道 编辑:UC知道 时间:2024/05/21 15:06:36
void CMyDlg::OnButton2()
{
// TODO: Add your control notification handler code here
m_comdlg.ShowOpen();
m_SrcFile = m_comdlg.GetFileName();
UpdateData(FALSE);
}
怎么改呢,想让它类型那就显示后缀为.tif格式的,求~~~~~~~~`

void CMyClass::OnFileOpen()
{
// szFilters is a text string that includes two file name filters:
// "*.tif" for "MyType Files" and "*.*' for "All Files."
TCHAR szFilters[]= _T("MyType Files (*.tif)|*.tif|All Files (*.*)|*.*||");

// Create an Open dialog; the default file name extension is ".my".
CFileDialog fileDlg(TRUE, _T("tif"), _T("*.tif"),
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters);

// Display the file dialog. When user clicks OK, fileDlg.DoModal()
// returns IDOK.
if(fileDlg.DoModal() == IDOK)
{
CString pathName = fileDlg.GetPathName();

// Implement opening and reading file in here.

//Change the window's title to the opened file's title.
CString fileName = fileDlg.GetFileTitle();

SetWindowText(fileName);
}
}