| Usuario |
CommoDialog para seleccionar carpe... |
Desconocido
|
| Enviado - 5/3/2003 |
| |
Como se puede lanzar un CommonDialog para que pueda seleccionar carpetas y no ficheros.
gracias a todos. |
| |
|
fmarredo
486 Mensaje(s)
|
| Enviado - 5/3/2003 |
| |
Te paso algo para eso:
En un módulo general:
Option Explicit
Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
sDisplayName As String
sTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const MAX_PATH = 260
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (bBrowse As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" (ByVal lItem As Long, ByVal sDir As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Public Function BuscarCarpeta(Optional ByVal Titulo As String) As String
Dim browse_info As BrowseInfo
Dim Item As Long
Dim dir_name As String
If Len(Titulo) = 0 Then
Titulo = "Seleccione la carpeta"
End If
With browse_info
.hWndOwner = Screen.ActiveForm.hWnd 'necesita el handler de algún formulario
.pIDLRoot = 0
.sDisplayName = Space$(MAX_PATH)
.sTitle = Titulo
.ulFlags = BIF_RETURNONLYFSDIRS
.lpfn = 0
.lParam = 0
.iImage = 0
End With
Item = SHBrowseForFolder(browse_info)
If Item Then
dir_name = Space$(MAX_PATH)
If SHGetPathFromIDList(Item, dir_name) Then
BuscarCarpeta = Left$(dir_name, InStr(dir_name, vbNullChar) - 1)
Else
BuscarCarpeta = vbNullString
End If
End If
End Function
'**Fin del modulo **********************
MODO DE USO:
txtRuta.Text = BuscarCarpeta("Seleccione la ruta") |
| |
|
Desconocido
|
| Enviado - 6/3/2003 |
| |
Gracias, la verdad es que lo estaba buscando para VB.Net y la solucion que me has dado tiene algunos problemas con .Net, pero quizas puede adaptarlo.
|
| |
|
|
|