Code: Select all
AddGadgetItem(0, -1, "text, ImageID(i), 1)
How can I get the ImageID from the items again?
Code: Select all
AddGadgetItem(0, -1, "text, ImageID(i), 1)
Can you not?IceSoft wrote:I added some items to a TreeGadget like this:My question is now:Code: Select all
AddGadgetItem(0, -1, "text, ImageID(i), 1)
How can I get the ImageID from one of the items again?
Code: Select all
ImageOne = ImageID(i)
AddGadgetItem(0, -1, "text, ImageOne, 1)
Debug ImageOne
Code: Select all
AddGadgetItem(0, -1, "text", ImageID(i), 1)
SetGadgetItemData(0,CountGadgetItems(0),ImageID(i))
Yes this is possible. I thought also on it. And yes it works.citystate wrote:I don't think there is a native method of getting the ImageID - can you use something like this?
though I'd be more inclined to store the image number...Code: Select all
AddGadgetItem(0, -1, "text", ImageID(i), 1) SetGadgetItemData(0,CountGadgetItems(0),ImageID(i))
Code: Select all
For i = 1 To 7
CreateImage(i, 16,16)
StartDrawing(ImageOutput(i))
DrawText(4,1,Str(i))
StopDrawing()
Next
If OpenWindow(0, 0, 0, 355, 180, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TreeGadget(0, 10, 10, 160, 160)
CanvasGadget(1, 180, 10, 32,32, 0)
AddGadgetItem (ID, -1, "Normal Item "+Str(a), ImageID(1))
AddGadgetItem (ID, -1, "Node "+Str(a), ImageID(2))
AddGadgetItem(ID, -1, "Sub-Item 1", ImageID(3), 1)
AddGadgetItem(ID, -1, "Sub-Item 2", ImageID(4), 1)
AddGadgetItem(ID, -1, "Sub-Item 3", ImageID(5), 1)
AddGadgetItem(ID, -1, "Sub-Item 4", ImageID(6), 1)
AddGadgetItem (ID, -1, "File "+Str(a), ImageID(7), 0)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_Change
If GetGadgetState(0) > -1
DC = StartDrawing(CanvasOutput(1))
item.TVITEM
item\hItem = GadgetItemID(0, GetGadgetState(0))
item\mask = #TVIF_IMAGE
SendMessage_(GadgetID(0),#TVM_GETITEMA, 0, @item)
;Directly draw image
;ImageList_Draw_(SendMessage_(GadgetID(0), #TVM_GETIMAGELIST,#TVSIL_NORMAL,0),item\iImage, DC, 8,8, #SRCCOPY)
Icon = ImageList_GetIcon_(SendMessage_(GadgetID(0), #TVM_GETIMAGELIST,#TVSIL_NORMAL,0), GetGadgetState(0)+1, 0)
DrawImage(Icon, 8, 8)
DeleteObject_(Icon)
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf