Click to See Complete Forum and Search --> : showing a directory browse box
SmashingPumpkinsAddict
Dec 5th, 1999, 11:43 AM
Is there a control/API call I can use to show a directory browse box, similiar to the common dialog control? I have VB4 and I was not able to find such a control in the list....
-Adam
Vit
Dec 5th, 1999, 03:33 PM
Use MS Common dialog control:
CommonDialog1.ShowOpen
Crazy D
Dec 5th, 1999, 04:21 PM
Put this in the declarations section of a code module:
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Type BROWSEINFO
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
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Const BIF_RETURNONLYFSDIRS = &H1
And put this somewhere in the same module:
Public Function DialogSelectFolder(hOwner As Long, psTitle As String) As String
Dim udtBrowseInfo As BROWSEINFO, sPath As String
With udtBrowseInfo
.hOwner = hOwner
.pidlRoot = 0&
.lpszTitle = psTitle
.ulFlags = BIF_RETURNONLYFSDIRS
End With
sPath = Space$(512)
If SHGetPathFromIDList(SHBrowseForFolder(udtBrowseInfo), sPath) Then
DialogSelectFolder = Left(sPath, InStr(sPath, vbNullChar) - 1)
Else
DialogSelectFolder = ""
End If
End Function
Call it like this:
Dim sFolder As String
sFolder = DialogSelectFolder(Me.hWnd, "Just something...")
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.