Results 1 to 5 of 5

Thread: Folders With CommonDialog

  1. #1

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287

    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.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    You can't with the common dialog control. But you can do it with 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.

  3. #3

    Thread Starter
    Hyperactive Member Stiletto's Avatar
    Join Date
    Aug 2002
    Location
    Jerusalem, Israel
    Posts
    287
    I think i just need to set the right flag...

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    If you can find a flag for that let us know. I believe that manavo11 is the only way to do it.

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Originally posted by Stiletto
    I think i just need to set the right flag...
    Sorry but I don't think so. I have never seen an example like that or even something like it in any application...


    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