int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0); OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hImageList); if (hOldList != 0) OS.ImageList_Destroy (hOldList);
OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hStateList); if (hOldStateList != 0) OS.ImageList_Destroy (hOldStateList);
void setCheckboxImageList () {	if ((style & SWT.CHECK) == 0) return;	int count = 4;	int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);	int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);	int height = (oneItem >> 16) - (empty >> 16), width = height;	int hImageList = OS.ImageList_Create (width, height, OS.ILC_COLOR, count, count);	int hDC = OS.GetDC (handle);	int memDC = OS.CreateCompatibleDC (hDC);	int hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);	int hOldBitmap = OS.SelectObject (memDC, hBitmap);	RECT rect = new RECT ();	OS.SetRect (rect, 0, 0, width * count, height);	int hBrush = OS.CreateSolidBrush (getBackgroundPixel ());	OS.FillRect (memDC, rect, hBrush);	OS.DeleteObject (hBrush);	int oldFont = OS.SelectObject (hDC, defaultFont ());	TEXTMETRIC tm = new TEXTMETRIC ();	OS.GetTextMetrics (hDC, tm);	OS.SelectObject (hDC, oldFont);	int itemWidth = Math.min (tm.tmHeight, width);	int itemHeight = Math.min (tm.tmHeight, height);	int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;	OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight);	OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT);	rect.left += width;  rect.right += width;	OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT);	rect.left += width;  rect.right += width;	OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT);	rect.left += width;  rect.right += width;	OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT);	OS.SelectObject (memDC, hOldBitmap);	OS.DeleteDC (memDC);	OS.ReleaseDC (handle, hDC);	OS.ImageList_AddMasked (hImageList, hBitmap, 0);	OS.DeleteObject (hBitmap);	int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);	OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hImageList);	if (hOldList != 0) OS.ImageList_Destroy (hOldList);}