by Wade Reynolds (3 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 23rd April 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Directory Selector. Does not use the Common Dialogs. Very, very easy to use! Opens the Windows 'Browse for folder' tree-view window and
API Declarations
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260
Private Type BrowseInfo
hwndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = odtvTitle
With tBrowseInfo
.hwndOwner = odtvOwner.hwnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
OpenDirectoryTV = sBuffer
End If
End Function
' Example Usage:
'
' Create a new project with a textbox (Text1)
' and a command button (Command1) on Form1.
'
' Insert this line into Command1_Click
'
' Text1.Text = OpenDirectoryTV(Form1, "Place your title or message here!")
'
'
' Run the project, click the button, browse for a folder,
' and click Ok. That was easy, huh?
'
'
No comments have been posted about Directory Selector. Does not use the Common Dialogs. Very, very easy to use! Opens the Windows 'Bro. Why not be the first to post a comment about Directory Selector. Does not use the Common Dialogs. Very, very easy to use! Opens the Windows 'Bro.