by Alex Lvov (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 13th June 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Displays a dialog that allows the user to select a directory from a tree
API Declarations
'Type definition
Public Type SHITEMID 'Browse Dialog
cb As Long
abID As Byte
End Type
Public Type ITEMIDLIST 'Browse Dialog
mkid As SHITEMID
End Type
Public Type BROWSEINFO 'Browse Dialog
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Public Const BIF_RETURNONLYFSDIRS = &H1 'Browse Dialog
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
'Parameters:
' string: Prompt to display
' form: Form from which function was called
Public Function BrowseForFolder(szPrompt As String, frmCall As Form) As String
Dim bi As BROWSEINFO
Dim pidl As Long
Dim nRet As Long
Dim szPath As String
frmCall.Enabled = False 'make form modal (pseudo)
szPath = Space$(512)
'Fill struct
bi.hOwner = 0&
bi.pidlRoot = 0&
bi.lpszTitle = szPrompt
bi.ulFlags = BIF_RETURNONLYFSDIRS
'Display the dialog and get the selected path
pidl& = SHBrowseForFolder(bi)
SHGetPathFromIDList ByVal pidl&, ByVal szPath
frmCall.Enabled = True
'Return value
BrowseForFolder = Trim$(szPath)
End Function
No comments have been posted about Displays a dialog that allows the user to select a directory from a tree. Why not be the first to post a comment about Displays a dialog that allows the user to select a directory from a tree.