Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Standard windows dialogue box for selecting folders?

Status
Not open for further replies.

Jonathan

Programmer
Mar 19, 1999
116
GB
I am using the Windows API in my application to allow the user to easily select files to open using the standard windows Open File box. I also need to provide some means of selecting a folder. An example of what I want can be seen by going to the start menu, clicking Find - Files or Folders and clicking the Browse... button next to the Look In combo.<br>
<br>
Does anyone know if there is a Win API function or other easy method for achieving this (preferably without getting new ActiveX controls)<br>
<br>
Cheers<br>
<br>
Jonathan
 
I am not sure if you are still waiting for a reply on this one, but just in case you are, here is the API for Selecting a folder:<br>
<br>
Private Type BROWSEINFO<br>
hOwner As Long<br>
pidlRoot As Long<br>
pszDisplayName As String<br>
lpszTitle As String<br>
ulFlags As Long<br>
lpfn As Long<br>
lParam As Long<br>
iImage As Long<br>
End Type<br>
<br>
Private Declare Function SHGetPathFromIDList Lib &quot;shell32.dll&quot; Alias _<br>
&quot;SHGetPathFromIDListA&quot; (ByVal pidl As Long, _<br>
ByVal pszPath As String) As Long<br>
<br>
Private Declare Function SHBrowseForFolder Lib &quot;shell32.dll&quot; Alias _<br>
&quot;SHBrowseForFolderA&quot; (lpBrowseInfo As BROWSEINFO) _<br>
As Long<br>
<br>
Private Const BIF_RETURNONLYFSDIRS = &H1<br>
Public Function BrowseFolder(szDialogTitle As String) As String<br>
Dim X As Long, bi As BROWSEINFO, dwIList As Long<br>
Dim szPath As String, wPos As Integer<br>
<br>
With bi<br>
.hOwner = hWndAccessApp<br>
.lpszTitle = szDialogTitle<br>
.ulFlags = BIF_RETURNONLYFSDIRS<br>
End With<br>
<br>
dwIList = SHBrowseForFolder(bi)<br>
szPath = Space$(512)<br>
X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)<br>
<br>
If X Then<br>
wPos = InStr(szPath, Chr(0))<br>
BrowseFolder = Left$(szPath, wPos - 1)<br>
Else<br>
BrowseFolder = &quot;&quot;<br>
End If<br>
End Function<br>

 
OK, I have just went browsing and see that you already got the answer you were looking for on this one previously.
 
Send your email address to <A HREF="mailto:chthomas@tebodinme.co.ae">chthomas@tebodinme.co.ae</A>. I have some sample db which performs the browse for folder, that i will email if you are intrested.<br>
Charley
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top