ImageList changes for ListIconGadgets question

Just starting out? Need help? Post your questions and find answers here.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

ImageList changes for ListIconGadgets question

Post by Fangbeast »

I've created an imagelist for my ListIconGadget so that I can use icons in all other collumns and although I get icons in all collumns, one of the collumns has the wrong icon so I've done something wrong somewhere.

#Image_appointment_date is the main icon used in collumn 0 when the gadget is initally populated. Code example below (main program is getting a bit big to constantly repost)

Code: Select all


Procedure ChangeIcon(mygadget.l, myrow.l, mycolumn.l, myicon.l)
  LVG.lv_item      
  LVG\mask     = #LVIF_IMAGE | #LVIF_TEXT 
  LVG\iItem    = myrow 
  LVG\iSubItem = mycolumn
  changetext.s = GetGadgetItemText(mygadget, myrow, mycolumn)
  LVG\pszText  = @changetext.s
  LVG\iImage   = myicon  
  SendMessage_(GadgetID(mygadget), #LVM_SETITEM, 0, @LVG) 
EndProcedure

Enumeration
  #Image_appointment_date
  #Image_appointment_time
  #Image_appointment_category
  #Image_appointment_notes
EndEnumeration

;=======================
; Grab the images to memory for use
;=======================

CatchImage(#Image_appointment_date,       ?_PTK_appointment_date)
CatchImage(#Image_appointment_time,       ?_PTK_appointment_time)
CatchImage(#Image_appointment_category,   ?_PTK_appointment_category)
CatchImage(#Image_appointment_notes,      ?_PTK_appointment_notes)

;==============================================================================================================================
; Any stored and included data
;==============================================================================================================================

DataSection
  _PTK_appointment_date       : IncludeBinary "Images\date.ico"
  _PTK_appointment_time       : IncludeBinary "Images\time.ico"
  _PTK_appointment_category   : IncludeBinary "Images\category.ico"
  _PTK_appointment_notes      : IncludeBinary "Images\notes.ico"
EndDataSection

;-------------------------------------------------------------------------
; Create a new image list and add icons to it.
;-------------------------------------------------------------------------
  hImgList.l     = ImageList_Create_(16, 16, #ILC_MASK | #ILC_COLOR32, 0, 15)
  timeicon.l     = ImageList_ReplaceIcon_(hImgList, -1, UseImage(#Image_appointment_time))
  categoryicon.l = ImageList_ReplaceIcon_(hImgList, -1, UseImage(#Image_appointment_category))
  notesicon.l    = ImageList_ReplaceIcon_(hImgList, -1, UseImage(#Image_appointment_notes))
  SendMessage_(GadgetID(#Gadget_appointment_appointments), #LVM_SETIMAGELIST,#LVSIL_SMALL, hImgList)
  ImageList_SetBkColor_(hImgList, #CLR_NONE)  
  SendMessage_(GadgetID(#Gadget_appointment_appointments), #LVM_SETEXTENDEDLISTVIEWSTYLE, #LVS_EX_SUBITEMIMAGES, #LVS_EX_SUBITEMIMAGES) 
And when I want to add icons to the other collumns...

First add the item to my gadget..

Code: Select all

      AddGadgetItem(#Gadget_appointment_appointments, -1, LineIn.s, UseImage(#Image_appointment_date))
Now change the icons in the other collumns of the newly added item.

Code: Select all

       program\counter + 1 ; Track items in my list
      ChangeIcon(#Gadget_appointment_appointments, program\counter - 1, 1, timeicon)
      ChangeIcon(#Gadget_appointment_appointments, program\counter - 1, 2, categoryicon)
      ChangeIcon(#Gadget_appointment_appointments, program\counter - 1, 3, notesicon)
Collumn 0 is correct, collumns 2 and 3 are right but collumn 1 uses the wrong icon?? Don't know what I've done here.
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post by Pupil »

I'm guessing here -maybe PB replaces an image(1:st one presumably) in the icon list when using addgadgetitem with an image argument?
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Pupil wrote:I'm guessing here -maybe PB replaces an image(1:st one presumably) in the icon list when using addgadgetitem with an image argument?
I've had a similar problem in the past with tree gadgets and the problem was essentially as Pupil has suggested. Although I found that using an imageID with AddGadgetItem() appended the image to the underlying imagelist (as opposed to overwriting one) and then only in the case that the imageID had not already been added to the list. Still, this would seem to be the obvious place to look.
I may look like a mule, but I'm not a complete ass.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Both your comments make sense when I think about it.

Just changed the procedures as you hinted and it worked great. It's so nice to be in the company of geniuses :P :P :P :P :P
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet
Post Reply