Okay. Im taking a crack at my own player. I'm a decently experienced coder, but I'm stumped. Perhaps I am too close to the problem to see clearly.
Anyway, I'm working on an idea to use a TreeView control to explore directory structure and MP3 in the same window. Idea is to work with TreeView with checkboxes, so I can check songs and whole directories and for example add them all to a playlist, queue, etc.
I've tried numerous TreeView Controls. Current control is from VBAccellerator.
Code:
Option Explicit
Private m_cIml As New cVBALSysImageList
Private m_lID As Long
Private m_shl As New Shell
Private Sub Form_Load()
' Create a System Image List:
Set m_cIml = New cVBALSysImageList
m_cIml.IconSizeX = 16
m_cIml.IconSizeY = 16
m_cIml.Create
tvwDirs.ImageList = m_cIml.hIml
' Enumerate the shell's desktop folder for files
Dim drives As Folder
Set drives = m_shl.NameSpace("E:\ripped")
Dim driveItem As FolderItem
Dim nod As cTreeViewNode
Dim count As Long
Dim sKey As String
For Each driveItem In drives.items
If (driveItem.IsFolder) Then
m_lID = m_lID + 1
sKey = m_lID & ":" & driveItem.Path
Set nod = tvwDirs.nodes.Add(, , sKey, driveItem.Name, _
m_cIml.ItemIndex(driveItem.Path, True))
nod.ItemData = 0
m_lID = m_lID + 1
nod.Children.Add , , "TODO:" & m_lID, "Unexpanded"
Else
m_lID = m_lID + 1
sKey = m_lID & ":" & driveItem.Path
Set nod = tvwDirs.nodes.Add(, , sKey, driveItem.Name, _
m_cIml.ItemIndex(driveItem.Path, True))
nod.ItemData = 1
End If
Next
End Sub
Private Sub tvwDirs_BeforeExpand(node As vbalTreeViewLib6.cTreeViewNode, cancel As Boolean)
If InStr(node.FirstChild.Key, "TODO:") = 1 Then
Screen.MousePointer = vbHourglass
node.Children.Remove 1
Dim items As Folder
Dim itm As FolderItem
Dim nod As cTreeViewNode
Dim sKey As String
Dim iPos As Long
Dim nodes As cTreeViewNodes
Set nodes = node.Children
sKey = node.Key
iPos = InStr(sKey, ":")
sKey = Mid(sKey, iPos + 1)
Set items = m_shl.NameSpace(sKey)
If Not items Is Nothing Then
For Each itm In items.items
If (itm.IsFolder) Then
m_lID = m_lID + 1
sKey = m_lID & ":" & itm.Path
Set nod = nodes.Add(, , sKey, itm.Name, _
m_cIml.ItemIndex(itm.Path, True))
nod.ItemData = 0
m_lID = m_lID + 1
nod.Children.Add , , "TODO:" & m_lID, "Unexpanded"
Else
m_lID = m_lID + 1
sKey = m_lID & ":" & itm.Path
Set nod = nodes.Add(, , sKey, itm.Name, _
m_cIml.ItemIndex(itm.Path, True))
nod.ItemData = 1
End If
Next
End If
node.Sort etvwItemDataThenAlphabetic
Screen.MousePointer = vbDefault
End If
End Sub
This should loop and display the subfolders of the base directory on FormLoad.. and it does.
On Expand of Tree tvwDirs_BeforeExpand should then loop and display subfolders of current node on each expand. and it does not.
I have no doubt it is a silly syntax issue, but I can't find it.
Thanks in advance for any help.
Jack
Bookmarks