GetGadgetItemImage?

Just starting out? Need help? Post your questions and find answers here.
liam
User
User
Posts: 38
Joined: Tue Jul 03, 2007 3:48 am
Location: Philippines

GetGadgetItemImage?

Post 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)
PureBasic 4.51(x86) on WinXP SP3
User avatar
Michael Vogel
Addict
Addict
Posts: 2820
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: GetGadgetItemImage?

Post 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
liam
User
User
Posts: 38
Joined: Tue Jul 03, 2007 3:48 am
Location: Philippines

Re: GetGadgetItemImage?

Post by liam »

thank you very much michael.

there wasn't anything like that in the helpfile.
PureBasic 4.51(x86) on WinXP SP3
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: GetGadgetItemImage?

Post 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

Egypt my love
liam
User
User
Posts: 38
Joined: Tue Jul 03, 2007 3:48 am
Location: Philippines

Re: GetGadgetItemImage?

Post 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.
PureBasic 4.51(x86) on WinXP SP3
Post Reply