Image List Control (CIMAGELIST) is a collection of the same size image, all of which are used in 0 for the image of the image, and the image list is typically constructed of a large icon or a bitmap, including the transparent bitmap mode. You can use the Windows32-bit application interface function API to draw, build and delete images, and increase, delete, replace, and drag images. Image list control provides the basic method of controlling image lists, which can be implemented in Windows 95 and later. (1) Object structure 1, image control data member m_himagelist Connection Image Object Control Handle 2 BOOL Create (int cx, int cy, UINT nFlags, int nInitial, int nGrow); BOOL Create (UINT nBitmapID, int cx, int nGrow, COLORREF crMask); BOOL Create (LPCTSTR lpszBitmapID, int cx, int nGrow, COLORREF crMask) Bool Create (CIMAGELIST & Imagelist1, Int Nimage1, Cimagelist & Imagelist2, Int Nimage2, Int DX, INT DY); The meaning of each parameter is: CX defines the width of the image, the unit is pixel; CY defines the height, unit of the image For pixels; NFLAGS determines the type of an image list, which can be a combination of the following values: ILC_COLOR, ILC_COLOR4, ILC_COLOR8, ILC_COLOR16, ILC_COLOR24, ILC_COLOR32, ILC_COLORDDB and ILC_MASK; Ninitial is used to determine the number of images included in the image list; NGROW is used to determine The image list can be controlled. Nbitmapid is used to determine the bitmap flag value of the image list contact; Crmask represents the color mask bit; the lpszbitmapID is used to determine the identity string containing the bitmap resource; IMAGELIST1 points to a pointer to the image list control object; NIMAGE1 Image list 1 included ImageList2 points to a pointer to the image list control object; the number of images included in the NIMAGE2 image list 2; DX represents the image width in pixels; DY represents the image height of the pixel. Similarly, the establishment of image control also includes two steps, first establish an image list structure, and then establish an image list control. 3 Setbkcolor. 4 ADD in the image list and delete Remove from the list list. (2) Application skills of image control For image control, the same cannot be used alone, and must be used in combination with list control, tree control, and label control, and the specific application skills are described below.
1. Image Control In List Control 1 Set Image Control ClistCtrl :: SetImageList's call format is as follows: CIMAGELIST * SETIMAGELIST (CIMAGELIST * PIMAGELIST (INT NIMAGELIST); its return value refers to a pointer to the forward image list, If there is no previous image list, it is null; where the parameter pimagelist is the identifier of the image list, NIMAGELIST is the type of image list, which can be the following value: LVSIL_NORMAL uses a large image list; LVSIL_SMALL uses a small icon to make an image list LVSIL_STATE The image list is imaged in an image state; 2 acquired image control CListCtrl :: getImageList's call format as follows: CIMAGELIST * GetImageList (int nimagelist) const; its return value is a pointer to the image list control, where nimagelist is used to determine the return value The value of the image list, the value is the same as the set image list function. 3 Image Control Application Example CIMAGELIST CIL1, CIL2; // Defines the Size Figure Item List CVClistApp * PAPP = (CVCListApp *) AFXGetApp (); // Number of List Control Programs Cil1.create (32, 32, True, 2, 2); // Establish 32-bit image control cil1.add (PAPP-> Loadicon (IDi_gj))); // Increase the selected status image cil1.add (PAPP-> loadicon (IDi_xs)); // Increase non-selection state Image cil2.create (16, 16, true, 2, 2); // Establish 16-bit image control cil2.add (PAPP-> Loadicon (IDi_gj)); // Add the selected status image cil2.add (PAPP-> Loadicon (IDi_xs)); // Increase the non-selected state image m_listctrl.setimageList (& Cil1, Lvsil_NORMAL); / / Set large icon control M_ListCtrl.setimageList (& Cil2, lvsil_small); // Set small icon control 2, image control in tree control Application Skills 1 Set Image Control CTREECTRL :: SetImageList's call format is as follows: CIMAGELIST * SETIMAGELIST (CIMAGELIST * PIMAGELIST, INT NIMAGELISTTYPE); its return value is a pointer to the previous image list, otherwise null; parameter pimagelist is pointing image The logo of the list, if all the images are cleared from the tree control; nimageListType is the type of image list setting, which can be one of the following: TVSIL_NORMAL sets a list of normal images, including two types of two Icon; TVSIL_State Sets the image list status, refers to the user-defined state; 2 acquisition image control CTREECTRL :: GetImageList's call format is as follows: CIMAGELIST * GetImageList (uint nimage); Return the image list control pointer if the call is successful; nimage In order to obtain an image list type of the return value, the value of the value and the acquisition of the image list are identical.