如何调用文件打开对话框?

benet_773703308 2013-12-14 09:45:36
如何用VC调用如下对话框:


我用vc中的CFileDialog类的DoModal方法,调用的总是如下窗口


我该怎么实现 就能调用第一种文件打开对话框呢?
...全文
222 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiantian1980 2013-12-15
  • 打赏
  • 举报
回复
这个应是系统的问题吧
schlafenhamster 2013-12-15
  • 打赏
  • 举报
回复
vc6 的 要这样: //if use new style! OSVERSIONINFO VersionInformation; GetVersionEx(&VersionInformation); if(VersionInformation.dwMajorVersion >= 5) dlgFile.m_ofn.lStructSize=88;// new =88 else dlgFile.m_ofn.lStructSize=76;// old =76
凌乱哥 2013-12-15
  • 打赏
  • 举报
回复
6楼的回复没看到?此贴早就终结了
memeai 2013-12-14
  • 打赏
  • 举报
回复
引用 2 楼 benet_773703308 的回复:
[quote=引用 1 楼 worldy 的回复:] CFileDialog dlg(TRUE); dlg.DoModal();
我就是这样做的呀,我的代码如下: DWORD dwFlag = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, NULL, NULL, dwFlag, "媒体文件(所有文件)|(*.flv;*.rmvb;*.avi;*.rm)||", this); dlg.DoModal(); 可是还是不能调用第一种形式的文件打开对话框呀[/quote] 明明可以呀
worldy 2013-12-14
  • 打赏
  • 举报
回复
别基于求成 先做 CFileDialog dlg(TRUE),其它参数慢慢加进
benet_773703308 2013-12-14
  • 打赏
  • 举报
回复
引用 1 楼 worldy 的回复:
CFileDialog dlg(TRUE); dlg.DoModal();
我就是这样做的呀,我的代码如下: DWORD dwFlag = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT; CFileDialog dlg(TRUE, NULL, NULL, dwFlag, "媒体文件(所有文件)|(*.flv;*.rmvb;*.avi;*.rm)||", this); dlg.DoModal(); 可是还是不能调用第一种形式的文件打开对话框呀
worldy 2013-12-14
  • 打赏
  • 举报
回复
CFileDialog dlg(TRUE); dlg.DoModal();
gfm688 2013-12-14
  • 打赏
  • 举报
回复
引用 9 楼 gfm688 的回复:
[quote=引用 8 楼 SXJIAKE 的回复:] dwFlag 添加 OFN_EXPLORER 标志位
Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods. For more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates. By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag. If you want the old-style user interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook procedure. If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns FALSE. [/quote] 楼主想要的那个确实是OFN_EXPLORER 估计MFC指定lpfnHook了,否则不指定OFN_EXPLORER,也会是楼主想要的那个
gfm688 2013-12-14
  • 打赏
  • 举报
回复
引用 8 楼 SXJIAKE 的回复:
dwFlag 添加 OFN_EXPLORER 标志位
Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods. For more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates. By default, the Open and Save As dialog boxes use the Explorer-style user interface regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template, or set the OFN_ALLOWMULTISELECT flag. If you want the old-style user interface, omit the OFN_EXPLORER flag and provide a replacement old-style template or hook procedure. If you want the old style but do not need a custom template or hook procedure, simply provide a hook procedure that always returns FALSE.
「已注销」 2013-12-14
  • 打赏
  • 举报
回复
dwFlag 添加 OFN_EXPLORER 标志位
mjpedy 2013-12-14
  • 打赏
  • 举报
回复
我经过测试,没有设置初始化目录时,默认情况下打开的就是“文档”文件夹(在Windows 7中)。不知道你那里为什么会默认打开“桌面”文件夹。你尝试手动设置打开文件的初始化目录,看看是否有效
	DWORD dwFlag = OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
	CFileDialog dlg(TRUE, NULL, NULL, dwFlag, _T("媒体文件(所有文件)|(*.flv;*.rmvb;*.avi;*.rm)||"), this);
	dlg.m_ofn.lpstrInitialDir = _T("::{450D8FBA-AD25-11D0-98A8-0800361B1103}");//设置初始化目录为“文档”文件夹
	dlg.DoModal();
凌乱哥 2013-12-14
  • 打赏
  • 举报
回复
VC6要设置lStructSize

CFileDialog dlg(TRUE);
if(GetVersion()<0x80000000)
    dlg.m_ofn.lStructSize = 88;
else
    dlg.m_ofn.lStructSize = 76;
dlg.DoModal();
encoderlee 版主 2013-12-14
  • 打赏
  • 举报
回复
你使用VC6.0吧,VC6.0的MFC类库版本太老。 如果你使用Visual studio 2008及以上版本来编译的话,就是第一种效果了。 代码不用改。

16,472

社区成员

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

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

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