Results 1 to 2 of 2

Thread: Common Dialog for show folder [RESOLVED]

  1. #1

    Thread Starter
    Lively Member vb_paladin's Avatar
    Join Date
    May 2003
    Location
    USA
    Posts
    102

    Cool Common Dialog for show folder [RESOLVED]

    I know there is a common dialog for finding and opening files. But is there such a dialog for selecting folders? And then putting the folder path into a string?
    Last edited by vb_paladin; Jul 13th, 2003 at 08:25 PM.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Use this :

    VB Code:
    1. 'PUT IN MODULE
    2. 'API declarations
    3.  
    4. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    5. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    6. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    7.  
    8. 'Constants
    9.  
    10. Private Const BIF_RETURNONLYFSDIRS = 1
    11. Private Const BIF_DONTGOBELOWDOMAIN = 2
    12. Private Const MAX_PATH = 260
    13. Private Const BIF_NEWDIALOGSTYLE = &H40
    14.  
    15. 'Types
    16.  
    17. Private Type BrowseInfo
    18.    hWndOwner      As Long
    19.    pIDLRoot       As Long
    20.    pszDisplayName As Long
    21.    lpszTitle      As Long
    22.    ulFlags        As Long
    23.    lpfnCallback   As Long
    24.    lParam         As Long
    25.    iImage         As Long
    26. End Type
    27.  
    28. Public Function funcBrowseFolder(WindowHandle As Long, BrowseTitle As String) As String
    29.  
    30. 'Opens a Treeview control that displays the directories in a computer
    31.  
    32. Dim lpIDList As Long
    33. Dim sBuffer As String
    34. Dim szTitle As String
    35. Dim tBrowseInfo As BrowseInfo
    36.    
    37.    szTitle = BrowseTitle '"Select the folder to save to"
    38.    With tBrowseInfo
    39.       .hWndOwner = WindowHandle
    40.       .lpszTitle = lstrcat(szTitle, "")
    41.       .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_NEWDIALOGSTYLE
    42.    End With
    43.    
    44.    lpIDList = SHBrowseForFolder(tBrowseInfo)
    45.    
    46.    If (lpIDList) Then
    47.       sBuffer = Space$(MAX_PATH)
    48.       SHGetPathFromIDList lpIDList, sBuffer
    49.       sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    50.       funcBrowseFolder = sBuffer
    51.    End If
    52.    
    53. End Function


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width