elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  necesito desplegar un cuadro de dialogo para directorios
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: necesito desplegar un cuadro de dialogo para directorios  (Leído 5,539 veces)
WHK
Moderador Global
***
Desconectado Desconectado

Mensajes: 6.589


Sin conocimiento no hay espíritu


Ver Perfil WWW
necesito desplegar un cuadro de dialogo para directorios
« en: 7 Octubre 2009, 05:20 am »

Hola, estaba buscando algo como esto:



pero quería saber como hacer funcionar la api o funcion o lo que sea de forma nativa de windows ya que solamente encuentro formularios fabricados que no sirven de mucho.

Gracias.


En línea

BlackZeroX
Wiki

Desconectado Desconectado

Mensajes: 3.158


I'Love...!¡.


Ver Perfil WWW
Re: necesito desplegar un cuadro de dialogo para directorios
« Respuesta #1 en: 7 Octubre 2009, 05:48 am »


http://allapi.mentalis.org/apilist/FindFirstFile.shtml

hay te explican sobre las apis, FindFirstFile es para buscar Archivos y directorios. en esa pagina hay un ejemplo sobre su uso.

Dulces Lunas!¡.


En línea

The Dark Shadow is my passion.
WHK
Moderador Global
***
Desconectado Desconectado

Mensajes: 6.589


Sin conocimiento no hay espíritu


Ver Perfil WWW
Re: necesito desplegar un cuadro de dialogo para directorios
« Respuesta #2 en: 7 Octubre 2009, 07:20 am »

de verdad gracias por darte tu tiempo en responder pero no tiene nada que ver con lo que necesito XD

No necesito saber como manipular archivos sino "desplegar" una ventana de busqueda de directorios como esta:


habrá alguna api o lo que sea que pueda utilizar esta ventana de forma similar al commondialog 6? o forzadamente tendré que hacer un dirlist en un form nuevo?

Edito:
acabo de encontrar un ejemplo pero en javascript:
Código
  1. var objShell = new ActiveXObject("Shell.Application");
  2. var objFolder = new Object;
  3. objFolder = objShell.BrowseForFolder(0, "Select folder", 0,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}");

Lo guardo en un archivo x.js y le hago doble click:


Necesito eso pero en VB6  :P
« Última modificación: 7 Octubre 2009, 07:24 am por WHK » En línea

WHK
Moderador Global
***
Desconectado Desconectado

Mensajes: 6.589


Sin conocimiento no hay espíritu


Ver Perfil WWW
Re: necesito desplegar un cuadro de dialogo para directorios
« Respuesta #3 en: 7 Octubre 2009, 07:33 am »

bueno ya lo encontré xD
la función de la api se llama BrowseForFolder
http://allapi.mentalis.org/apilist/774F8232380EA83E4CF374E8F31ED355.html

Código
  1. Private Type BrowseInfo
  2.    hWndOwner As Long
  3.    pIDLRoot As Long
  4.    pszDisplayName As Long
  5.    lpszTitle As Long
  6.    ulFlags As Long
  7.    lpfnCallback As Long
  8.    lParam As Long
  9.    iImage As Long
  10. End Type
  11. Const BIF_RETURNONLYFSDIRS = 1
  12. Const MAX_PATH = 260
  13. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
  14. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  15. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
  16. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
  17. Private Sub Form_Load()
  18.    'KPD-Team 1998
  19.    'URL: http://www.allapi.net/
  20.    'KPDTeam@Allapi.net
  21.    Dim iNull As Integer, lpIDList As Long, lResult As Long
  22.    Dim sPath As String, udtBI As BrowseInfo
  23.  
  24.    With udtBI
  25.        'Set the owner window
  26.        .hWndOwner = Me.hWnd
  27.        'lstrcat appends the two strings and returns the memory address
  28.        .lpszTitle = lstrcat("C:\", "")
  29.        'Return only if the user selected a directory
  30.        .ulFlags = BIF_RETURNONLYFSDIRS
  31.    End With
  32.  
  33.    'Show the 'Browse for folder' dialog
  34.    lpIDList = SHBrowseForFolder(udtBI)
  35.    If lpIDList Then
  36.        sPath = String$(MAX_PATH, 0)
  37.        'Get the path from the IDList
  38.        SHGetPathFromIDList lpIDList, sPath
  39.        'free the block of memory
  40.        CoTaskMemFree lpIDList
  41.        iNull = InStr(sPath, vbNullChar)
  42.        If iNull Then
  43.            sPath = Left$(sPath, iNull - 1)
  44.        End If
  45.    End If
  46.  
  47.    MsgBox sPath
  48. End Sub
En línea

seba123neo
Moderador
***
Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: necesito desplegar un cuadro de dialogo para directorios
« Respuesta #4 en: 8 Octubre 2009, 02:13 am »

mira aca tenes un ejemplo con WSH:

Diálogo de windows para seleccionar carpeta

o con la api SHBrowseForFolder :

Cuadro de diálogo Buscar carpeta

saludos.

En línea

WHK
Moderador Global
***
Desconectado Desconectado

Mensajes: 6.589


Sin conocimiento no hay espíritu


Ver Perfil WWW
Re: necesito desplegar un cuadro de dialogo para directorios
« Respuesta #5 en: 8 Octubre 2009, 10:13 am »

si, ya las habia visto, de hecho la imagen que puse era de ese msmo lugar xD
pero acá dejo la función que armé por si a alguien le hace falta:

Dialogo.bas
Código
  1. Option Explicit
  2.  
  3. Private Type BrowseInfo
  4.    hWndOwner As Long
  5.    pIDLRoot As Long
  6.    pszDisplayName As Long
  7.    lpszTitle As Long
  8.    ulFlags As Long
  9.    lpfnCallback As Long
  10.    lParam As Long
  11.    iImage As Long
  12. End Type
  13. Private Const BIF_RETURNONLYFSDIRS = 1
  14. Private Const MAX_PATH = 260
  15. Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
  16. Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
  17. Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
  18. Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
  19.  
  20. Public Function Dir_Dialogo() As String
  21. Dim iNull As Integer, lpIDList As Long, lResult As Long
  22. Dim sPath As String, udtBI As BrowseInfo
  23.  
  24. With udtBI
  25.  'Set the owner window
  26.  .hWndOwner = Form1.hWnd
  27.  'lstrcat appends the two strings and returns the memory address
  28.  .lpszTitle = lstrcat("Seleccione el directorio", ":")
  29.  'Return only if the user selected a directory
  30.  .ulFlags = BIF_RETURNONLYFSDIRS
  31. End With
  32.  
  33. 'Show the 'Browse for folder' dialog
  34. lpIDList = SHBrowseForFolder(udtBI)
  35.  
  36. If lpIDList Then
  37.  sPath = String$(MAX_PATH, 0)
  38.  'Get the path from the IDList
  39.  SHGetPathFromIDList lpIDList, sPath
  40.  'free the block of memory
  41.  CoTaskMemFree lpIDList
  42.  iNull = InStr(sPath, vbNullChar)
  43.  If iNull Then
  44.   sPath = Left$(sPath, iNull - 1)
  45.  End If
  46. End If
  47.  
  48. If Len(sPath) > 0 Then
  49.  If Not Right(sPath, 1) = "\" Then
  50.   Dir_Dialogo = sPath & "\"
  51.  Else
  52.   Dir_Dialogo = sPath
  53.  End If
  54. End If
  55.  
  56. End Function
  57.  

Y funciona así:
Código
  1. Private Sub Boton_Click()
  2. Dim Directorio As String
  3. ' Establece el directorio
  4. Directorio = Dir_Dialogo
  5. ' Verifica que haya valor, o sea que no hayan cancelado
  6. If Len(Directorio) > 0 Then
  7.  Text.Text = Directorio
  8. End If
  9. End Sub
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines