Visualizzazione dei risultati da 1 a 5 su 5

Discussione: [VB6] Sfoglia cartelle

  1. #1
    Utente di HTML.it L'avatar di saraX
    Registrato dal
    Apr 2003
    Messaggi
    56

    [vb6] sfoglia... cartelle

    Ciao a tutti. Ecco la mia nuova questione:
    vorrei implementare un pulsantino Sfoglia... che mi restituisca in una txtBox il path selezionato dall'utente, ma senza che lui selezioni un file specifico.

    In primis avevo pensato alle commonDialog, perchè mi piace il modo in cui esplorano le risorse... però non mi sembra che ci sia un metodo adatto per aprire solo delle cartelle e non dei files.

    Qualcuno mi sa dare qualche dritta su come fare?
    Esiste qualche controllo già bello inscatolato che non conosco ?

    Grazie,
    Sara.

  2. #2
    Eccoti servita: dai un'occhiata a questo:
    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()
    
        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
    Ciao, ciao
    Simo

  3. #3
    Utente di HTML.it L'avatar di saraX
    Registrato dal
    Apr 2003
    Messaggi
    56
    ...direi su un piatto d'argento!
    Grazie!
    Sara.

  4. #4
    Ciao ragazzi!

    Io ho bisogno esattamente di quello che è stato postato sopra, però, in aggiunta, voglio che mi venga aperto e quindi che venga impostato per default un certo folder.
    E' possibile?

    Grazie.
    Non piangere per ciò che hai sbagliato ma per quello che non hai fatto per paura di sbagliare.

  5. #5
    Ho risolto!!



    Vi posto l'url dove ho trovato la soluzione.
    http://vbcity.com/forums/faq.asp?fid...ommon%20Dialog


    Grazie!
    Non piangere per ciò che hai sbagliato ma per quello che non hai fatto per paura di sbagliare.

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.