int width = rect.right - rect.left - gridWidth; int height = rect.bottom - rect.top - gridWidth;
int width = rect.right - rect.left - gridWidth * 2; int height = rect.bottom - rect.top - gridWidth * 2; if (index != 0) { LVITEM lvItem = new LVITEM (); lvItem.mask = OS.LVIF_IMAGE; lvItem.iItem = itemIndex; lvItem.iSubItem = index; if (OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem) == 0 || lvItem.iImage < 0) { width = 0; } }
public Rectangle getImageBounds (int index) {	checkWidget();	int itemIndex = parent.indexOf (this);	if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);	int hwnd = parent.handle;		int hwndHeader =  OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);	int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);	if (!(0 <= index && index < count)) return new Rectangle (0, 0, 0, 0); 	int gridWidth = 0;	if (parent.getLinesVisible ()) gridWidth = parent.getGridLineWidth ();	RECT rect = new RECT ();	rect.top = index;	rect.left = OS.LVIR_ICON;	OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, itemIndex, rect);	if (index == 0) {		RECT iconRect = new RECT ();		iconRect.left = OS.LVIR_ICON;		OS.SendMessage (hwnd, OS.LVM_GETSUBITEMRECT, itemIndex, iconRect);			rect.left = iconRect.left - gridWidth;	}	int width = rect.right - rect.left - gridWidth;	int height = rect.bottom - rect.top - gridWidth;	/*	* Bug in Windows.  In version 5.80 of COMCTL32.DLL, the top	* of the rectangle returned by LVM_GETSUBITEMRECT is off by	* the grid width when the grid is visible.  The fix is to	* move the top of the rectangle up by the grid width.	*/	if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {		rect.top -= gridWidth;	}	return new Rectangle (rect.left + gridWidth, rect.top + gridWidth, width, height);}