Add libraries (eg Music) to ExplorerTreeGadget?
Posted: Tue May 29, 2018 7:36 am
I am using the ExplorerTreeGadget and associated gadgets for a custom-built file browser, so I can include controls for previewing audio files. However, the PureBasic ExplorerTreeGadget only includes Documents as an additional item, so to get to libraries such as Music the users has to navigate through the relevant parent directories. On searching for a solution in the PB Forums I found a similar request from oryaaaaa which contained some code provided by RASHAD. That code was written for Win7, and I've tried to use this (slightly modified) on my Win10 development machine, but the code does not seem to detect that the libraries contain any sub-directories (which they do).
Here's the code I'm using:
When I run this code, the public music, pictures and videos folders are displayed without the '+', even though they contain sub-directories.
Does the above code need changing for Win10? Should this code handle sub-directories?
Here's the code I'm using:
Code: Select all
#TVGN_LASTVISIBLE = 10
Procedure AddItem(gadget.l, text.s)
hRoot = SendMessage_(GadgetID(gadget), #TVM_GETNEXTITEM, #TVGN_LASTVISIBLE, 0)
lpis.TV_INSERTSTRUCT
lpis\hParent = SendMessage_(GadgetID(gadget), #TVM_GETNEXTITEM, #TVGN_PARENT, hRoot)
lpis\hInsertAfter = hRoot
lpis\item\mask = #TVIF_TEXT
lpis\item\cchTextMax = Len(text)
lpis\item\pszText = @text
SendMessage_(GadgetID(gadget), #TVM_INSERTITEM, 0, @lpis)
EndProcedure
OpenWindow(0, 0, 0, 300, 350, "ExplorerTreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ExplorerTreeGadget(0, 10, 10, 280, 280, "*.*")
SetWindowLongPtr_(GadgetID(0), #GWL_STYLE, GetWindowLongPtr_(GadgetID(0), #GWL_STYLE) | #TVS_CHECKBOXES|#TVS_TRACKSELECT)
If OSVersion() >= #PB_OS_Windows_7
AddItem(0,"C:\Users\Public\Public Music")
AddItem(0,"C:\Users\Public\Public Pictures")
AddItem(0,"C:\Users\Public\Public Videos")
EndIf
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
Does the above code need changing for Win10? Should this code handle sub-directories?