CImageList myImageList; myImageList.Create(32, 32, ILC_COLOR32, 1, 0); // Add images to the image list HIMAGELIST hList = myImageList.Detach(); // Now use hList as needed DestroyIcon(hList);
void ResetImageList(CImageList& imageList, int width, int height) { HIMAGELIST hList = imageList.Detach(); ImageList_Destroy(hList); imageList.Create(width, height, ILC_COLOR24, 0, 1); }In this example, a function is defined that resets an existing CImageList instance. The Detach function is used to retrieve the handle of the image list, which is then destroyed using the ImageList_Destroy function. Finally, a new image list is created using the specified width, height, and color format. Package library: MFC (Microsoft Foundation Class)