|
-
July 4th, 2001, 05:01 PM
#1
Folder Picker
Is there such thing in VB as Folder Picker?
I know there is a CommonDialog control, but it has only FileOpen/Save standard dialogs. :-(
-
July 4th, 2001, 05:40 PM
#2
Re: Folder Picker
What about the DirListBox control... have you tried that?
-
July 4th, 2001, 07:22 PM
#3
Re: Folder Picker
private Type SHITEMID
cb as Long
abID as Byte
End Type
private Type ITEMIDLIST
mkid as SHITEMID
End Type
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 Const BIF_RETURNONLYFSDIRS = &H16
private Const MAX_PATH = 260
private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(byval hwndOwner as Long, _
byval nFolder as Long, _
Pidl as Long) as Long
private Declare Function SHGetPathFromIDList Lib _
"shell32.dll" Alias "SHGetPathFromIDListA" (byval Pidl as Long, _
byval pszPath as string) as Long
private Declare Function SHBrowseForFolder Lib _
"shell32.dll" Alias "SHBrowseForFolderA" _
(lpBrowseInfo as BROWSEINFO) as Long
private Declare Sub CoTaskMemFree Lib "ole32.dll" (byval pv as Long)
private Function vbGetBrowseDirectory() as string
Dim bi as BROWSEINFO
Dim IDL as ITEMIDLIST
Dim R as Long
Dim Pidl as Long
Dim tmpPath as string
Dim pos as Integer
bi.pidlRoot = 0&
bi.lpszTitle = "Select input files location"
bi.ulFlags = BIF_RETURNONLYFSDIRS 'get the folder
Pidl = SHBrowseForFolder(bi)
If Pidl <> 0 then
tmpPath = Space$(MAX_PATH)
If SHGetPathFromIDList(Pidl, byval tmpPath) then
pos = InStr(tmpPath, Chr$(0))
tmpPath = Left(tmpPath, pos - 1)
vbGetBrowseDirectory = ValidateDir(tmpPath)
else:
vbGetBrowseDirectory = ValidateDir("c:\")
End If
else
vbGetBrowseDirectory = ValidateDir("c:\")
End If
Call CoTaskMemFree(Pidl)
End Function
private Function ValidateDir(tmpPath as string) as string
If Right$(tmpPath, 1) = "\" then
ValidateDir = tmpPath
else
ValidateDir = tmpPath & "\"
End If
End Function
private Sub Command1_Click()
vbGetBrowseDirectory
End Sub
-
July 5th, 2001, 10:16 AM
#4
Unfortunately...
the code has a bug - it shows domain names in the network but cannot explore them :-(
-
July 5th, 2001, 10:51 AM
#5
Re: Unfortunately...
You can use the BrowseDialog OCX available at the common conrols replacement project http://www.mvps.org/ccrp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|