Using Image Lists

You create an image list by calling the ImageList_Create function. For a nonmasked image list, this function creates a single bitmap large enough to hold a specified number of images of the specified dimensions. Then, it creates a screen-compatible device context and selects the bitmap into it. For a masked image list, the function creates two bitmaps and two screen-compatible device contexts. It selects the image bitmap into one device context and the mask bitmap into the other.

In ImageList_Create, you specify the initial number of images that will be in an image list, as well as the number of images by which the list can grow. If you attempt to add more images than you initially specified, the image list automatically grows to accommodate the images.

If ImageList_Create succeeds, it returns a handle to the HIMAGELIST type. You use this handle in other image list functions to access the image list and manage the images. You can add and remove images, copy images from one image list to another, and merge images from two different image lists. When you no longer need an image list, you destroy it by specifying its handle in a call to the ImageList_Destroy function.

You use the ImageList_Duplicate, ImageList_SetImageCount, and ImageList_RemoveAll functions to respectively copy, resize, or remove all images from an image list.

Windows CE supports a structure for image lists, called IMAGELISTDRAWPARAMS, which is used with the ImageList_DrawIndirect function. The IMAGELISTDRAWPARAMS structure contains information about how to draw an image from an image list, such as what part of the image to draw, the foreground and background colors, the style, and a raster operation (ROP) code specifying how to combine the image's colors with the background colors.