Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hidden Folders with directory list box question

Status
Not open for further replies.

Tckazz

Technical User
Feb 19, 2002
17
US
Is there a simple way to get the directory list box to display hidden folders?

I saw a post from 4 years ago with no answer, I thought I would post the question again and see if someone has some ideas.

Thanks

TcKazz
 
Sadly, unlike the FileListbox, the DirListbox does not have a handy Hidden property to make this easy. One approach would be to write a function that:

a) uses whatever technique you like to get a list of the hidden folders in a named folder

b) uses the API (LB_ADDSTRING) to add those folders (using full path) to the DirListBox

And that's it. Here's my version, which uses the FileSystemObject for part a:
Code:
[COLOR=blue]Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_ADDSTRING = &H180


Private Sub GetHiddenFolders(myDirListBox As DirListBox)
    Dim myFolder As Object
    Dim strPath As String
    Dim Hidden As Long
    
    Hidden = 2
    With CreateObject("scripting.filesystemobject")
        For Each myFolder In .GetFolder(myDirListBox.Path).SubFolders
            If (myFolder.Attributes And Hidden) = Hidden Then
                strPath = myFolder.Name
                SendMessage myDirListBox.hwnd, LB_ADDSTRING, 0&, ByVal strPath
            End If
        Next
    End With
End Sub
[/color]
 
Once again - he came, he saw, he APIed...

I would have starred this myself only my browser seems to have a scripting fault that prevents it working. I will be starring it tonight though...

mmilan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top