Accueil > > > BOITE DE DIALOGUE PARCOURIR REPERTOIRE
BOITE DE DIALOGUE PARCOURIR REPERTOIRE
Information sur la source
Description
J'ai trouve sur ce site une source qui permet d'utiliser la boite de dialogue parcourir repertoire de windows grace aux api. Mais le probleme etait que lors de l'ouverture de la boite de dialogue on se retrouvait toujours sur poste de travail.... Pauvre utilisateur qui met dix plombes a trouver son repertoire et qui veut en changer... La source n'est pas de moi mais comme j'ai vraiment gallerer pour la trouver je veux vous en faire profiter :
Source
- '==================================
- ' Code trouve sur le site :
- ' http://www.c2i.fr/code.asp?IDCode=1083
- '==================================
- 'a mettre dans un module :
- '==================================
- Private Const BIF_STATUSTEXT = &H4&
- Private Const BIF_RETURNONLYFSDIRS = 1
- Private Const BIF_DONTGOBELOWDOMAIN = 2
- Private Const MAX_PATH = 260
-
- Private Const WM_USER = &H400
- Private Const BFFM_INITIALIZED = 1
- Private Const BFFM_SELCHANGED = 2
- Private Const BFFM_SETSTATUSTEXT = (WM_USER + 100)
- Private Const BFFM_SETSELECTION = (WM_USER + 102)
-
- Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
- 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 m_CurrentDirectory As String 'The current directory
-
- Public Function BrowseForFolder(owner As Form, Title As String, StartDir As String) As String
- 'ouvre la boite de dialogue sélectionnant un dossier
-
- Dim lpIDList As Long
- Dim szTitle As String
- Dim sBuffer As String
- Dim tBrowseInfo As BrowseInfo
- m_CurrentDirectory = StartDir & vbNullChar
-
- szTitle = Title
- With tBrowseInfo
- .hWndOwner = owner.hWnd
- .lpszTitle = lstrcat(szTitle, "")
- .ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_STATUSTEXT
- .lpfnCallback = GetAddressofFunction(AddressOf BrowseCallbackProc) 'get address of function.
- End With
-
- lpIDList = SHBrowseForFolder(tBrowseInfo)
- If (lpIDList) Then
- sBuffer = Space(MAX_PATH)
- SHGetPathFromIDList lpIDList, sBuffer
- sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
- BrowseForFolder = sBuffer
- Else
- BrowseForFolder = ""
- End If
-
- End Function
-
- Private Function BrowseCallbackProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal lp As Long, ByVal pData As Long) As Long
-
- Dim lpIDList As Long
- Dim ret As Long
- Dim sBuffer As String
-
- On Error Resume Next 'Sugested by MS to prevent an error from
- 'propagating back into the calling process.
-
- Select Case uMsg
-
- Case BFFM_INITIALIZED
- Call SendMessage(hWnd, BFFM_SETSELECTION, 1, m_CurrentDirectory)
- Case BFFM_SELCHANGED
- sBuffer = Space(MAX_PATH)
- ret = SHGetPathFromIDList(lp, sBuffer)
- If ret = 1 Then
- Call SendMessage(hWnd, BFFM_SETSTATUSTEXT, 0, sBuffer)
- End If
- End Select
-
- BrowseCallbackProc = 0
-
- End Function
-
- ' This function allows you to assign a function pointer to a vaiable.
- Private Function GetAddressofFunction(add As Long) As Long
- GetAddressofFunction = add
- End Function
-
-
- '=====================================
- 'exemple d'utilisation, dans une procedure
- '=====================================
- Dim rep as String
- rep = BrowseForFolder(Me, "Un texte", "c:\windows\")
-
'==================================
' Code trouve sur le site :
' http://www.c2i.fr/code.asp?IDCode=1083
'==================================
'a mettre dans un module :
'==================================
Private Const BIF_STATUSTEXT = &H4&
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260
Private Const WM_USER = &H400
Private Const BFFM_INITIALIZED = 1
Private Const BFFM_SELCHANGED = 2
Private Const BFFM_SETSTATUSTEXT = (WM_USER + 100)
Private Const BFFM_SETSELECTION = (WM_USER + 102)
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
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 m_CurrentDirectory As String 'The current directory
Public Function BrowseForFolder(owner As Form, Title As String, StartDir As String) As String
'ouvre la boite de dialogue sélectionnant un dossier
Dim lpIDList As Long
Dim szTitle As String
Dim sBuffer As String
Dim tBrowseInfo As BrowseInfo
m_CurrentDirectory = StartDir & vbNullChar
szTitle = Title
With tBrowseInfo
.hWndOwner = owner.hWnd
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_STATUSTEXT
.lpfnCallback = GetAddressofFunction(AddressOf BrowseCallbackProc) 'get address of function.
End With
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
BrowseForFolder = sBuffer
Else
BrowseForFolder = ""
End If
End Function
Private Function BrowseCallbackProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal lp As Long, ByVal pData As Long) As Long
Dim lpIDList As Long
Dim ret As Long
Dim sBuffer As String
On Error Resume Next 'Sugested by MS to prevent an error from
'propagating back into the calling process.
Select Case uMsg
Case BFFM_INITIALIZED
Call SendMessage(hWnd, BFFM_SETSELECTION, 1, m_CurrentDirectory)
Case BFFM_SELCHANGED
sBuffer = Space(MAX_PATH)
ret = SHGetPathFromIDList(lp, sBuffer)
If ret = 1 Then
Call SendMessage(hWnd, BFFM_SETSTATUSTEXT, 0, sBuffer)
End If
End Select
BrowseCallbackProc = 0
End Function
' This function allows you to assign a function pointer to a vaiable.
Private Function GetAddressofFunction(add As Long) As Long
GetAddressofFunction = add
End Function
'=====================================
'exemple d'utilisation, dans une procedure
'=====================================
Dim rep as String
rep = BrowseForFolder(Me, "Un texte", "c:\windows\")
Conclusion
Merci à l'auteur de cette source, qui m'a bien aidée alors j'espere qu'elle vous aidera également A la prochaine pour d'autres sources...
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|