一个简单的例子.
// AddIconsToImageList - creates a masked image list and adds some
// icons to it.
// Returns the handle to the new image list.
// hinst - handle to the application instance.
//
// Global variables and constants
// g_nBird and g_nTree - indexes of the images.
// cx_icon and cy_icon - width and height of the icon.
// num_icons - number of icons to add to the image list.
extern int g_nBird, g_nTree;
HIMAGELIST AddIconsToImageList(HINSTANCE hinst)
{
HIMAGELIST himlIcons; // handle to new image list
HICON hicon; // handle to icon
// Ensure that the common control DLL is loaded.
InitCommonControls();
// Create a masked image list large enough to hold the icons.
himlIcons = ImageList_Create(CX_ICON, CY_ICON, ILC_MASK, NUM_ICONS, 0);
// Load the icon resources, and add the icons to the image list.
hicon = LoadIcon(hinst, MAKEINTRESOURCE(IDI_BIRD));
g_nBird = ImageList_AddIcon(himlIcons, hicon);