Shell BrowseForFolder 预选路径
我有这样的调用:
oShell.BrowseForFolder(Me.hwnd, "Select path:", 0, "C:\dir\")
这将打开一个标准文件浏览器对话框,其中“C:\dir\”为 root。 我的问题是你无法浏览根文件夹之上。 (如文档 http://msdn.microsoft.com/en 中指定-us/library/bb774065(v=vs.85).aspx)
对于使用选定路径和完全浏览功能打开此对话框有什么建议吗?
谢谢
I have this call:
oShell.BrowseForFolder(Me.hwnd, "Select path:", 0, "C:\dir\")
This opens a standard file browser dialog with "C:\dir\" as root.
My problem is that you can not browse above the root folder. (as specified in doc http://msdn.microsoft.com/en-us/library/bb774065(v=vs.85).aspx)
Any suggestions on oppening this dialog with a selected path and full browsing posibility?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
执行此操作的方法涉及调用底层 API,
SHBrowseForFolder()< /代码>
。
由于您希望整个 shell 命名空间可用,因此需要将
NULL
作为pidlRoot
。为了选择所需的文件夹,您需要在 < 中提供回调代码>lpfn。使此回调响应BFFM_INITIALIZED
通过设置选定的文件夹。此选择是通过将 BFFM_SETSELECTION 消息发送到对话框的窗口句柄(传递给回调函数)来执行的。没有代码,因为我没有 VB6,但希望该方法的概述足以让您上路。
The way to do this involves calling the underlying API,
SHBrowseForFolder()
.Since you want the entire shell namespace to be available you need to pass
NULL
aspidlRoot
. In order to select your desired folder you will need to provide a callback inlpfn
. Make this callback respond toBFFM_INITIALIZED
by setting the selected folder. This selection is performed by sending theBFFM_SETSELECTION
message to the dialog's window handle (passed to the callback function).No code because I don't have VB6, but hopefully this outline of the method is enough to get you on your way.
Karl E Peterson 的优秀网站包含一个示例,演示了带有回调的 API 调用
SHBrowseForFolder
,如 David Heffernan 的回答所示。KeyStuff 项目
查看
MFolderBrowse.bas
,例程BrowseForFolderByPIDL
,它传递回调函数BrowseCallbackProc
。Karl E Peterson's excellent website contains a sample which demonstrates the API call
SHBrowseForFolder
with a callback, as in David Heffernan's answer.The KeyStuff project
Look at
MFolderBrowse.bas
, routineBrowseForFolderByPIDL
which passes a callback functionBrowseCallbackProc
.尝试旧的 CCRP 项目。它有一个很好的浏览对话框实现。我在我的几个项目中使用了它,它具有解决您遇到的问题的属性。
Try the old CCRP project. It has a nicely done implementation of the Browse dialog. I used it in several of my projects and it has properties to address the issue you are having.
下面是准备复制并粘贴到 C++ 类中的代码:
Here a code ready for copy and paste in a C++ class: