Page 1 of 3
Treegadget problem...
Posted: Sat Dec 09, 2006 10:49 am
by Inf0Byt3
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...
Posted: Sat Dec 09, 2006 3:26 pm
by Inf0Byt3
For an example take a look here... Where can i find some information about this?

Posted: Sat Dec 09, 2006 3:47 pm
by srod
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.
Posted: Sat Dec 09, 2006 3:54 pm
by Inf0Byt3
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

.
Posted: Sat Dec 09, 2006 4:12 pm
by srod
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.
Posted: Sat Dec 09, 2006 4:26 pm
by Inf0Byt3
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

Posted: Sat Dec 09, 2006 4:37 pm
by srod
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
Posted: Sat Dec 09, 2006 5:43 pm
by Sparkie
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
Posted: Sat Dec 09, 2006 5:56 pm
by srod
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.
Posted: Sat Dec 09, 2006 6:06 pm
by srod
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.
Posted: Sat Dec 09, 2006 6:08 pm
by Sparkie
Oh well, I guess it was my turn to be off target this time srod.

Posted: Sat Dec 09, 2006 6:10 pm
by Sparkie
I gotta learn to type faster

Posted: Sat Dec 09, 2006 6:13 pm
by srod
It's okay, I type faster than I think... sadly!
Actually, I am totally confused now as to what it is InfoByte is after? Oh well.

Posted: Sat Dec 09, 2006 6:16 pm
by Sparkie
Well if we're lucky, we've now confused Inf0Byt3 as well, and this is all forgotten

Posted: Sat Dec 09, 2006 6:25 pm
by srod
This is now completely off topic, but your avatar is simply too cool!
I'm going to change mine pronto!
