introduction
I believe that when you install your own computer, more or less the "Device Manager" of the system. When some devices in your computer are not driven, on the node icon of the device in the device manager There will be an exclamation mark (or a fork)! So how is this feature implementation?
principle
View MSDN's CImageList, seeing CImageList has such a way: SETOVERLAYIMAGE
CIMAGELIST :: SETOVERLAYIMAGE
Bool SetoverlayImage (int nimage, int noverlay);
Return Value
Nonzero if Successful; OtherWise 0.
Parameters
NIMAGE
Zero-based index of the image to use as an offlay mask.
Noverlay
One-based index of the overlay mask.
Remarks
Call this function to add the zero-based index of an app....
An overlay mask is an image drawn transparently over another image. Draw an overlay mask over an image by using the CImageList :: Draw member function with the one-based index of the overlay mask specified by using the INDEXTOOVERLAYMASK macro
From this paragraph (especially for red underline), we can know that by setting an IMAG set to overlay, then the image can be synthesized to other Image, which can reach the device manager. That effect.
achieve
A part of the code similar to the device manager effect is given below.
SP_CLASSIMAGELIST_DATA ImageClass; / / Device Image
CIMAGELIST IMAGEDRIVER;
ImageClass.cbsize = sizeof (sp_CLASIMAGELIST_DATA);
Verify (SetupDiGetClassImageList (& imageclass)); // Get device class image
Imagedriver.attach (ImageClass.ImageList);
// Start setting Overlaymask below
//
// In sp_classimagelist_data, the last three image is an Overlay Image
// is used, where the countdown is the third is to indicate an exclamation icon that is not normal.
//
Int nimagecount = imagedriver.getimageCount ();
Imagedriver.SetoverlayImage (NimageCount - 3, 1); // Put the last image of the third Image as the first overlay image
// You can also set the second image of the countdown for overlay image.
//
// The above is just the necessary initialization settings using Overlay Image.
// When the specific use, the method of the specific control is to be used, and the tree control is an example.
/ / In order to be able to achieve this, you need to invoke the setItemState method of the tree control to make Overlay // image.
CTreeCtrl DRVTree;
DRVTree.setimagelist (& imageDriver, TVsil_small);
/ / Set an Overlay Image for a node
Drvtree.setItemState (HITEM,
IndextooverLaymask (1),
VIS_OVERLAYMASK;
//
// Note: As for the usage of the list control (CListCtrl), you also need to call ClistCtrl :: SETITEMSTATE to implement the overlay image of a row.