Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

580 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