Other virtual folders for ExplorerTreeGadget()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Marc56us
Addict
Addict
Posts: 1477
Joined: Sat Feb 08, 2014 3:26 pm

Other virtual folders for ExplorerTreeGadget()

Post by Marc56us »

Hi PB Team,

:idea: It would be nice to have for ExplorerTreeGadget(), not only #PB_Directory_Documents, but also the other virtual folders (if possible ?)

#PB_Directory_Desktop
#PB_Directory_Downloads
#PB_Directory_Pictures
#PB_Directory_Musics
#PB_Directory_Videos
#PB_Directory_Public

:arrow: So flag to disable it, like: _NoMyDocuments
#PB_Explorer_NoMyDocuments : The 'My Documents' Folder will not be displayed as a separate item.

Thank's
:wink:
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Other virtual folders for ExplorerTreeGadget()

Post by RSBasic »

I don't know if this wish function will be implemented, otherwise with own code?
Example:

Code: Select all

EnableExplicit

Procedure AddTreeGadgetSpecialItem(Gadget, ItemText$, Image)
  Protected TV_INSERTSTRUCT.TV_INSERTSTRUCT
  Protected ImageList
  Protected ItemIcon
  
  ImageList = SendMessage_(GadgetID(Gadget), #TVM_GETIMAGELIST, #TVSIL_NORMAL, 0)
  ItemIcon = ImageList_AddIcon_(ImageList, Image)
  
  TV_INSERTSTRUCT\hParent = 0
  TV_INSERTSTRUCT\hInsertAfter = #TVI_FIRST
  TV_INSERTSTRUCT\Item\Mask = #TVIF_TEXT | #TVIF_IMAGE | #TVIF_SELECTEDIMAGE
  TV_INSERTSTRUCT\Item\pszText = @ItemText$
  TV_INSERTSTRUCT\Item\cchTextMax = Len(ItemText$)
  TV_INSERTSTRUCT\item\iImage = ItemIcon
  TV_INSERTSTRUCT\item\iSelectedImage = ItemIcon
  
  SendMessage_(GadgetID(Gadget), #TVM_INSERTITEM, 0, TV_INSERTSTRUCT)
  
  ImageList_Destroy_(ImageList)
  
EndProcedure

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ExplorerTreeGadget(1, 0, 0, WindowWidth(0), WindowHeight(0), "", 0)
  
  AddTreeGadgetSpecialItem(1, "Desktop", ExtractIcon_(GetModuleHandle_(0), "imageres.dll", 125))
  AddTreeGadgetSpecialItem(1, "Downloads", ExtractIcon_(GetModuleHandle_(0), "imageres.dll", 175))
  AddTreeGadgetSpecialItem(1, "Pictures", ExtractIcon_(GetModuleHandle_(0), "imageres.dll", 108))
  AddTreeGadgetSpecialItem(1, "Musics", ExtractIcon_(GetModuleHandle_(0), "imageres.dll", 103))
  AddTreeGadgetSpecialItem(1, "Videos", ExtractIcon_(GetModuleHandle_(0), "imageres.dll", 178))
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
(Only Windows and my example code is incomplete.)
Image
Image
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Other virtual folders for ExplorerTreeGadget()

Post by Kwai chang caine »

and my example code is incomplete
Yes but it works, thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply