Udostępnij za pośrednictwem


Manipulating Image Lists

The Replace member function replaces an image in an image list (CImageList) with a new image. This function is also useful if you need to dynamically increase the number of images in an image list object. The SetImageCount function dynamically changes the number of images stored in the image list. If you increase the size of the image list, call Replace to add images to the new image slots. If you decrease the size of the image list, the images beyond the new size are freed.

The Remove member function removes an image from an image list. The Copy member function can copy or swap images within an image list. This function allows you to indicate whether the source image should be copied to the destination index or the source and destination images should be swapped.

To create a new image list by merging two image lists, use the appropriate overload of the Create member function. This overload of Create merges the first image of the existing image lists, storing the resultant image in a new image list object. The new image is created by drawing the second image transparently over the first. The mask for the new image is the result of performing a logical-OR operation on the bits of the masks for the two existing images.

This is repeated until all images are merged and added to the new image list object.

You can write the image information to an archive by calling the Write member function, and read it back by calling the Read member function.

The GetSafeHandle, Attach, and Detach member functions allow you to manipulate the handle of the image list attached to the CImageList object, while the DeleteImageList member function deletes the image list without destroying the CImageList object.

See Also

Concepts

Controls (MFC)

Reference

Using CImageList