Creating an Image List

An image list is a collection of same-size images. You can create the images in a single wide bitmap or as individual bitmaps that you add to the list one at a time. Image lists manage images, but they do not display the images directly. They can be used independently or in conjunction with list view and tree view controls.

There are two types of image lists, nonmasked and masked. A nonmasked image list consists of a color bitmap that contains one or more images. A masked image list consists of two bitmaps of equal size. The first is a color bitmap that contains the images, and the second is a monochrome bitmap that contains a series of masks—one for each image in the first bitmap.

Windows CE draws a nonmasked image by copying it into the target device context and drawing it over the existing background color of the device context. Windows CE draws a masked image by combining its bits with the bits of the mask, typically producing transparent areas in the bitmap where the background color of the target device context shows through.

Note Most Windows CE–based platforms do not support cursors except for the wait cursor. Therefore, image lists cannot contain cursors.

    To create an image list

  1. Call 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. ImageList_Create selects the image bitmap into one device context and the mask bitmap into the other.

  2. Specify the initial number of images in the 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. 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, destroy it by specifying its handle in a call to the ImageList_Destroy function.

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

The IMAGELISTDRAWPARAMS structure, used with the ImageList_DrawIndirect function, contains data 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 code specifying how to combine the image's colors with the background colors.