调用一个CFileDialog类,它的lpszFilter参数用来通过后缀过滤文件。
如果要支持多个后缀,msdn介绍的方法是将上面的参数设成:
szFilter[] = "Chart Files (*.xlc)|*.xlc|Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|*.xlc; *.xls|All Files (*.*)|*.*||";
我试了很长时间都失败了。最后才发现,msdn下面还有一行Note:
Note, however, that if you plan to use this string to directly update the OPENFILENAME structure, you should delimit your strings with the null character, (/0), instead of the vertical bar (|).
本文详细介绍了如何使用 CFileDialog 类的 lpszFilter 参数来过滤文件。特别是当需要支持多个文件后缀名时,文章提供了 MSDN 中推荐的设置方式,并指出了一个容易被忽视的细节:字符串应该使用空字符 (/0) 而不是竖线 (|) 来分隔。
1万+

被折叠的 条评论
为什么被折叠?



