Results 1 to 3 of 3

Thread: common dialog

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    SA
    Posts
    17

    common dialog

    If anybody knows how to open a windows 2000 dialog that will enable the user to select a path or a folder (not files) please tell me how, I needed to know that yesterday.
    thanks

  2. #2
    Matthew Gates
    Guest
    Try this:


    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
    45.  
    46.  
    47.  
    48. Private Sub Command1_Click()
    49.     Msgbox BrowseForFolder(hWnd, "Select a Directory..")
    50. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Apr 2001
    Location
    SA
    Posts
    17
    Thanks I got the answer on aother thread so dont worry unless someone knows of a new 2000 one thanks

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