Tech Note 03i: ImageList Object

January 5, 2007

© NSB Corporation. All rights reserved.

For more information on this control, see Microsoft's documentation.


This control contains a collection of images to which you can refer by index. Use as a central repository to conveniently supply other controls, such as TabStrip, ListView, and TreeView, with images. The number of images that you can load is limited by the amount of available memory.

This control has been replaced by NSBControls.dll.

Here is some documention, thanks to Heiko Stolte:

Syntax

AddObject "ceimagelist.imagelistctrl.1", "ImageList1",0,0,0,0
Where Imagelist1 is the name of the object.

Properties

HImageList Pointer to Imagelist
Count Number of pictures
Imagewidth* Width of Imagelist = width of first picture
Imageheight* Height of Imagelist = height of first picture
* all other pictures will be resized to first picture size

Methods

Add pathfilename Adds an image to imagelist
Important: picture colors*
Remove index Remove pictures number
RemoveAll Removes all pictures
Replace index, pathfilename Replace picture number index with picture filename
Reset Resets imagelist
* I tested with 256 colors, that works fine

Example (see MSCEListview sample)

AddObject "ceimagelist.imagelistctrl.1","ImageList1",0,0,0,0
AddObject "ceimagelist.imagelistctrl.1","ImageList2",0,0,0,0
AddObject "listviewctrl.listviewctrl.1","listView",10,130,220,120
      
       
' big icons
ImageList1.Add("\My Documents\test1.bmp")
ImageList1.Add("\My Documents\test2.bmp")
ImageList1.Add("\My Documents\test3.bmp")
ImageList1.Add("\My Documents\test4.bmp")
' small icons
ImageList2.Add("\My Documents\test5.bmp")
ImageList2.Add("\My Documents\test6.bmp")
ImageList2.Add("\My Documents\test7.bmp")
ImageList2.Add("\My Documents\test8.bmp")
  
' connect listview with imageview
ListView.Icons = ImageList1.hImageList
ListView.SmallIcons = ImageList2.hImageList