Results 1 to 5 of 5

Thread: Need to use a browse box to get a path

  1. #1

    Thread Starter
    Lively Member Crazy_bee's Avatar
    Join Date
    Jul 2001
    Location
    Fitchburg
    Posts
    90

    Arrow Need to use a browse box to get a path

    I'm trying to figure out how to get a browse box just for a path. I tried using the commondialog but that is just for saving and opening. Does anyone know the omponent that I have to add to get a browse directory box?
    Don't ever Ginop before you Ginip

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

  3. #3
    Addicted Member
    Join Date
    Feb 2001
    Location
    West Palm Beach, Florida
    Posts
    188

    Browse Path

    I'm sending you an example of one of the forms I used in one of my applications to browse for a path
    Attached Files Attached Files

  4. #4
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    Here:

    Put this in a module, or if you want it on a form, add Private where appropriate:
    VB Code:
    1. Option Explicit
    2.  
    3. 'Dir Select code
    4. Const BIF_RETURNONLYFSDIRS = 1
    5. Const BIF_DONTGOBELOWDOMAIN = 2
    6. Const MAX_PATH = 260
    7.  
    8. Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    9. Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    10. Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    11.  
    12. Type BrowseInfo
    13.     hWndOwner As Long
    14.     pIDLRoot As Long
    15.     pszDisplayName As Long
    16.     lpszTitle As Long
    17.     ulFlags As Long
    18.     lpfnCallback As Long
    19.     lParam As Long
    20.     iImage As Long
    21. End Type
    22.  
    23. Function DirSelect() As String
    24. 'Dir Select dialog code:
    25. Dim lpIDList As Long
    26. Dim sBuffer As String
    27. Dim szTitle As String
    28. Dim tBrowseInfo As BrowseInfo
    29.  
    30. szTitle = "Choose Folder"
    31.  
    32. With tBrowseInfo
    33.     .hWndOwner = Form1.hWnd
    34.     .lpszTitle = lstrcat(szTitle, "")
    35.     .ulFlags = BIF_DONTGOBELOWDOMAIN + BIF_RETURNONLYFSDIRS
    36. End With
    37.  
    38. lpIDList = SHBrowseForFolder(tBrowseInfo)
    39.  
    40. If (lpIDList) Then
    41.     sBuffer = Space(MAX_PATH)
    42.     SHGetPathFromIDList lpIDList, sBuffer
    43.     'sBuffer value is the directory that the user choose from the dialog.
    44.     sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    45.     DirSelect = sBuffer
    46. End If
    47. End Function
    Just call the DirSelect function and it will display the dialog and return the path of the dir.
    You just proved that sig advertisements work.

  5. #5

    Thread Starter
    Lively Member Crazy_bee's Avatar
    Join Date
    Jul 2001
    Location
    Fitchburg
    Posts
    90
    thanks all.
    nishantp how would I make it open center owner?
    Don't ever Ginop before you Ginip

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