Treegadget problem...
Treegadget problem...
Does anybody know how can i make some items in a treegadget have normal buttons (+'es) and some have checkboxes? AFAIK PB only allows creation of only-checkbox treegadget or simple ones with buttons...
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
I think you'll have to supply your own stateicon images. So you'll either have to add them to the treeview image list or create a new image list from scratch. Of course PB already supplies it's own state images for the checkboxes and so you'll either need to replace these or add a couple more as required.
Afraid I haven't any example code to help out and I reckon it could be quite a bit of work if you're actually going to add more icons to those already there as you'll have to take charge of the hit-testing and deciding exactly which images to show etc. Some subclassing involved, but I don't think it will prove too difficult.
Afraid I haven't any example code to help out and I reckon it could be quite a bit of work if you're actually going to add more icons to those already there as you'll have to take charge of the hit-testing and deciding exactly which images to show etc. Some subclassing involved, but I don't think it will prove too difficult.
I may look like a mule, but I'm not a complete ass.
Oh, i see... I was afraid there isn't a simple method to do this... I think i'll have to change the strategy if i can't get it to work... Found some code to add custom images to the imagelist on the forum and i hope it will not be too hard to make something usefull with it.
Thank you for the idea
.
Thank you for the idea

None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Using the #TVS_CHECKBOXES style only makes use of two stateicons (checked and non-checked) which is probably not enough for your requirements and so you'd probably have to dispense with this flag and 'go it alone'!
Of course checkboxes and such like are in addition to any icons you may associate with an item. So if you don't require both, then maybe you can use the regular icons to give you the effect you're after. This would still require some hit-testing though.
Of course checkboxes and such like are in addition to any icons you may associate with an item. So if you don't require both, then maybe you can use the regular icons to give you the effect you're after. This would still require some hit-testing though.
I may look like a mule, but I'm not a complete ass.
http://www.purebasic.fr/english/viewtop ... checkboxes
Just found something cool
. I'll post here if i'll make it... BTW, i only need checkboxes so i guess it's easy... Thank you for the help 
Just found something cool


None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
In terms of checkboxes, all that code does is add the #TVS_CHECKBOXES style to the underlying tree gadget which forms the basis of the explorer tree.
Code: Select all
#TVS_CHECKBOXES = $100
If OpenWindow(0, 0, 0, 300, 300, "ExplorerTreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
ExplorerTreeGadget(0, 10, 10, 280, 280, "*.pb;*.pbi")
SetWindowLong_(GadgetID(0),#GWL_STYLE,GetWindowLong_(GadgetID(0),#GWL_STYLE) | #TVS_CHECKBOXES )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
I may look like a mule, but I'm not a complete ass.

Code: Select all
Procedure RemoveTVIcheckbox(tvGadget, item)
tvi.TV_ITEM
tvi\mask = #TVIF_HANDLE | #TVIF_STATE
tvi\hItem = GadgetItemID(tvGadget, item)
tvi\state = 0 << 12
tvi\stateMask = #TVIS_STATEIMAGEMASK
SendMessage_(GadgetID(1), #TVM_SETITEM, 0, tvi)
EndProcedure
If OpenWindow(0, 0, 0, 400, 380, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
TreeGadget(1, 180, 10, 160, 360, #PB_Tree_CheckBoxes)
For a = 0 To 4
AddGadgetItem (1, -1, "Normal Item "+Str(a), 0, 0)
AddGadgetItem (1, -1, "Node "+Str(a), 0, 0)
AddGadgetItem(1, -1, "Sub-Item 1", 0, 1)
AddGadgetItem(1, -1, "Sub-Item 2", 0, 1)
AddGadgetItem(1, -1, "Sub-Item 3", 0, 1)
AddGadgetItem(1, -1, "Sub-Item 4", 0, 1)
AddGadgetItem (1, -1, "File "+Str(a), 0, 0)
Next a
RemoveTVIcheckbox(1, 1)
RemoveTVIcheckbox(1, 6)
For i = 8 To 12
RemoveTVIcheckbox(1, i)
Next i
SetGadgetItemState(1, 8, #PB_Tree_Expanded)
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
It's not that Sparks, I think Info is after two different types of checkbox or, one set of checkbox buttons and another set of push buttons instead etc.
I think that having first added a couple more images to the image list (3<<12 and 4<<12) we could then perhaps use your code to set the required state. But I've a feeling that, in this case, Windows will cycle through all 4 checkbox images as you click each check mark and thus we need to intercept the relevant notifications etc.
I think that having first added a couple more images to the image list (3<<12 and 4<<12) we could then perhaps use your code to set the required state. But I've a feeling that, in this case, Windows will cycle through all 4 checkbox images as you click each check mark and thus we need to intercept the relevant notifications etc.
I may look like a mule, but I'm not a complete ass.
Actually Sparks, I may have misread Info's first post!!!!!!
I think I've allowed Info's second post to confuse me a little in which he displays 2 different types of checkbox!
*ollox!
@Info, if you simply want to remove the checkmarks from individual items then Sparkies code does the job nicely and I apologise for getting the wrong end of the stick! In which case I blame your second post!
However, if you do want 2 different types of checkbox image then you will have to delve a little deeper etc.
I think I've allowed Info's second post to confuse me a little in which he displays 2 different types of checkbox!
*ollox!
@Info, if you simply want to remove the checkmarks from individual items then Sparkies code does the job nicely and I apologise for getting the wrong end of the stick! In which case I blame your second post!

However, if you do want 2 different types of checkbox image then you will have to delve a little deeper etc.
Last edited by srod on Sat Dec 09, 2006 6:08 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.