Page 1 of 1

GetGadgetItemImage?

Posted: Thu Jun 09, 2011 3:30 am
by liam
i have a prepopulated listicon with images in one window and i need to create a dropdown combobox with the same content as the listicongadget complete with images.
is there a way to directly copy the images to the combobox from the listicon?

(i have already used the getgadgetitemdata of the listicongadget to store the primary key of the items it contains so i couldn't use it to store the 'image' reference in it)

Re: GetGadgetItemImage?

Posted: Thu Jun 09, 2011 9:57 am
by Michael Vogel
I'm not sure, how you want to integrated the images, but if you just need to expand your code from saving a single data value...

Code: Select all

SetGadgetItemData(#ListIcon,item,key)
...to put multiple data values for each gadget item, you can create a structure like this...

Code: Select all

Structure DataType
	key.i
	image.i
EndStructure

Dim keyNimage.DataType(n)

SetGadgetItemData(#ListIcon,item,index)
keyNimage(index)\key=key
keyNimage(index)\image=image

Re: GetGadgetItemImage?

Posted: Thu Jun 09, 2011 11:15 am
by liam
thank you very much michael.

there wasn't anything like that in the helpfile.

Re: GetGadgetItemImage?

Posted: Fri Jun 10, 2011 10:23 am
by RASHAD
Hi
For Windows

Code: Select all

 If OpenWindow(0, 100, 100, 400, 300, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   ListIconGadget(0, 10,10, 380, 160, "Name", 100, #PB_ListIcon_FullRowSelect|#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_GridLines)
   AddGadgetColumn(0, 1, "Address", 250)
   AddGadgetItem(0, -1, " Harry Rannit"+Chr(10)+"12 Parliament Way",LoadIcon_(0,#IDI_ERROR))
   AddGadgetItem(0, -1, " Ginger Brokeit"+Chr(10)+"130 PureBasic Road",LoadIcon_(0,#IDI_EXCLAMATION))
   AddGadgetItem(0, -1, " Ginger Brokeit 2"+Chr(10)+"100 PureBasic Road",LoadIcon_(0,#IDI_QUESTION))
   AddGadgetItem(0, -1, " Ginger Brokeit 3"+Chr(10)+"60 PureBasic Road",LoadIcon_(0,#IDI_INFORMATION))
   himl = SendMessage_(GadgetID(0), #LVM_GETIMAGELIST, #LVSIL_NORMAL, 0)
   
   ComboBoxGadget(1, 10, 180, 250, 24, #PB_ComboBox_Image)
   For i = 0 To 3
     AddGadgetItem(1, -1, GetGadgetItemText(0,i,0),ImageList_GetIcon_(himl,i+1,#ILD_NORMAL|#ILD_TRANSPARENT))
   Next

  ; AddGadgetItem(1, -1, GetGadgetItemText(0,0,0),ImageList_GetIcon_(himl,1,#ILD_NORMAL|#ILD_TRANSPARENT))
  ; AddGadgetItem(1, -1, GetGadgetItemText(0,1,0),ImageList_GetIcon_(himl,2,#ILD_NORMAL|#ILD_TRANSPARENT))
  ; AddGadgetItem(1, -1, GetGadgetItemText(0,2,0),ImageList_GetIcon_(himl,3,#ILD_NORMAL|#ILD_TRANSPARENT))
  ; AddGadgetItem(1, -1, GetGadgetItemText(0,3,0),ImageList_GetIcon_(himl,4,#ILD_NORMAL|#ILD_TRANSPARENT))
   
   Repeat
     Event = WaitWindowEvent()
   Until Event = #PB_Event_CloseWindow
 EndIf


Re: GetGadgetItemImage?

Posted: Fri Jun 10, 2011 10:44 am
by liam
thanks for the snippet rashad much appreciated. although winapis is a bit advanced for me at this stage, i'll save this just in case i may have to use it in the future.