Pb selection repertoire urgent help svp!!

BadAcid - 16 avril 2001 à 19:08
EvilGost Messages postés 235 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 16 mai 2011 - 8 févr. 2005 à 12:27
G un gros pb:
comment on fait pour afficher une boite de dialogue (ouvrir)qui permet de selectionner un répertoire, et non un fichier???
je voudrais que l'utilisateur voie une boite de dial qui lui demande ou il a installé ses fichier d'u certain type.
Merci d'avance.

5 réponses

Met ceci dans un module:

'
' Origine:  http://www.vbthunder.com/source/explorer/folderbrowse.htm
'=====
'
'  Exemple d'utilisation:
'
'Private Sub cmdFolder_Click()
'     Dim sFolder As String
'     sFolder = GetFolder(hwnd)
'     If Len(sFolder) > 0 Then
'          MsgBox "Folder selected was: " & sFolder
'     Else
'          MsgBox "No folder selected!"
'     End If
'End Sub
'

Public Type BROWSEINFO
     hOwner As Long
     pidlRoot As Long
     pszDisplayName As String
     lpszTitle As String
     ulFlags As Long
     lpfn As Long
     lParam As Long
     iImage As Long
End Type

'BROWSEINFO.ulFlags values:
Public Const BIF_RETURNONLYFSDIRS = &H1
Public Const BIF_DONTGOBELOWDOMAIN = &H2
Public Const BIF_STATUSTEXT = &H4
Public Const BIF_RETURNFSANCESTORS = &H8
Public Const BIF_BROWSEFORCOMPUTER = &H1000
Public Const BIF_BROWSEFORPRINTER = &H2000

Public Declare Function SHGetPathFromIDList Lib "shell32.dll" _
     Alias "SHGetPathFromIDListA" (ByVal pidl As Long, _
     ByVal pszPath As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32.dll" _
     Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)

Public Function GetFolder(ByVal hWndModal As Long) As String
     Dim bInf As BROWSEINFO
     Dim RetVal As Long
     Dim PathID As Long
     Dim RetPath As String
     Dim Offset As Integer
     'Set the properties of the folder dialog
     bInf.hOwner = hWndModal
     bInf.lpszTitle = "Please select a folder:"
     bInf.ulFlags = BIF_RETURNONLYFSDIRS
     'Show the Browse For Folder dialog
     PathID = SHBrowseForFolder(bInf)
     RetPath = Space$(512)
     RetVal = SHGetPathFromIDList(ByVal PathID, ByVal RetPath)
     If RetVal Then
          'Trim off the null chars ending the path
          'and display the returned folder
          Offset = InStr(RetPath, Chr$(0))
          GetFolder = Left$(RetPath, Offset - 1)
          'Free memory allocated for PIDL
          CoTaskMemFree PathID
     Else
          GetFolder = ""
     End If
End Function
0
manoloelfanjo Messages postés 13 Date d'inscription mercredi 10 juillet 2002 Statut Membre Dernière intervention 19 septembre 2003
13 mars 2003 à 11:03
Super, c exactement ce que je voulais !
Bien joué, Mariner...

Manolo
0
cs_Imagine Messages postés 8 Date d'inscription mardi 17 décembre 2002 Statut Membre Dernière intervention 13 octobre 2004
9 sept. 2003 à 01:49
Imagine

Cette source est bien mais ne propose malheureusement pas toutes les possibilités de la common dialogue ouvrir...

Moi perso j'utilise un 'bug' (si on peut dire) de cette derniere,
je m'explique:
cmd etant un commondialog

cmd.FileName = "1"
cmd.DialogTitle = "Selectionner un dossier."
cmd.ShowOpen
If cmd.FileName <> "" Then
If cmd.FileName Like "*.*" Then 'si un fichier est select.
txtDoss.Text = Fso.GetFile(cmd.FileName).ParentFolder.Path
Else 'sinon
txtDoss.Text = Mid(cmd.FileName, 1, Len(cmd.FileName) - 2)
End If
End If

Voila j'espere que ca va aider quelqu'un !
(j'ai pas essayer toutes les bugs de ce code. Ca peut poser quelques problemes...)
0
vaneri2004 Messages postés 28 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 17 février 2006
20 déc. 2004 à 09:03
Merci merci bien cher Imagine. Simple et éfficace :)
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
EvilGost Messages postés 235 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 16 mai 2011 2
8 févr. 2005 à 12:27
Merci Mariner, je cherchais aussi et ca marche impec'

EvilGost
0
Rejoignez-nous