打开文件对话框里如何设置文件类型
发布网友
发布时间:2022-05-24 12:25
我来回答
共2个回答
热心网友
时间:2023-10-13 04:10
// 文件过滤器,用于文件对话框
static char BASED_CODE szFilterProgram[] = "tif文件 (*.tif)|*.tif|All Files (*.*)|*.*||";
void CNewDialog::OnBnClickedBrowse()
{
CString filename;
CFileDialog fileopenbox(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilterProgram);
fileopenbox.m_ofn.lpstrTitle = "打开";
if(fileopenbox.DoModal() == IDOK)
{
filename = fileopenbox.GetPathName();
SetDlgItemText(IDC_FILECOMBO,filename);
BOOL bReturn = ((CComboBox*)GetDlgItem(IDC_FILECOMBO))->FindString(-1,filename);
if(bReturn<0)//将文件名插入到组合列表中
((CComboBox*)GetDlgItem(IDC_FILECOMBO))->InsertString(-1,filename);
}
}
参考资料:百度一下
热心网友
时间:2023-10-13 04:11
char BASED_CODE szFilterProgram[] = "tif文件 (*.tif)|*.tif|All Files (*.*)|*.*||";
void CNewDialog::OnBnClickedBrowse()
{
CString filename;
CFileDialog fileopenbox(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilterProgram);
fileopenbox.m_ofn.lpstrTitle = "打开";
if(fileopenbox.DoModal() == IDOK)
{
filename = fileopenbox.GetPathName();
SetDlgItemText(IDC_FILECOMBO,filename);
BOOL bReturn = ((CComboBox*)GetDlgItem(IDC_FILECOMBO))->FindString(-1,filename);
if(bReturn<0)//将文件名插入到组合列表中
((CComboBox*)GetDlgItem(IDC_FILECOMBO))->InsertString(-1,filename);
}
}追问编译能通过,但就是不能显示对话框,怎么办?