Programación General > Visual Basic 6.0 e inferiores
Re: Necesito un ejemplo de TreeView completo
Jessuss:
A ver, necesito si me podeis ayudar ejemplo con un TreeView, el cual me muestre el esquema interno de MiPc al estilo explorador de windows.
Gracias de antemano.:question:
ROBER.29:
Con este código podrás utilizar el seleccionador de carpetas del windows. Aquí te dejo el código: En un formulario añade un commandButton que se llame cmdExaminar y un textbox que se llame txtRuta.
{Form Code}
'Este código lo pones en el código del formulario
Private Sub cmdExaminar_click ()
txtRuta.Text = Module1.GetFolder(Form1.hWnd, "Select folder")
End Sub
{Module Code}
'Agregas un módulo y le pegas este código.
Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Const BIF_RETURNONLYFSDIRS = &H1
Const BIF_DONTGOBELOWDOMAIN = &H2
Const BIF_STATUSTEXT = &H4
Const BIF_RETURNFSANCESTORS = &H8
Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_BROWSEFORPRINTER = &H2000
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
Function GetFolder(ByVal hWndOwner As Long, ByVal sTitle As String) As String
Dim bInf As BROWSEINFO
Dim RetVal As Long
Dim PathID As Long
Dim RetPath As String
Dim Offset As Integer
bInf.hOwner = hWndOwner
bInf.lpszTitle = sTitle
bInf.ulFlags = BIF_RETURNONLYFSDIRS
PathID = SHBrowseForFolder(bInf)
RetPath = Space$(512)
RetVal = SHGetPathFromIDList(ByVal PathID, ByVal RetPath)
If RetVal Then
Offset = InStr(RetPath, Chr$(0))
GetFolder = Left$(RetPath, Offset - 1)
End If
End Function
Espero que te sirva.
Saludos,
Roberto García
Jessuss:
Muchas gracias, lo probaré y te contaré que tal.:lightsabre:
Jessuss:
Funciona, muchas gracias :yes:
Jessuss:
Perdona Rober.29, pero me sabrias decir si hay algun parámetro o alguna forma con la cual pueda sacar los ficheros o .txt que hay dentro de las carpetas?
Gracias de nuevo.
Navegación
[#] Página Siguiente
Ir a la versión completa