Besides, or instead of using, the Create() member function, you can call CImageList::Add() to add a bitmap to the CImageList variable. Its syntaxes are: int Add(CBitmap* pbmImage, CBitmap* pbmMask); int Add(CBitmap* pbmImage, COLORREF crMask); int Add(HICON hIcon); The pbmImage argument represents the bitmap to be added, unless you want to add an icon, in which case you would use the third version. The pbmMask argument is the bitmap that will be used to mask the image list. You can use a color instead, in which case you would pass a COLORREF value as the second argument to the second version.
If you want to remove a picture from the image list, call the CImageList::Remove() member function. Its syntax: BOOL Remove(int nImage); The nImage argument is the index of the picture to be removed.
Instead of removing a picture, you can just replace it with another picture. This is done using the CImageList::Replace() member function whose syntaxes are: BOOL Replace(int nImage, CBitmap* pbmImage, CBitmap* pbmMask); int Replace(int nImage, HICON hIcon);
Once an image list is ready, you can use it directly in an application or make it available to a control that can use it. One way you can use an image list is to display one or more of its pictures on a dialog box, a form, or a view. To do this, you would call the CImageList::Draw() member function. Its syntax is: BOOL Draw(CDC* pdc, int nImage, POINT pt, UINT nStyle); The first argument, pdc, specifies the device context on which you are drawing. The nImage argument is the index of the picture you want to draw. The pt argument is a POINT or a CPoint value that specifies the location of the new picture. The nStyle argument is a flag that specifies how the picture will be drawn. |
|
|||||||||||
|