Displays a dialog that allows the user to select a directory from a tree
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
Rate Displays a dialog that allows the user to select a directory from a tree
(2(2 Vote))
'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
Displays a dialog that allows the user to select a directory from a tree Comments
No comments yet — be the first to post one!
Post a Comment