Results 1 to 7 of 7

Thread: easy folder choosing?

  1. #1

    Thread Starter
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048

    easy folder choosing?

    how do i access the ms folder chooser? u know, the one that is already programed and has desktop, my documents etc. and has no file display/choosing

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    In all the years I've dealth with various versions of Windows, I've never heard of a "folder chooser".

    What the heck are you talking about?

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can use the SHBrowseForFolder() and associated API, i.e.

    In a Standard Module:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Type BROWSEINFO
    4.     hwndOwner As Long
    5.     pIDLRoot As Long
    6.     pszDisplayName As Long
    7.     lpszTitle As Long
    8.     ulFlags As Long
    9.     lpfnCallback As Long
    10.     lParam As Long
    11.     iImage As Long
    12. End Type
    13.  
    14. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    15. Private Declare Function lStrCat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    16. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BROWSEINFO) As Long
    17. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    18.  
    19. Private Const BIF_RETURNONLYFSDIRS = 1
    20.  
    21. Public Function BrowseForFolder(ByVal lHwnd As Long, ByVal sPrompt As String) As String
    22.     Dim tBI As BROWSEINFO
    23.     Dim lList As Long
    24.     Dim lResult As Long
    25.     Dim sPath As String
    26.     Dim sString As String
    27.    
    28.     sString = Space(260)
    29.     With tBI
    30.         .hwndOwner = lHwnd
    31.         .lpszTitle = lStrCat(sPrompt, Chr(0))
    32.         .pszDisplayName = StrPtr(sString)
    33.         .ulFlags = BIF_RETURNONLYFSDIRS
    34.     End With
    35.     lList = SHBrowseForFolder(tBI)
    36.     sString = StrConv(sString, vbUnicode)
    37.     If lList Then
    38.         sPath = Space(260)
    39.         lResult = SHGetPathFromIDList(lList, sPath)
    40.         Call CoTaskMemFree(lList)
    41.         sPath = Left$(sPath, InStr(sPath, Chr(0)) - 1)
    42.     End If
    43.     BrowseForFolder = sPath
    44. End Function
    Example Usage:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Caption = BrowseForFolder(hWnd, "Select Directory..")
    3. End Sub

  4. #4

    Thread Starter
    Frenzied Member dis1411's Avatar
    Join Date
    Mar 2001
    Posts
    1,048
    thanks aaron!!!!

    folder chooser was MY name for it, but i think it was pretty clear what i was looking for by the description

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally posted by dis1411
    but i think it was pretty clear what i was looking for by the description
    Quite the contrary. It is a testament to Aaron Young's imagination that he had a clue what you were talking about.

    Aaron: You are a mind reading genius. I've gone over dis1411 until I can recite it from memory. How did you know what the heck he was talking about?

  6. #6
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    I worked as the sole tech-support for a company of 250+ users for just over 2 years... You learn to read between the lines.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    This probably doesn't mean anything to you Aaron, but you just got 3 stars in my book of respect!!!

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