Results 1 to 4 of 4

Thread: [RESOLVED] Folder Browser Problem

  1. #1

    Thread Starter
    Hyperactive Member kazar's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    323

    Resolved [RESOLVED] Folder Browser Problem

    Hey,

    I am using the following code to create a windows folder dialog box using apis. However, when i bring up the dialog, i would like the New Folder button to show, and wondered if any one knew of a flag or whatever that would do that.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const BIF_RETURNONLYFSDIRS As Long = &H1
    4. Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
    5. Private Const BIF_RETURNFSANCESTORS As Long = &H8
    6. Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
    7. Private Const BIF_BROWSEFORPRINTER As Long = &H2000
    8. Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
    9. Private Const MAX_PATH As Long = 260
    10. Dim filex As String
    11.  
    12.  
    13. Type BrowseInfo
    14.     hOwner As Long
    15.     pidlRoot As Long
    16.     pszDisplayName As String
    17.     lpszINSTRUCTIONS As String
    18.     ulFlags As Long
    19.     lpfn As Long
    20.     lParam As Long
    21.     iImage As Long
    22. End Type
    23.  
    24. Type SHFILEOPSTRUCT
    25.     hwnd As Long
    26.     wFunc As Long
    27.     pFrom As String
    28.     pTo As String
    29.     fFlags As Integer
    30.     fAnyOperationsAborted As Boolean
    31.     hNameMappings As Long
    32.     lpszProgressTitle As String
    33. End Type
    34.  
    35. Declare Function SHGetPathFromIDListA Lib "shell32.dll" ( _
    36.     ByVal pidl As Long, _
    37.     ByVal pszBuffer As String) As Long
    38.  
    39. Declare Function SHBrowseForFolderA Lib "shell32.dll" ( _
    40.     lpBrowseInfo As BrowseInfo) As Long
    41.  
    42.  
    43. Function BrowseFolder(Optional Caption As String = "") As String
    44.  
    45.     Dim BrowseInfo As BrowseInfo
    46.     Dim FolderName As String
    47.     Dim ID As Long
    48.     Dim Res As Long
    49.  
    50.     With BrowseInfo
    51.         .hOwner = 0
    52.         .pidlRoot = 0
    53.         .pszDisplayName = String$(MAX_PATH, vbNullChar)
    54.         .lpszINSTRUCTIONS = Caption
    55.         .ulFlags = BIF_RETURNONLYFSDIRS
    56.         .lpfn = 0
    57.     End With
    58.  
    59.     FolderName = String$(MAX_PATH, vbNullChar)
    60.  
    61.     ID = SHBrowseForFolderA(BrowseInfo)
    62.  
    63.     If ID Then
    64.         Res = SHGetPathFromIDListA(ID, FolderName)
    65.         If Res Then
    66.             BrowseFolder = Left$(FolderName, InStr(FolderName, _
    67.                 vbNullChar) - 1)
    68.         End If
    69.         End If
    70.  
    71. End Function

    Thanks
    KAZAR

    The Law Of Programming:

    As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
    __________________________________
    www.startingqbasic.co.uk

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Folder Browser Problem

    Add this constant
    VB Code:
    1. Private Const BIF_NEWDIALOGSTYLE As Long = &H40
    And change the ulFlags to
    VB Code:
    1. .ulFlags = BIF_RETURNONLYFSDIRS Or BIF_NEWDIALOGSTYLE
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Hyperactive Member kazar's Avatar
    Join Date
    Apr 2006
    Location
    UK
    Posts
    323

    Re: Folder Browser Problem

    thanks a tonne, that works brilliantly
    KAZAR

    The Law Of Programming:

    As the Number of Lines of code increases, the number of bugs generated by fixing a bug increases exponentially.
    __________________________________
    www.startingqbasic.co.uk

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Folder Browser Problem

    Please Mark your thread resolved by pulling down thread tools at the top of the thread and select Mark Thread Resolved.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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