I'm trying to figure out how to get a browse box just for a path. I tried using the commondialog but that is just for saving and opening. Does anyone know the omponent that I have to add to get a browse directory box?
:p :p
Printable View
I'm trying to figure out how to get a browse box just for a path. I tried using the commondialog but that is just for saving and opening. Does anyone know the omponent that I have to add to get a browse directory box?
:p :p
I'm sending you an example of one of the forms I used in one of my applications to browse for a path
Here:
Put this in a module, or if you want it on a form, add Private where appropriate:
Just call the DirSelect function and it will display the dialog and return the path of the dir.VB Code:
Option Explicit 'Dir Select code Const BIF_RETURNONLYFSDIRS = 1 Const BIF_DONTGOBELOWDOMAIN = 2 Const MAX_PATH = 260 Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long Type BrowseInfo hWndOwner As Long pIDLRoot As Long pszDisplayName As Long lpszTitle As Long ulFlags As Long lpfnCallback As Long lParam As Long iImage As Long End Type Function DirSelect() As String 'Dir Select dialog code: Dim lpIDList As Long Dim sBuffer As String Dim szTitle As String Dim tBrowseInfo As BrowseInfo szTitle = "Choose Folder" With tBrowseInfo .hWndOwner = Form1.hWnd .lpszTitle = lstrcat(szTitle, "") .ulFlags = BIF_DONTGOBELOWDOMAIN + BIF_RETURNONLYFSDIRS End With lpIDList = SHBrowseForFolder(tBrowseInfo) If (lpIDList) Then sBuffer = Space(MAX_PATH) SHGetPathFromIDList lpIDList, sBuffer 'sBuffer value is the directory that the user choose from the dialog. sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1) DirSelect = sBuffer End If End Function
thanks all.
nishantp how would I make it open center owner?