Visualizzazione dei risultati da 1 a 6 su 6

Discussione: Sfoglia Cartelle

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2003
    Messaggi
    12

    Sfoglia Cartelle

    salve a tutti

    dunque io ho questo codice :

    Option Explicit

    Private Type BROWSEINFO
    hOwner 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 Const BIF_RETURNONLYFSDIRS = &H1
    Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
    Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)

    Public Function SfogliaCartelle(ByVal Handle As Long) As String
    Dim BInfo As BROWSEINFO
    Dim CartellaScelta As Long
    Dim PercorsoAllocato As Long
    Dim PercorsoScelto As String
    BInfo.hOwner = Handle
    BInfo.lpszTitle = "Scegli una cartella:"
    BInfo.ulFlags = BIF_RETURNONLYFSDIRS
    PercorsoAllocato = SHBrowseForFolder(BInfo)
    PercorsoScelto = Space$(512)
    CartellaScelta = SHGetPathFromIDList(PercorsoAllocato, PercorsoScelto)
    If CartellaScelta Then
    SfogliaCartelle = Left$(PercorsoScelto, InStr(PercorsoScelto, Chr$(0)) - 1)
    CoTaskMemFree PercorsoAllocato
    Else
    SfogliaCartelle = ""
    End If
    End Function

    Private Sub Sfoglia_Click()
    Percorso.Text = SfogliaCartelle(Me.hWnd)
    End Sub



    bene, detto ciò questo codice mi permette di sfogliare le cartelle ed inserirle su un campo textbox

    ma che stringa devo modificare se necessito di sfogliare l'esplora risorse per intero?, cioè per far in modo di visualizzare anche dei file di testo che dovrei poi,eventualmente, far caricare sulla text box?

    mammamia che macello.... :quipy:

  2. #2
    prova con questo codice, non so se è quel che cerchi

    Private Const VER_PLATFORM_WIN32_NT = 2
    Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
    End Type
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
    Private Declare Function GetFileNameFromBrowseW Lib "shell32" Alias "#63" (ByVal hwndOwner As Long, ByVal lpstrFile As Long, ByVal nMaxFile As Long, ByVal lpstrInitialDir As Long, ByVal lpstrDefExt As Long, ByVal lpstrFilter As Long, ByVal lpstrTitle As Long) As Long
    Private Declare Function GetFileNameFromBrowseA Lib "shell32" Alias "#63" (ByVal hwndOwner As Long, ByVal lpstrFile As String, ByVal nMaxFile As Long, ByVal lpstrInitialDir As String, ByVal lpstrDefExt As String, ByVal lpstrFilter As String, ByVal lpstrTitle As String) As Long

    Private Sub Form_Load()
    Dim sSave As String
    sSave = Space(255)
    'Sistema operativo NT
    If IsWinNT Then
    GetFileNameFromBrowseW Me.hwnd, StrPtr(sSave), 255, StrPtr("c:\"), StrPtr("txt"), StrPtr("Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), StrPtr("The Title")
    'Sistema operativo NON NT
    Else
    GetFileNameFromBrowseA Me.hwnd, sSave, 255, "c:\", "txt", "Text files (*.txt)" + Chr$(0) + "*.txt" + Chr$(0) + "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0), "The Title"
    End If
    'Show the result
    MsgBox "File selezionato " & sSave
    End Sub

    Public Function IsWinNT() As Boolean
    Dim myOS As OSVERSIONINFO
    myOS.dwOSVersionInfoSize = Len(myOS)
    GetVersionEx myOS
    IsWinNT = (myOS.dwPlatformId = VER_PLATFORM_WIN32_NT)
    End Function

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2003
    Messaggi
    12
    si il codice è giusto

    però mi da errore sul codice del bottone "sfoglia" e cioè questo:

    Private Sub Sfoglia_Click()
    Percorso.Text = SfogliaCartelle(Me.hWnd)
    End Sub


  4. #4
    ma hai modificato la sub SfogliaCartelle?

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2003
    Messaggi
    12
    grazie tante

    tutto risolto

  6. #6
    OK

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.