IFileSaveDialog-在Windows 7中选择文件夹 [英] IFileSaveDialog - choosing folders in Windows 7

查看:379
本文介绍了IFileSaveDialog-在Windows 7中选择文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vista中,我一直使用IFileSaveDialog让用户选择另存为"文件夹.例如,用户导出图像文件夹,并且需要选择一个新的或现有的目标文件夹.

In Vista, I have been using an IFileSaveDialog to let users pick a "save-as" folder. Users export a folder of images, say, and need to choose a new or existing target folder.

简而言之,代码如下:

IFileSaveDialog* dialog; // created
dialog->SetOptions(FOS_PICKFOLDERS);
dialog->Show(NULL);
dialog->GetResult(&shellItem)

在Windows 7中,FOS_PICKFOLDERS选项似乎已被禁止(并且在

In Windows 7, the FOS_PICKFOLDERS option appears to have been disallowed (and is marked as such in the API). The return value on the SetOptions call is E_INVALIDARG. If I use a IFileOpenDialog, I'm allowed to set the folders option, but the user is prompted with an error when choosing a nonexistent folder (despite my setting flags suggesting not to do this).

是否有另一种方法来使新的IFileDialog充当保存文件夹"对话框?

Is there an alternate way to get the new IFileDialog to act as a "save folder" dialog?

[为了避免发表评论,SHBrowseForFolder API仍然存在,但是对于我们的UI决定者来说仍然不是可接受的解决方案.]

[To head off some comments, the SHBrowseForFolder API still exists, but is still not an acceptable solution for our UI deciders.]

推荐答案

其原因可在文档中找到:

The reason for this can be found in the documentation:

FOS_PICKFOLDERS:显示打开"对话框,提供选择的文件夹而不是文件.

FOS_PICKFOLDERS: Present the Open dialog offering a choice of folders rather than files.

从未支持将FOS_PICKFOLDERS用作保存",但Vista并未强制执行.改用IFileOpenDialog,您就很好了. 您正在选择一个现有文件夹(未指定要创建的文件夹),因此打开始终是正确的选择.

Using FOS_PICKFOLDERS for "Save" was never supposed to be supported but Vista didn't enforce it. Use IFileOpenDialog instead and you're good to go. You are picking an existing folder (not specifying a folder to create), so open was always the correct choice.

这篇关于IFileSaveDialog-在Windows 7中选择文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆