Page 1 of 1

ImageList changes for ListIconGadgets question

Posted: Sun Dec 18, 2005 12:58 pm
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.

Posted: Sun Dec 18, 2005 5:13 pm
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?

Posted: Sun Dec 18, 2005 5:43 pm
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.

Posted: Sun Dec 18, 2005 9:12 pm
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