home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Explorer_v53475262002.psc / mExplorerTree.bas < prev    next >
Encoding:
BASIC Source File  |  2001-12-20  |  4.1 KB  |  82 lines

  1. Attribute VB_Name = "mExplorerTree"
  2. '***********************************************************************************
  3. 'Populates a TreeView with the sub Folder`s of the selected Drive or Folder.
  4. '***********************************************************************************
  5.  
  6. Option Explicit
  7.  
  8. Public Sub subShowFolderList(oFolderList As ListBox, oExplorerTree As TreeView, sDriveLetter As String, vParentID As Variant)
  9.     
  10.     Dim nNode As Node                           'Node object for ExplorerTree.
  11.     Dim lReturn As Long                         'Holds Search Handle of File.
  12.     Dim lNextFile As Long                       'Return Search Handle of next Folder.
  13.     Dim sPath As String                         'Path to search.
  14.     Dim WFD As WIN32_FIND_DATA                  'Win32 Structure (VB Type).
  15.     Dim sFolderName As String                   'Name of Folder.
  16.     Dim x As Long                               'Used to loop through Folders in frmMain.List1).
  17.     
  18.     'Return all Folders from selected Drive.----------------------------------------
  19.     sPath$ = (sDriveLetter & "*.*") & Chr$(0)
  20.     '-------------------------------------------------------------------------------
  21.     
  22.     'Search for First Folder Handle.------------------------------------------------
  23.     lReturn& = FindFirstFile(sPath$, WFD)
  24.     '-------------------------------------------------------------------------------
  25.     
  26.     'Loop through all Folders (One level).------------------------------------------
  27.     Do
  28.  
  29.         'If a Folder is found add to oFolderList.------------------------------------
  30.         If (WFD.dwFileAttributes And vbDirectory) Then
  31.             
  32.             'Strip vbNullChar from Folder Name.-------------------------------------
  33.             sFolderName$ = mProcFunc.ftnStripNullChar(WFD.cFileName)
  34.             '-----------------------------------------------------------------------
  35.             
  36.             If sFolderName$ <> "." And sFolderName$ <> ".." Then
  37.                 
  38.                 'If the Folder has an Attribute <> 16 then add "~A~" to it.---------
  39.                 If WFD.dwFileAttributes <> 16 Then
  40.                     oFolderList.AddItem sFolderName$ & "~A~"
  41.                 Else
  42.                     oFolderList.AddItem sFolderName$ & "~~~"
  43.                 End If
  44.                 '-------------------------------------------------------------------
  45.  
  46.             End If
  47.         End If
  48.         '---------------------------------------------------------------------------
  49.         
  50.         'Search for Handle of next Folder.------------------------------------------
  51.         lNextFile& = FindNextFile(lReturn&, WFD)
  52.         '---------------------------------------------------------------------------
  53.  
  54.     Loop Until lNextFile& = False
  55.     '-------------------------------------------------------------------------------
  56.   
  57.     'Close Handle of Folder.--------------------------------------------------------
  58.     lNextFile& = FindClose(lReturn&)
  59.     '-------------------------------------------------------------------------------
  60.  
  61.     'Loop through oFolderList which has it`s sorted property set to True, then add---
  62.     'Folder Path to ExplorerTree
  63.     For x = 0 To oFolderList.ListCount - 1
  64.  
  65.         'If the Folder has an Attribute, set ForeColor to Grey----------------------
  66.         If Right(oFolderList.List(x), 3) = "~A~" Then
  67.             Set nNode = oExplorerTree.Nodes.Add(vParentID, tvwChild, , Left(oFolderList.List(x), Len(oFolderList.List(x)) - 3), "cldfoldera", "opnfoldera")
  68.             nNode.ForeColor = RGB(205, ght(oeo----------------------------------------------------------------------------
  69.  
  70.     nerTree.Nodes.Add( "opnr
  71.             Set nNo
  72.  
  73. erList.---------
  74.  
  75.     nerTree.Nodes.a(0)
  76.  n
  77.     nerTree.Nes.A'sI,r'o
  78. ist.-----m  nerTree.NNes.A'sI,r'o
  79. ist.-----m  nerTree.NNes.A'sI,r'o
  80. ist.-----m  nerTree.NNes.A'sI,r'o
  81. i  v
  82.     nerTree.NoderW---------------------vC-------sSe-------lder  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r