Faire sortir le "browser" pour récupérer un chemin
2 réponses
Lunis82
J'ai écri du code pour ouvrir le browser et récupérer un chemin mais
aparement je me suis trompé sur ( preske ) toute la ligne
pouvez vous m'aider je pense a un flag mais lekel?
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Clive Lumb
"Lunis82" a écrit dans le message de news:
J'ai écri du code pour ouvrir le browser et récupérer un chemin mais aparement je me suis trompé sur ( preske ) toute la ligne pouvez vous m'aider je pense a un flag mais lekel?
merci d'avance
Lunis82
Voici comment je fais:
Private Const BIF_RETURNONLYFSDIRS = 1 Private Const BIF_DONTGOBELOWDOMAIN = 2 Private Const BIF_BROWSEINCLUDEFILES = 16384 Private Const MAX_PATH = 260 Dim Old_Path As String Dim WorkingPath as String
Private Declare Function SHBrowseForFolder Lib "shell32" _ (lpbi As 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
Private 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
Private Sub Command1_Click() 'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long Dim sBuffer As String Dim szTitle As String Dim tBrowseInfo As BrowseInfo
szTitle = "Choose the database folder and file" With tBrowseInfo .hWndOwner = Me.hwnd .lpszTitle = lstrcat(szTitle, "") .ulFlags = BIF_RETURNONLYFSDIRS + BIF_BROWSEINCLUDEFILES '+ BIF_DONTGOBELOWDOMAIN End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then sBuffer = Space(MAX_PATH) SHGetPathFromIDList lpIDList, sBuffer sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1) If UCase$(Right$(sBuffer, 3)) <> "MDB" Then MsgBox "Must be an ACCESS MDB file ! Using default demo db.." WorkingPath = App.Path & "demo.mdb" Me.txt_database.Text = WorkingPath Else WorkingPath = sBuffer Me.txt_database.Text = WorkingPath End If End If End Sub
"Lunis82" <Lunis82@discussions.microsoft.com> a écrit dans le message de
news:8FE47CED-6586-4770-979B-C79CBB7C4A01@microsoft.com...
J'ai écri du code pour ouvrir le browser et récupérer un chemin mais
aparement je me suis trompé sur ( preske ) toute la ligne
pouvez vous m'aider je pense a un flag mais lekel?
merci d'avance
Lunis82
Voici comment je fais:
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const BIF_BROWSEINCLUDEFILES = 16384
Private Const MAX_PATH = 260
Dim Old_Path As String
Dim WorkingPath as String
Private Declare Function SHBrowseForFolder Lib "shell32" _
(lpbi As 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
Private 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
Private Sub Command1_Click()
'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
szTitle = "Choose the database folder and file"
With tBrowseInfo
.hWndOwner = Me.hwnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_BROWSEINCLUDEFILES '+
BIF_DONTGOBELOWDOMAIN
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
If UCase$(Right$(sBuffer, 3)) <> "MDB" Then
MsgBox "Must be an ACCESS MDB file ! Using default demo
db.."
WorkingPath = App.Path & "demo.mdb"
Me.txt_database.Text = WorkingPath
Else
WorkingPath = sBuffer
Me.txt_database.Text = WorkingPath
End If
End If
End Sub
J'ai écri du code pour ouvrir le browser et récupérer un chemin mais aparement je me suis trompé sur ( preske ) toute la ligne pouvez vous m'aider je pense a un flag mais lekel?
merci d'avance
Lunis82
Voici comment je fais:
Private Const BIF_RETURNONLYFSDIRS = 1 Private Const BIF_DONTGOBELOWDOMAIN = 2 Private Const BIF_BROWSEINCLUDEFILES = 16384 Private Const MAX_PATH = 260 Dim Old_Path As String Dim WorkingPath as String
Private Declare Function SHBrowseForFolder Lib "shell32" _ (lpbi As 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
Private 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
Private Sub Command1_Click() 'Opens a Treeview control that displays the directories in a computer
Dim lpIDList As Long Dim sBuffer As String Dim szTitle As String Dim tBrowseInfo As BrowseInfo
szTitle = "Choose the database folder and file" With tBrowseInfo .hWndOwner = Me.hwnd .lpszTitle = lstrcat(szTitle, "") .ulFlags = BIF_RETURNONLYFSDIRS + BIF_BROWSEINCLUDEFILES '+ BIF_DONTGOBELOWDOMAIN End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then sBuffer = Space(MAX_PATH) SHGetPathFromIDList lpIDList, sBuffer sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1) If UCase$(Right$(sBuffer, 3)) <> "MDB" Then MsgBox "Must be an ACCESS MDB file ! Using default demo db.." WorkingPath = App.Path & "demo.mdb" Me.txt_database.Text = WorkingPath Else WorkingPath = sBuffer Me.txt_database.Text = WorkingPath End If End If End Sub
Gloops
Bonjour,
Peut-être est-ce ceci que tu as oublié ? Moyennant quoi ton code fonctionne. J'ai aussi fait un copier-coller du nom de fonction GetOpenFileName, qui a été décisif, pourtant je ne vois pas l'erreur dessus.
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _ Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type
Dim w_ofn_fic As OPENFILENAME
Bonjour,
Peut-être est-ce ceci que tu as oublié ?
Moyennant quoi ton code fonctionne. J'ai aussi fait un copier-coller du
nom de fonction GetOpenFileName, qui a été décisif, pourtant je ne vois
pas l'erreur dessus.
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Private Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Peut-être est-ce ceci que tu as oublié ? Moyennant quoi ton code fonctionne. J'ai aussi fait un copier-coller du nom de fonction GetOpenFileName, qui a été décisif, pourtant je ne vois pas l'erreur dessus.
Private Declare Function GetOpenFileName Lib "comdlg32.dll" _ Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long Private Type OPENFILENAME lStructSize As Long hwndOwner As Long hInstance As Long lpstrFilter As String lpstrCustomFilter As String nMaxCustFilter As Long nFilterIndex As Long lpstrFile As String nMaxFile As Long lpstrFileTitle As String nMaxFileTitle As Long lpstrInitialDir As String lpstrTitle As String flags As Long nFileOffset As Integer nFileExtension As Integer lpstrDefExt As String lCustData As Long lpfnHook As Long lpTemplateName As String End Type