after playing a while with the treeview gadget I'm looking for a solution to change the
image after a node is opend.
I only found this thread
viewtopic.php?t=7407
but the example file is not abailable. Could anybody help with this

Code: Select all
#Tree = 0
#Button = 1
;Images. Load your own here.
img0 = LoadImage(0, "new.ico")
img1 = LoadImage(1, "open.ico")
img2 = LoadImage(2, "save.ico")
;The following procedure cheats and uses PB to add our icons to the tree gadget's 'normal' image list prior to adding our normal
;items. It is usually easier to add all icons first before attempting to switch images etc.
Procedure AddIconToTree(id, hImage)
AddGadgetItem(id, 0, "", hImage)
RemoveGadgetItem(id, 0)
EndProcedure
If OpenWindow(0, 0, 0, 300, 300, "PureBasic Window",#PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
TreeGadget(#Tree, 10, 10, 280, 250, #PB_Tree_AlwaysShowSelection)
;Add our 3 icons before adding items to the tree gadget.
AddIconToTree(#Tree, img0)
AddIconToTree(#Tree, img1)
AddIconToTree(#Tree, img2)
;Add some items.
AddGadgetItem(#Tree, -1, "Parent", img0, 0)
AddGadgetItem(#Tree, -1, "Child", img1, 1)
ButtonGadget(#Button, 10, 270, 100, 20, "CHANGE ICONS!")
Repeat
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Button
;Change the two items icons to the 3rd icon we loaded.
With tvi.TVITEM
\mask = #TVIF_IMAGE|#TVIF_HANDLE|#TVIF_SELECTEDIMAGE
\iImage = 3 ;Image index 3 (the 3rd icon - actually, it is the 4th icon, but that is another story!).
\iSelectedImage = 3
EndWith
For i = 0 To 1
tvi\hItem = GadgetItemID(#Tree, i)
SendMessage_(GadgetID(#TREE), #TVM_SETITEM, 0, tvi)
Next
EndSelect
EndSelect
Until Quit = 1
EndIf
End
Your choice - I do this kind of thing quite often to good effect.pb-user wrote:srod,
thx for example code. I think better to keep the static icon.![]()
Or I will use the explorer gadget.