Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    Aprire "Sfoglia cartelle" da visual basic 6.0

    vorrei sapere come posso fare per far comparire la finestra "sfoglia cartelle" cliccando sopra un bottone all'interno di un programma vb. Cioè ho un campo testo nel quale voglio andare a memorizzare il percorso di una foto, in seguito questo percorso lo devo poi salvare sul DB.
    Grazie

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Utilizza il controllo CommonDialog

  3. #3
    Se non sbaglio le CommonDialog per VB6 non includono la finestra "Sfoglia cartelle"; se non sbaglio comunque dovrebbe esserci qualche API in shell32.dll... prova a dare un'occhiata sulla MSDN.
    Amaro C++, il gusto pieno dell'undefined behavior.

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Giusto ... mi era sfuggito il fatto che ci si riferisse alle cartelle ... la API e' la SHBrowseForFolder

    Un esempio, tratto da www.allapi.net

    codice:
    Private Type BrowseInfo
        hWndOwner As Long
        pIDLRoot As Long
        pszDisplayName As Long
        lpszTitle As Long
        ulFlags As Long
        lpfnCallback As Long
        lParam As Long
        iImage As Long
    End Type
    Const BIF_RETURNONLYFSDIRS = 1
    Const MAX_PATH = 260
    Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
    Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
    Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
    Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
    Private Sub Form_Load()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'KPDTeam@Allapi.net
        Dim iNull As Integer, lpIDList As Long, lResult As Long
        Dim sPath As String, udtBI As BrowseInfo
    
        With udtBI
            'Set the owner window
            .hWndOwner = Me.hWnd
            'lstrcat appends the two strings and returns the memory address
            .lpszTitle = lstrcat("C:\", "")
            'Return only if the user selected a directory
            .ulFlags = BIF_RETURNONLYFSDIRS
        End With
    
        'Show the 'Browse for folder' dialog
        lpIDList = SHBrowseForFolder(udtBI)
        If lpIDList Then
            sPath = String$(MAX_PATH, 0)
            'Get the path from the IDList
            SHGetPathFromIDList lpIDList, sPath
            'free the block of memory
            CoTaskMemFree lpIDList
            iNull = InStr(sPath, vbNullChar)
            If iNull Then
                sPath = Left$(sPath, iNull - 1)
            End If
        End If
    
        MsgBox sPath
    End Sub

  5. #5
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    perfetto

    però in qualche programma ho visto che veniva usata una finestra simile ma in cui compariva anche il pulsante "crea cartella"...

    Si può fare?
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

  6. #6
    Utente di HTML.it L'avatar di wallrider
    Registrato dal
    Apr 2003
    Messaggi
    2,755
    RIP Cicciobenzina 9/11/2010

    "Riseminaciceli, i ceci nell'orto"

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.