Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

Puedo saber el nombre de un directorio a partir del CommonDialog?

Estas en el tema de Puedo saber el nombre de un directorio a partir del CommonDialog? en el foro de Visual Basic clásico en Foros del Web. Buenas, me presento al foro. Estoy haciendo una pequeña aplicacion que tiene una funcion de ver fotos. Lo que quiero es que de alguna manera, ...
  #1 (permalink)  
Antiguo 17/03/2006, 11:49
 
Fecha de Ingreso: marzo-2006
Mensajes: 29
Antigüedad: 18 años, 1 mes
Puntos: 0
Puedo saber el nombre de un directorio a partir del CommonDialog?

Buenas, me presento al foro.

Estoy haciendo una pequeña aplicacion que tiene una funcion de ver fotos.

Lo que quiero es que de alguna manera, mediante el commondialog, pueda seleccionar, una foto, pero que el resto de fotos de ese directorio me las carge en un listbox o algun otro sitio, para poder visionarlas todas.

No se si me explico.

Tampoco quiero usar un DirlistBox porque me rompe la estetica del programa.

Gracias.

P.D. Tengo otra pregunta, abrire otro post.
  #2 (permalink)  
Antiguo 17/03/2006, 14:00
Avatar de [EX3]  
Fecha de Ingreso: marzo-2006
Ubicación: Fuenlabrada, Madrid
Mensajes: 203
Antigüedad: 18 años, 1 mes
Puntos: 1
En vez de un CommonDialog usa un BrowseDialog:
Código:
Option Explicit

Private Const BIF_BROWSEFORCOMPUTER = 1000
Private Const BIF_BROWSEFORPRINTER = 2000
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const BIF_RETURNFSANCESTORS = 8
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_STATUSTEXT = 4
Private Const MAX_SIZE = 255

Private Type BROWSEINFO
         hwndOwner 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

Private Declare Function BrowseFolderDlg Lib "shell32.dll" Alias "SHBrowseForFolder" (lpBrowseInfo As BROWSEINFO) As Long
Private Declare Function GetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDList" (ByVal PointerToIDList As Long, ByVal pszPath As String) As Long

 Private Sub Form_Load()
MsgBox DLG_BrowseFolder(Me.hwnd, "Elija directorio para obtener su ruta:")

 End Sub

 Private Function DLG_BrowseFolder(hwnd As Long, Title As String) As String
On Local Error Resume Next

Dim mBrowseInfo As BROWSEINFO
Dim mPointerToIDList As Long
Dim mResult As Long
Dim mPathBuffer As String
Dim sReturn As String

        ' this string is returned as result if you have canceled the action
         'sReturn = "You canceled operation"
         sReturn = ""
         With mBrowseInfo
                     ' set parent window (hWnd of this window)
                      .hwndOwner = hwnd
                       ' set start folder (0=desktor folder)
                      .pidlRoot = 0
                       ' dialog title
                      .lpszTitle = Title
                      ' pointer to a buffer that receives the display name of the folder selected by the user
                      .pszDisplayName = String(MAX_SIZE, Chr(0))
                       ' value specifying the types of folders to be listed in the dialog box as well as other options
                      .ulFlags = BIF_RETURNONLYFSDIRS
         End With
         ' returns a pointer to an item identifier list that specifies the location of the selected folder relative to the root of the name space
          mPointerToIDList = BrowseFolderDlg(mBrowseInfo)

         If mPointerToIDList <> 0& Then
                       ' create a buffer
                      mPathBuffer = String(MAX_SIZE, Chr(0))
                       ' now get the selected path
                      mResult = GetPathFromIDList(ByVal mPointerToIDList, ByVal mPathBuffer)
                       ' returned path
                      sReturn = VBA.Left$(mPathBuffer, InStr(mPathBuffer, Chr(0)) - 1)  'and return just that
         End If

DLG_BrowseFolder = sReturn

 End Function 
Salu2...
__________________
Proyecto dx_lib32 (http://dxlib32.se32.com) Libreria DLL ActiveX para el desarollo de juegos y programas multimedia en Visual Basic 6.0 con la potencia de DirectX

Dice un dicho que "el que calla otorga". En internet tenemos otro que dice "nunca alimentes a un troll" que viene a decir "dejale hablar solo que se ya se cansara de incordiar". Solo los necios creen tener la razon con la ultima palabra.

  #3 (permalink)  
Antiguo 17/03/2006, 15:30
 
Fecha de Ingreso: marzo-2006
Mensajes: 29
Antigüedad: 18 años, 1 mes
Puntos: 0
Es perfecto, muchas gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 12:26.