Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shell BrowseForFolder preselected path

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

like image 238
thedev Avatar asked Sep 01 '11 13:09

thedev


3 Answers

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 as pidlRoot. In order to select your desired folder you will need to provide a callback in lpfn. Make this callback respond to BFFM_INITIALIZED by setting the selected folder. This selection is performed by sending the BFFM_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.

like image 148
David Heffernan Avatar answered Nov 12 '22 00:11

David Heffernan


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, routine BrowseForFolderByPIDL which passes a callback function BrowseCallbackProc.

like image 34
MarkJ Avatar answered Nov 12 '22 00:11

MarkJ


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.

like image 29
AngryHacker Avatar answered Nov 11 '22 22:11

AngryHacker