Ouvrir browsefolder a un endroit bien precis

Résolu
petiflamand Messages postés 675 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 - 24 mars 2012 à 08:40
petiflamand Messages postés 675 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 - 25 mars 2012 à 08:40
Bonjour a tous ,


Je cherche comment faire pour ouvrir la boite de dialog dans un repertoire bien déterminé

j'utilise ceci
With udtBI
        .hwndOwner = hwndOwner
        '.lpszTitle = lstrcat("g:", "")
        .lpszTitle = lstrcat(sPrompt, "")
        .ulFlags = BIF_RETURNONLYFSDIRS
     End With

    
     lpIDList = SHBrowseForFolder(udtBI)

Mais il l'ouvre sur le poste de travail
alors que je voudrais l'ouvrir dans app.path

Merci d'avance

4 réponses

ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
24 mars 2012 à 12:28
Je me demande pourquoi, finalement, j'ai dit que ce serait si complexe !
Il suffit d'appeler mes trois héros préférés !
Exemple :
Sur un Form : un commandbutton1 et ce code (pour réveiller les 3 zozos) :
Private Sub Command1_Click()
  Dim ret As String
  ret = SelectFolder("Voilà mon ritre pour cette boîte", 0, "D:\monoutil\escales")
  MsgBox ret
End Sub

et dans un module bas : l'arrivée sur scène de ces 3 zozos :
Public Declare Function LocalAlloc Lib "kernel32" (ByVal uFlags As Long, ByVal uBytes As Long) As Long
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BROWSEINFO) As Long
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Declare Function LocalFree Lib "kernel32" (ByVal hMem As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Const LPTR = (&H0 Or &H40)
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public 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

Public Function SelectFolder(Ribouldingue As String, Croquignol As Long, Filochard As String) As String
  Dim lpIDList As Long
  Dim strBuffer As String
  Dim tBrowseInfo As BROWSEINFO
  Dim lptrInitPath As Long
  With tBrowseInfo
     .hwndOwner = Croquignol
     .lpszTitle = lstrcat(Ribouldingue, "")
     .ulFlags = BIF_RETURNONLYFSDIRS Or BIF_DONTGOBELOWDOMAIN Or BIF_EDITBOX Or BIF_NEWDIALOGSTYLE
     lptrInitPath = LocalAlloc(LPTR, Len(Filochard) + 1)
     CopyMemory ByVal lptrInitPath, ByVal Filochard, Len(Filochard) + 1
     .lParam = lptrInitPath
     .lpfnCallback = AddressOf2Ptr(AddressOf BrowseCallbackProc)
  End With
  lpIDList = SHBrowseForFolder(tBrowseInfo)
  LocalFree lptrInitPath
  If (lpIDList) Then
     strBuffer = String(260, vbNullChar)
     SHGetPathFromIDList lpIDList, strBuffer
     SelectFolder = Left(strBuffer, InStr(strBuffer, vbNullChar) - 1)
  End If
End Function
Private Function BrowseCallbackProc(ByVal les As Long, ByVal trois As Long, ByVal pieds As Long, ByVal Nickeles As Long) As Long
  If trois = 1 Then Call SendMessage(les, 1126, 1, ByVal Nickeles)
End Function
Public Function AddressOf2Ptr(ByVal Louis_Forton As Long) As Long
    AddressOf2Ptr = Louis_Forton
End Function


J'ai bien évidemment laissé à leur créateur le dernier mot.

____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
3
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
24 mars 2012 à 11:15
Bonjour, petitflamand,

La chose est à mon sens réalisable (en envoyant un message à la boîte de dialogue ouverte), mais de manière forcément alors complexe.
Es-tu bien certain d'en avoir réellement besoin ?
Si vraiment oui, je veux bien commencer à m'y mettre.
Dis-moi.


____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
24 mars 2012 à 12:36
Zut alors !
J'ai oublié les trois personnages présents dance ce code !
Les voilà donc, Les fameux trois zozos
Je les salue en ce début de week-end.


____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
petiflamand Messages postés 675 Date d'inscription samedi 31 mai 2003 Statut Membre Dernière intervention 26 mai 2013 1
25 mars 2012 à 08:40
Un très très grand Merci
ça fonctionne Nikel

Merci
0
Rejoignez-nous