Results 1 to 3 of 3

Thread: showing a directory browse box

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 1999
    Location
    Boise, ID USA
    Posts
    15

    Post

    Is there a control/API call I can use to show a directory browse box, similiar to the common dialog control? I have VB4 and I was not able to find such a control in the list....

    -Adam

  2. #2
    Lively Member
    Join Date
    Mar 1999
    Posts
    93

    Post

    Use MS Common dialog control:
    CommonDialog1.ShowOpen

  3. #3
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Put this in the declarations section of a code module:
    Code:
    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    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 Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
    Private Const BIF_RETURNONLYFSDIRS = &H1
    And put this somewhere in the same module:
    Code:
    Public Function DialogSelectFolder(hOwner As Long, psTitle As String) As String
        Dim udtBrowseInfo As BROWSEINFO, sPath As String
        With udtBrowseInfo
            .hOwner = hOwner
            .pidlRoot = 0&
            .lpszTitle = psTitle
            .ulFlags = BIF_RETURNONLYFSDIRS
        End With
        sPath = Space$(512)
        If SHGetPathFromIDList(SHBrowseForFolder(udtBrowseInfo), sPath) Then
            DialogSelectFolder = Left(sPath, InStr(sPath, vbNullChar) - 1)
        Else
            DialogSelectFolder = ""
        End If
    End Function
    Call it like this:
    Code:
    Dim sFolder As String
    sFolder = DialogSelectFolder(Me.hWnd, "Just something...")

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