if (handle == 0) return 0; boolean checkSelection = false, checkFilter = false, checkActivate = false; switch (msg) { case OS.WM_CHAR: case OS.WM_IME_CHAR: case OS.WM_KEYUP: case OS.WM_SYSCHAR: case OS.WM_SYSKEYDOWN: case OS.WM_SYSKEYUP: case OS.WM_LBUTTONDBLCLK: case OS.WM_LBUTTONUP: case OS.WM_MBUTTONDBLCLK: case OS.WM_MBUTTONUP: case OS.WM_MOUSEHOVER: case OS.WM_MOUSELEAVE: case OS.WM_MOUSEMOVE:  case OS.WM_RBUTTONDBLCLK: case OS.WM_RBUTTONUP: case OS.WM_XBUTTONDBLCLK: case OS.WM_XBUTTONUP: checkSelection = true; break;  case OS.WM_LBUTTONDOWN: case OS.WM_MBUTTONDOWN: case OS.WM_RBUTTONDOWN: case OS.WM_XBUTTONDOWN: checkSelection = checkFilter = true; break;  case OS.WM_KEYDOWN: checkSelection = checkActivate = true; break; } boolean oldSelected = wasSelected; if (checkSelection) wasSelected = false; if (checkActivate) ignoreActivate = true; if (checkFilter) display.ignoreMsgFilter = true; int code = OS.CallWindowProc (TableProc, hwnd, msg, wParam, lParam); if (checkFilter) display.ignoreMsgFilter = false; if (checkActivate) ignoreActivate = false; if (checkSelection) { if (wasSelected) { Event event = new Event (); int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED); if (index != -1) event.item = _getItem (index); postEvent (SWT.Selection, event); } wasSelected = oldSelected; } return code;
return callWindowProc (hwnd, msg, wParam, lParam, false);
int callWindowProc (int hwnd, int msg, int wParam, int lParam) {	if (handle == 0) return 0;	boolean checkSelection = false, checkFilter = false, checkActivate = false;	switch (msg) {		case OS.WM_CHAR:		case OS.WM_IME_CHAR:		case OS.WM_KEYUP:		case OS.WM_SYSCHAR:		case OS.WM_SYSKEYDOWN:		case OS.WM_SYSKEYUP:		case OS.WM_LBUTTONDBLCLK:		case OS.WM_LBUTTONUP:		case OS.WM_MBUTTONDBLCLK:		case OS.WM_MBUTTONUP:		case OS.WM_MOUSEHOVER:		case OS.WM_MOUSELEAVE:		case OS.WM_MOUSEMOVE://		case OS.WM_MOUSEWHEEL:		case OS.WM_RBUTTONDBLCLK:		case OS.WM_RBUTTONUP:		case OS.WM_XBUTTONDBLCLK:		case OS.WM_XBUTTONUP:			checkSelection = true;			break;		/*		* Bug in Windows.  For some reason, when the user clicks		* on this control, the Windows hook WH_MSGFILTER is sent		* despite the fact that an input event from a dialog box,		* message box, menu, or scroll bar did not seem to occur.		* The fix is to ignore the hook.		*/		case OS.WM_LBUTTONDOWN:		case OS.WM_MBUTTONDOWN:		case OS.WM_RBUTTONDOWN:		case OS.WM_XBUTTONDOWN:			checkSelection = checkFilter = true;			break;		/*		* Feature in Windows.  Windows sends LVN_ITEMACTIVATE from WM_KEYDOWN		* instead of WM_CHAR.  This means that application code that expects		* to consume the key press and therefore avoid a SWT.DefaultSelection		* event will fail.  The fix is to ignore LVN_ITEMACTIVATE when it is		* caused by WM_KEYDOWN and send SWT.DefaultSelection from WM_CHAR.		*/		case OS.WM_KEYDOWN:			checkSelection = checkActivate = true;			break;	}	boolean oldSelected = wasSelected;	if (checkSelection) wasSelected = false;	if (checkActivate) ignoreActivate = true;	if (checkFilter) display.ignoreMsgFilter = true;	int code = OS.CallWindowProc (TableProc, hwnd, msg, wParam, lParam);	if (checkFilter) display.ignoreMsgFilter = false;	if (checkActivate) ignoreActivate = false;	if (checkSelection) {		if (wasSelected) {			Event event = new Event ();			int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);			if (index != -1) event.item = _getItem (index);			postEvent (SWT.Selection, event);		}		wasSelected = oldSelected;	}	return code;}