|
-
Feb 11th, 2008, 01:43 AM
#1
Thread Starter
Frenzied Member
-
Feb 11th, 2008, 02:03 AM
#2
Re: Browse Folder
I'm not going to be too much help. Your code works perfectly for me. This is how I used it:
Code:
Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_DONTGOBELOWDOMAIN = &H2
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_EDITBOX = &H10
Private Const BIF_VALIDATE = &H20
Private Const BIF_BROWSEFORCOMPUTER = &H1000
Private Const BIF_BROWSEFORPRINTER = &H2000
Private Const BIF_BROWSEINCLUDEFILES = &H4000
Private Const MAX_PATH = 260
Private Type T_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
Private Declare Function SHBrowseForFolder Lib "shell32" _
(lpbi As T_BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" _
(ByVal pidList As Long, _
ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal _
lpString2 As String) As Long
Public Function BrowseFolder(ByVal HwndOwner As Long, ByRef Titre As String) As String
Dim lpIDList As Long
Dim sBuffer As String
Dim BrowseInfo As T_BROWSEINFO
BrowseFolder = ""
With BrowseInfo
.HwndOwner = HwndOwner
.lpszTitle = lstrcat(Titre, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lpIDList = SHBrowseForFolder(BrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
BrowseFolder = sBuffer
End If
End Function
Private Sub Command1_Click()
Dim strString As String
strString = BrowseFolder(Me.hWnd, "A Title")
Text1.Text = strString
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Runing under XP SP2 but that shouldn't make a difference
-
Feb 11th, 2008, 10:19 AM
#3
Re: Browse Folder
It works fine for me as well.
-
Feb 11th, 2008, 10:22 AM
#4
Thread Starter
Frenzied Member
Re: Browse Folder
I have solve this program, the error is I put this in the command button. Text1.Text = strString & "\"
-
Feb 11th, 2008, 10:28 AM
#5
Addicted Member
Re: Browse Folder
 Originally Posted by matrik02
I have solve this program, the error is I put this in the command button. Text1.Text = strString & "\"
Perhaps you should think about why you've put it there in the first place and if removing it isn't reintroducing an old problem.
Jottum™
XpVistaControls , (transparent) usercontrols for XP, Vista and 7 with W2K legacy support.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|