GDI Leak for ImageList_LoadImage() method
-
2012년 4월 16일 월요일 오후 12:33
Hi,
I am using following code to load images into HIMAGELIST structure which interns load image into Listview Header.
After using function i am removing images from HIMAGELIST.
I observed in task manager that during "ImageList_LoadImage" functiona call system increase 4 GDI object and while removing
it does not decrease it.
HIMAGELIST imageList=ImageList_LoadImage(_Module.GetModuleInstance(),MAKEINTRESOURCE(IDB_CHECKBOX),
16,16,RGB(255,0,0255),IMAGE_BITMAP,LR_LOADTRANSPARENT);
HWND pHead=ListView_GetHeader(GetDlgItem(IDC_LST_LEG));
ImageList_SetBkColor(imageList,COLORREF(0xFF00FF));
HDITEM hdItem;
Header_SetImageList(pHead,imageList);
hdItem.mask = HDI_IMAGE | HDI_FORMAT;...
...
if(imageList){
ImageList_Remove(imageList,-1);
imageList=NULL;
}Please guide me for removing GDI leaks for HIMAGELIST.
Thanks and Regards,
Deven
모든 응답
-
2012년 4월 16일 월요일 오후 12:38
Probably you have to call ImageList_Destroy.
- 답변으로 표시됨 Visual Deven 2012년 4월 19일 목요일 오전 8:19
-
2012년 4월 17일 화요일 오전 8:50
check this link this may help you out
-
2012년 4월 19일 목요일 오전 8:23
Thanks Viorel
It solved my problem
btw one more thing is when i am using following statement it consume 4 GDI objects. I am having doubt that whether it releases properly or not.
ListView_SetExtendedListViewStyle(ghw,LVS_EX_CHECKBOXES| LVS_EX_GRIDLINES|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
I am using LVS_EX_CHECKBOXES hence it occupies 4 GDI objects and after scope it was not able to clear all GDI objects as it shows 1 GDI object leak in task manager.

