|
-
Jul 13th, 2003, 04:45 PM
#1
Thread Starter
Hyperactive Member
Folders With CommonDialog
How can i Choose a folder with Common Dialog control?
I dont want files to appear. I want the to choose a folder.
-
Jul 13th, 2003, 06:00 PM
#2
You can't with the common dialog control. But you can do it with this :
VB Code:
'PUT IN MODULE
'API declarations
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
'Constants
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260
Private Const BIF_NEWDIALOGSTYLE = &H40
'Types
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
Public Function funcBrowseFolder(WindowHandle As Long, BrowseTitle As String) As String
'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = BrowseTitle '"Select the folder to save to"
With tBrowseInfo
.hWndOwner = WindowHandle
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_NEWDIALOGSTYLE
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space$(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
funcBrowseFolder = sBuffer
End If
End Function
Has someone helped you? Then you can Rate their helpful post. 
-
Jul 13th, 2003, 06:08 PM
#3
Thread Starter
Hyperactive Member
I think i just need to set the right flag...
-
Jul 13th, 2003, 06:13 PM
#4
If you can find a flag for that let us know. I believe that manavo11 is the only way to do it.
-
Jul 13th, 2003, 06:38 PM
#5
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
|