-
I downloaded this program, and it works fine like it is.
I then made an application using the wizard in VB5 that
looks like Explorer.
I pasted all of whats in the downloaded program into
the proper places(I'm pretty sure), but when I try to
run the program, I get an error:
(ImageList must be intialized before it can be used)
Do I really have to put in more code to intialize it?
Why does it work in the original like it is?
Code:
Option Explicit
' How to...
' by Philippe Durand
Private Sub DirFolders_Change()
filFiles.Path = DirFolders.Path
End Sub
Private Sub driDrives_Change()
DirFolders.Path = driDrives.Path
End Sub
Private Sub Form_Load()
Call BuildDriveList
End Sub
Private Sub BuildDriveList()
Dim i As Integer
Dim strPath As String
Dim intIcon As Integer
tvwDirectory.Nodes.Clear
For i = 0 To driDrives.ListCount - 1
strPath = UCase(Left(driDrives.List(i), 1)) & ":\"
Select Case strPath
Case "A:\", "B:\" ' Diskette drive.
intIcon = 1
Case "D:\"
intIcon = 3 ' CD drive.
Case Else ' Hard drive.
intIcon = 2
End Select
tvwDirectory.Nodes.Add , , strPath, driDrives.List(i), intIcon
tvwDirectory.Nodes.Add strPath, tvwChild, ""
Next
End Sub
Private Sub tvwDirectory_Expand(ByVal Node As ComctlLib.Node)
On Error GoTo ErrorTrapping
Dim i As Integer
Dim strRelative As String
Dim strFolderName As String
Dim intFolderPos As Integer
Dim intIcon As Integer
Dim strNewPath As String
Dim strExt As String
Dim intExtPos As Integer
MousePointer = vbHourglass
If Node.Child.Text = "" Then
tvwDirectory.Nodes.Remove Node.Child.Index
strRelative = Node.Key
DirFolders.Path = strRelative
intFolderPos = Len(strRelative) + 1
' Add folders
For i = 0 To DirFolders.ListCount - 1
strFolderName = Mid(DirFolders.List(i), intFolderPos)
strNewPath = strRelative & strFolderName & "\"
tvwDirectory.Nodes.Add strRelative, tvwChild, strNewPath, strFolderName, 4
DirFolders.Path = strNewPath
If (filFiles.ListCount > 0) Or (DirFolders.ListCount > 0) Then
tvwDirectory.Nodes.Add strNewPath, tvwChild, , ""
tvwDirectory.Nodes(strNewPath).ExpandedImage = 5
End If
DirFolders.Path = strRelative
Next
' Add files
For i = 0 To filFiles.ListCount - 1
strExt = UCase(filFiles.List(i))
intExtPos = InStr(strExt, ".") + 1
If intExtPos > 0 Then
strExt = Mid(strExt, intExtPos)
Else
strExt = ""
End If
Select Case strExt
Case "TXT", "DOC"
intIcon = 9
Case "HLP"
intIcon = 8
Case "EXE", "COM"
intIcon = 7
Case "BMP", "JPG", "GIF"
intIcon = 6
Case Else
intIcon = 10
End Select
tvwDirectory.Nodes.Add strRelative, tvwChild, , filFiles.List(i), intIcon
Next
End If
GoTo EndSub
ErrorTrapping:
' An error occurs when you try reading on a not ready drive
' re-add the precedent removed item
tvwDirectory.Nodes.Add Node.Key, tvwChild, , ""
Resume EndSub
EndSub:
MousePointer = vbDefault
End Sub
What I'm trying to do is make a program just like explorer
except were you can add notes out beside modified column on
the right side.
-
I guess what you are missing here is that you didnt associate the image list with listview or tree view control that you are using. Right click on the control and change it in the properties.
-
Doh!!
Doh!!
That was it Thanks.
But now it gave another error:
(Key is not unique in collection)
Any more ideas?
-
I guess you assigned the same key to more than one image in the imagelist control.
-
no key
There aren't any keys asigned to any images?
-
Yes, each Image in the ImageList have a Key and a Tag.
-
I don't see anything...
When I pull up the properties window for the ImageList
and go to the Image tab where the icons are there isn't
anything in the Key, or Tab boxes.
Is that where you're talking about, and do I need to
put something in those boxes, because there isn't
anything in them in the original program.
[Edited by catocom on 07-12-2000 at 08:42 PM]