MFC中怎么设置文件过滤器?

cau228charm 2007-08-12 09:15:01
默认情况下,打开文件时,显示所有文件(*.*),我现在想只让他显示*.bmp文件。应该怎么设。谢谢大家。。。。。。
...全文
601 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yjpa7 2010-07-07
  • 打赏
  • 举报
回复
在stringtable里面,我想一次让两种或以上的格式显示,应该怎么做??
zuo11888 2009-10-11
  • 打赏
  • 举报
回复
我也有这个问题,在stringtable里可以解决,但是框架会报错
hurryboylqs 2007-08-13
  • 打赏
  • 举报
回复
\0作为分割,\0\0作为结尾
clever101 2007-08-12
  • 打赏
  • 举报
回复
explicit CFileDialog(
BOOL bOpenFileDialog,
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL,
DWORD dwSize = 0
);
Parameters
bOpenFileDialog
Set to TRUE to construct a File Open dialog box or FALSE to construct a File Save As dialog box.
lpszDefExt
The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended.
lpszFileName
The initial filename that appears in the filename edit box. If NULL, no filename initially appears.
dwFlags
A combination of one or more flags that allow you to customize the dialog box. For a description of these flags, see the OPENFILENAME structure in the Platform SDK. If you modify the m_ofn.Flags structure member, use a bitwise-OR operator in your changes to keep the default behavior intact.
lpszFilter
A series of string pairs that specify filters you can apply to the file. If you specify file filters, only selected files will appear in the Files list box. See the Remarks section for more information on how to work with file filters.
pParentWnd
A pointer to the file dialog-box object's parent or owner window.
dwSize
The size of the OPENFILENAME structure. This value is dependent on the operating system version, so MFC can determine the appropriate kind of dialog to create (for example, new Windows 2000 dialogs as opposed to NT4 dialogs).


lpszFilter 这个就是文件过滤器,msdn上的一个例子是
static char BASED_CODE szFilter[] = "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||";

你对应参考一下吧
cau228charm 2007-08-12
  • 打赏
  • 举报
回复
我直接用的mfc框架直接生成的阿 只是重写了OnOpenDocument函数
BOOL CEdgeContourDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
CFile file; //定义文件对象,CFile是MFC类库中所有文件类的基类
CFileException fe; //定义文件异常对象,主要用来捕捉找不到指定文件的情况
。。。。。。。
这样的话
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("UC3D Mesh File(*.xml)|*.xml|;UC3D Binary Mesh File(*.bin)|*.bin|"),this);
这些代码可以在那个文件里找到
clever101 2007-08-12
  • 打赏
  • 举报
回复
quote:我的操作没有涉及到通用窗口的操作

难道你自己自定义一个打开文件对话框?
cau228charm 2007-08-12
  • 打赏
  • 举报
回复
不对啊,我的操作没有涉及到通用窗口的操作
sunraiing9 2007-08-12
  • 打赏
  • 举报
回复
CFileDialog dlg(FALSE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("UC3D Mesh File(*.xml)|*.xml|;UC3D Binary Mesh File(*.bin)|*.bin|"),this);

看看我这个写法你就知道了 呵呵
fmjk525283 2007-08-12
  • 打赏
  • 举报
回复
pct换成bmp就行
fmjk525283 2007-08-12
  • 打赏
  • 举报
回复
//选择打开文件夹
CFileDialog dlg(TRUE,"*.pct",NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"工艺卡片模板(*.pct)|*.pct|");

只打开.pct文件

16,472

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧