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

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Crear carpeta usando SHBrowseForFolder
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Crear carpeta usando SHBrowseForFolder  (Leído 5,055 veces)
Jeronimo17

Desconectado Desconectado

Mensajes: 31


Ver Perfil
Crear carpeta usando SHBrowseForFolder
« en: 3 Enero 2007, 05:37 am »

Hola,

Tengo una preguntita sobre directorios, uso SHBrowseForFolder para mostrar un dialogo con los directorios, de donde cojo la ruta y guardo el archivo ahi, todo eso muy bien, pero queria añadirle un boton para crear nueva carpeta

¿Es posible? ¿Como seria?

Gracias  ;)

Código:
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
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 Function BrowseForDirectory() As String
Dim browse_info As BrowseInfo
Dim item As Long
Dim dir_name As String
   
   browse_info.hWndOwner = hwnd
   browse_info.pidlRoot = 0
   browse_info.sDisplayName = Space$(260)
   browse_info.sTitle = "Selecionar una Carpeta"
   browse_info.ulFlags = 1 ' devuelve el nombre del directorio.
   browse_info.lpfn = 0
   browse_info.lParam = 0
   browse_info.iImage = 0
   
   item = SHBrowseForFolder(browse_info)
   If item Then
       dir_name = Space$(260)
       If SHGetPathFromIDList(item, dir_name) Then
           BrowseForDirectory = Left(dir_name, _
               InStr(dir_name, Chr$(0)) - 1)
       Else
           BrowseForDirectory = ""
       End If
   End If
End Function


En línea

~~
Ex-Staff
*
Desconectado Desconectado

Mensajes: 2.981


Ver Perfil WWW
Re: Crear carpeta usando SHBrowseForFolder
« Respuesta #1 en: 3 Enero 2007, 13:16 pm »

Si, tienes q usar mkdir. Ej:

Código:
MkDir ("C:\zzz")

1S4ludo


En línea

CeLaYa


Desconectado Desconectado

Mensajes: 543



Ver Perfil
Re: Crear carpeta usando SHBrowseForFolder
« Respuesta #2 en: 3 Enero 2007, 14:42 pm »

lo haces con la propiedad ulFlags

Código:
browse_info.ulFlags = BIF_USENEWUI Or BIF_RETURNONLYFSDIRS

también te dejo otras opciones que puesdes aplicar...
Código:
'For finding a folder to start document searching
Private Const BIF_RETURNONLYFSDIRS As Long = &H1

'For starting the Find Computer
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2

'Top of the dialog has 2 lines of text for
'BROWSEINFO.lpszTitle and one line if this flag is set.
'Passing the message BFFM_SETSTATUSTEXTA to the hwnd
'can set the rest of the text.  This is not used with
'BIF_USENEWUI and BROWSEINFO.lpszTitle gets all three
'lines of text.
Private Const BIF_STATUSTEXT As Long = &H4

Private Const BIF_RETURNFSANCESTORS As Long = &H8

'Add an editbox to the dialog: SHELL 5.0 or later only!
Private Const BIF_EDITBOX As Long = &H10

'insist on valid result (or CANCEL)
Private Const BIF_VALIDATE As Long = &H20

'Use the new dialog layout with the ability
'to resize: SHELL 5.0 or later only!
Private Const BIF_NEWDIALOGSTYLE As Long = &H40
Private Const BIF_USENEWUI As Long = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)

'Allow URLs to be displayed or entered
'(Requires BIF_USENEWUI): SHELL 5.0 or later only!
Private Const BIF_BROWSEINCLUDEURLS As Long = &H80

'Add a UA hint to the dialog, in place of the
'edit box. May not be combined with BIF_EDITBOX: SHELL 6.0 or later only!
Private Const BIF_UAHINT As Long = &H100

'Do not add the "New Folder" button to the dialog.
'Only applicable with BIF_NEWDIALOGSTYLE: SHELL 5.0 or later only!
Private Const BIF_NONEWFOLDERBUTTON As Long = &H200

'Browsing for Computers
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000

'Browsing for Printers
Private Const BIF_BROWSEFORPRINTER As Long = &H2000

'Browsing for Everything
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000

'sharable resources displayed (remote shares,
'requires BIF_USENEWUI): SHELL 5.0 or later only!
Private Const BIF_SHAREABLE As Long = &H8000&
En línea

"La soledad es el elemento de los grandes talentos".
Cristina de Suecia (1626-1689) Reina de Suecia.
Jeronimo17

Desconectado Desconectado

Mensajes: 31


Ver Perfil
Re: Crear carpeta usando SHBrowseForFolder
« Respuesta #3 en: 3 Enero 2007, 18:02 pm »

Muchas Gracias a los 2 por responder, estoy contento lo he conseguio :)

No se nada de Api, pero me ha salido, asi Funciona:

Código:
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
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
'Add an editbox to the dialog: SHELL 5.0 or later only!
Private Const BIF_EDITBOX As Long = &H10

'insist on valid result (or CANCEL)
Private Const BIF_NEWDIALOGSTYLE As Long = &H40
Private Const BIF_USENEWUI As Long = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)




Private Function BrowseForDirectory() As String
Dim browse_info As BrowseInfo
Dim item As Long
Dim dir_name As String
   
   browse_info.hWndOwner = hwnd
   browse_info.pidlRoot = 0
   browse_info.sDisplayName = Space$(260)
   browse_info.sTitle = "Selecionar una Carpeta"
   browse_info.ulFlags = 1 ' devuelve el nombre del directorio.
   browse_info.lpfn = 0
   browse_info.lParam = 0
   browse_info.iImage = 0
   browse_info.ulFlags = BIF_USENEWUI Or BIF_RETURNONLYFSDIRS
   item = SHBrowseForFolder(browse_info)
   If item Then
       dir_name = Space$(260)
       If SHGetPathFromIDList(item, dir_name) Then
           BrowseForDirectory = Left(dir_name, _
               InStr(dir_name, Chr$(0)) - 1)
       Else
           BrowseForDirectory = ""
       End If
   End If
End Function

Private Sub Command3_Click()

sRutaBrowserFolder = BrowseForDirectory

End Sub

Gracias y Saludos
En línea

CeLaYa


Desconectado Desconectado

Mensajes: 543



Ver Perfil
Re: Crear carpeta usando SHBrowseForFolder
« Respuesta #4 en: 3 Enero 2007, 18:55 pm »

creo que te faltaría declarar la constante BIF_RETURNONLYFSDIRS y te sobra la linea "browse_info.ulFlags = 1 ' devuelve el nombre del directorio."
En línea

"La soledad es el elemento de los grandes talentos".
Cristina de Suecia (1626-1689) Reina de Suecia.
Jeronimo17

Desconectado Desconectado

Mensajes: 31


Ver Perfil
Re: Crear carpeta usando SHBrowseForFolder
« Respuesta #5 en: 16 Marzo 2007, 17:10 pm »

Hola depues de todo esto que funciona bien, tengo una ultima duda.

Este es el codigo que tengo:

Código:
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 Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
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
'Add an editbox to the dialog: SHELL 5.0 or later only!
Private Const BIF_EDITBOX As Long = &H10

'insist on valid result (or CANCEL)
Private Const BIF_NEWDIALOGSTYLE As Long = &H40
Private Const BIF_USENEWUI As Long = (BIF_NEWDIALOGSTYLE Or BIF_EDITBOX)
Private Const BIF_RETURNONLYFSDIRS As Long = 1



Código:
Private Function BrowseForDirectory() As String
Dim browse_info As BrowseInfo
Dim item As Long
Dim dir_name As String
   
   browse_info.hWndOwner = hWnd
   browse_info.pidlRoot = Carpeta
   browse_info.sDisplayName = Space$(260)
   browse_info.sTitle = "Selecionar una Carpeta"
   browse_info.lpfn = 0
   browse_info.lParam = 0
   browse_info.iImage = 0
   browse_info.ulFlags = BIF_USENEWUI Or BIF_RETURNONLYFSDIRS
   item = SHBrowseForFolder(browse_info)
   If item Then
       dir_name = Space$(260)
       If SHGetPathFromIDList(item, dir_name) Then
           BrowseForDirectory = Left(dir_name, _
               InStr(dir_name, Chr$(0)) - 1)
               Carpeta = item
            Else
           BrowseForDirectory = ""
       End If
   End If
End Function



Código:
Private Sub Command3_Click()
sRutaBrowserFolder = BrowseForDirectory
Label8.Caption = sRutaBrowserFolder
End Sub

La variable Carpeta es la que guarda el numero referente a la ruta, y funciona bien, pero el problema es que depues me parte de ahi el arbol de directorios y no llega hasta Mi PC, o sea ,que no se puede llegar a la raiz, si no de la ruta guardada para delante

Ejemplo:



¿Alguna solucion?  :-(

Gracias de nuevo a todos  ;)
« Última modificación: 16 Marzo 2007, 17:20 pm por Jeronimo17 » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Crear biocomputadoras usando tumores cerebrales
Foro Libre
crazykenny 1 1,994 Último mensaje 25 Marzo 2012, 22:01 pm
por Graphixx
Cuadro de diálogo para elegir carpeta (no SHBrowseForFolder)
Programación C/C++
‭‭‭‭jackl007 0 1,474 Último mensaje 21 Octubre 2014, 23:08 pm
por ‭‭‭‭jackl007
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines