release the image resource once it's assigned

svn path=/trunk/; revision=28664
This commit is contained in:
Ged Murphy 2007-08-29 23:05:23 +00:00
parent d374f7cbb0
commit c8026e017e

View file

@ -122,7 +122,6 @@ ChangeListViewText(PMAIN_WND_INFO Info,
lpServiceConfig); lpServiceConfig);
} }
} }
break; break;
case LVDESC: case LVDESC:
@ -370,51 +369,57 @@ RefreshServiceList(PMAIN_WND_INFO Info)
static VOID static VOID
InitListViewImage(PMAIN_WND_INFO Info) InitListViewImage(PMAIN_WND_INFO Info)
{ {
HICON hSmIconItem, hLgIconItem; /* icon for list-view items */ HICON hSmIconItem, hLgIconItem;
HIMAGELIST hSmall, hLarge; /* image list for other views */ HIMAGELIST hSmall, hLarge;
/* Create the icon image lists */
hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), hSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON), GetSystemMetrics(SM_CYSMICON),
ILC_MASK | ILC_COLOR32, ILC_MASK | ILC_COLOR32,
1, 1,
1); 1);
if (hSmall)
{
hSmIconItem = LoadImage(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON,
16,
16,
0);
if (hSmIconItem)
{
ImageList_AddIcon(hSmall,
hSmIconItem);
(void)ListView_SetImageList(Info->hListView,
hSmall,
LVSIL_SMALL);
DestroyIcon(hSmIconItem);
}
}
hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON), hLarge = ImageList_Create(GetSystemMetrics(SM_CXICON),
GetSystemMetrics(SM_CYICON), GetSystemMetrics(SM_CYICON),
ILC_MASK | ILC_COLOR32, ILC_MASK | ILC_COLOR32,
1, 1,
1); 1);
if (hLarge)
/* Add an icon to each image list */ {
hSmIconItem = LoadImage(hInstance, hLgIconItem = LoadImage(hInstance,
MAKEINTRESOURCE(IDI_SM_ICON), MAKEINTRESOURCE(IDI_SM_ICON),
IMAGE_ICON, IMAGE_ICON,
16, 32,
16, 32,
0); 0);
if (hLgIconItem)
ImageList_AddIcon(hSmall, {
hSmIconItem); ImageList_AddIcon(hLarge,
hLgIconItem);
hLgIconItem = LoadImage(hInstance, (void)ListView_SetImageList(Info->hListView,
MAKEINTRESOURCE(IDI_SM_ICON), hLarge,
IMAGE_ICON, LVSIL_NORMAL);
32, DestroyIcon(hLgIconItem);
32, }
0); }
ImageList_AddIcon(hLarge,
hLgIconItem);
/* assign the image to the list view */
(void)ListView_SetImageList(Info->hListView,
hSmall,
LVSIL_SMALL);
(void)ListView_SetImageList(Info->hListView,
hLarge,
LVSIL_NORMAL);
} }