by Stephen Fonnesbeck (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (12 Votes)
Enhancing the SHBrowseForFolder API Function
============================================
Browse for a Folder using SHBrowseForFolder API function with a callback function BrowseCallbackProc. This Extends the functionality that was given in the MSDN Knowledge Base article Q179497 "HOWTO: Select a Directory Without the Common Dialog Control".
After reading the MSDN knowledge base article Q179378 "HOWTO: Browse for Folders from the Current Directory", I was able to figure out how to add a callback function that sets the starting directory and displays the currently selected path in the "Browse For Folder" dialog.
Inputs
Public Function BrowseForFolder(owner As Form, Title As String, StartDir As String) As String
owner = referance to the calling from (can be 0)
Title = Intructions to appear in the "Browse for Folder" dialog.
StartDir = The directory that is displayed in the tree view when the dialog appears.
Assumes
How to call API functions and how to use the AddressOf operator to get a function pointer and store it in a variable.
Code Returns
If user doesn't click cancel then it returns a string with the directory the users selected.
Download EBrowseF.zip (4 KB)