Page 1 of 1

TreeGadget : optional image parameter ?

Posted: Sun Jun 15, 2003 7:12 am
by eddy
OpenWindow(0,0,0,240,210,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"TreeGadget")
CreateGadgetList(WindowID())

#GADGET_Explorer=1
TreeGadget(#GADGET_Explorer,0,0,100,100,#PB_Tree_AlwaysShowSelection)
;First Item
LoadImage(#GADGET_Explorer,"img\new.ico")
AddGadgetItem(#GADGET_Explorer, -1, "Item with image",ImageID())

;Sub Item
OpenTreeGadgetNode(#GADGET_Explorer)
AddGadgetItem(#GADGET_Explorer, -1, "Sub Item")
CloseTreeGadgetNode(#GADGET_Explorer)

Repeat
Until WaitWindowEvent()=#PB_Event_CloseWindow
Why sub-item uses the last loaded image ?
I specified no image.

Posted: Sun Jun 15, 2003 10:43 am
by freak
Once you add an image, all Items need images, that's the way it works.

Timo

Posted: Sun Jun 15, 2003 11:01 am
by eddy
is it a global style for all of the tree ?

Posted: Sun Jun 15, 2003 11:15 am
by Denis
Hi Eddy,


try to put a negative value for ImageID

AddGadgetItem(#GADGET_Explorer, -1, "Sub Item")

But as Freak said it, Once you add an image, all Items need images, that's the way it works. So, with a negative value under Win98, no image is displayed but the system put space between horizontal line and text.



Denis

Posted: Sun Jun 15, 2003 11:23 am
by eddy
Ok I understand.

The problem is that even if I use a tiny image, Win$ stretches it to fit a common size. :roll:

Posted: Sun Jun 15, 2003 1:41 pm
by freak
This is a Windows thing, not a PB one:

To add an image, there is an ImageList created, and so all Items get an
Image from that list. That's why all must be (or are streched) to the same
size. If you put a negative value (which is an invalid ImageID()), there
is no image to display, but Windows puts these spaces there.

There is no way to change that, sorry.
(It's the same with Checkboxes. You can have either checkboxes on all
items, or on none of them)

Timo