Windows shell: need a good tutorial

Posted on 2003-03-18
Medium Priority
Last Modified: 2010-05-03
i'd like to create a folder listing using ListView & TreeView and i'd like it to look like Win-Explorer, for that i know i have to navigate through the shell namespace to list folders under my comptuer and get their icons... who can help me find a good tutorial for that ?

Question by:hatembr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

Cimperiali earned 500 total points
ID: 8158816
Star vb ide, and choose vb Application Wizard as project type (if chooses does not appear on opening vb, choose new project, and then Vb Application Wizard)
At first question on profile, click Next
At second question, choose "Explorer Style" and give the project a better name than "project1".
If you do not need menus, deselect on third page all what you see...Foolow wizard to the end.
You will have the front end completely setup by wizard.
Then you can add code to navigate throug folders and files, which goal you can obtain using filesystemObject (add a reference in your project to "Microsoft Scripting Runtime").
The following example works with all files and folders of "C:\" disk.
You can change it to work with all disk and to manage picture, also (but this require a bit more job)...
Add this declaration at top of form1 (after option explicit clause):
Private Fso As Scripting.FileSystemObject

'add this at form load event:
Dim folder As Scripting.folder
   'force form to show
   Me.Caption = "Please wait while loading..."
   tvTreeView.Style = tvwTreelinesPlusMinusPictureText
   tvTreeView.LineStyle = tvwRootLines
   Set Fso = New Scripting.FileSystemObject
      Set folder = Fso.GetFolder("C:\")
      tvTreeView.Nodes.Add , , "C:\", "C:\"
      Call addFiles(folder)
      Call filltreview(folder)
   Set Fso = Nothing
   Me.Caption = "Load completed!"
'Add these two private sub:
Private Sub filltreview(fldr As Scripting.folder)
Dim subFd As Scripting.folder
Dim fldrPath As String

On Error Resume Next
Debug.Print fldr.Name & " in " & fldr.Path
For Each subFd In fldr.SubFolders
   fldrPath = fldr.Path
   If Right(fldrPath, 1) <> "\" Then
      fldrPath = fldrPath & "\"
   End If
   tvTreeView.Nodes.Add fldrPath, tvwChild, fldrPath & subFd.Name & "\", subFd.Name
   If subFd.SubFolders.Count > 0 Then
      If Err.Number = 0 Then
         Call filltreview(subFd)
      End If
   End If
End Sub
Private Sub addFiles(fldr As Scripting.folder)
Dim fl As Scripting.File
For Each fl In fldr.Files
   lvListView.ListItems.Add , fl.Name, fl.Name
End Sub
'add this at nodeclick event of your treeview
Private Sub tvTreeView_NodeClick(ByVal Node As MSComctlLib.Node)
Set Fso = New Scripting.FileSystemObject
   Call addFiles(Fso.GetFolder(Node.Key))
Set Fso = Nothing
End Sub

Expert Comment

ID: 8532104
Hi hatembr,
This old question (QID 20554487) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.

Expert Comment

ID: 8982887
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

 -->Accept Cimperiali's as Answer
Please leave any comments here within the next seven days.


Cleanup Volunteer

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question