OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
public void setSelection (TreeItem [] items) {	checkWidget ();	if (items == null) error (SWT.ERROR_NULL_ARGUMENT);	int length = items.length;	if (length == 0 || ((style & SWT.SINGLE) != 0 && length > 1)) {		deselectAll();		return;	}			/* Select/deselect the first item */	TreeItem item = items [0];	if (item != null) {		if (item.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);		int hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);		int hNewItem = hAnchor = item.handle;				/*		* Bug in Windows.  When TVM_SELECTITEM is used to select and		* scroll an item to be visible and the client area of the tree		* is smaller that the size of one item, TVM_SELECTITEM makes		* the next item in the tree visible by making it the top item		* instead of making the desired item visible.  The fix is to		* detect the case when the client area is too small and make		* the desired visible item be the top item in the tree.		* 		* Note that TVM_SELECTITEM when called with TVGN_FIRSTVISIBLE		* also requires the work around for scrolling.		*/		boolean fixScroll = checkScroll (hNewItem);		if (fixScroll) {			OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);			OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);		}		ignoreSelect = true;		OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);		ignoreSelect = false;		if (OS.SendMessage (handle, OS.TVM_GETVISIBLECOUNT, 0, 0) == 0) {			OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hNewItem);		}		if (fixScroll) {			OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);			OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);		}				/*		* Feature in Windows.  When the old and new focused item		* are the same, Windows does not check to make sure that		* the item is actually selected, not just focused.  The		* fix is to force the item to draw selected by setting		* the state mask, and to ensure that it is visible.		*/		if (hOldItem == hNewItem) {			TVITEM tvItem = new TVITEM ();			tvItem.mask = OS.TVIF_STATE;			tvItem.state = OS.TVIS_SELECTED;			tvItem.stateMask = OS.TVIS_SELECTED;			tvItem.hItem = hNewItem;			OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);			showItem (hNewItem);		}	}	if ((style & SWT.SINGLE) != 0) return;	/* Select/deselect the rest of the items */	TVITEM tvItem = new TVITEM ();	tvItem.mask = OS.TVIF_STATE;	tvItem.stateMask = OS.TVIS_SELECTED;	int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);	OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);	if ((style & SWT.VIRTUAL) != 0) {		int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);		setSelection (hItem, tvItem, items);	} else {		for (int i=0; i<this.items.length; i++) {			item = this.items [i];			if (item != null) {				int index = 0;				while (index < length) {					if (items [index] == item) break;					index++;				}				tvItem.hItem = item.handle;				OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);				if ((tvItem.state & OS.TVIS_SELECTED) != 0) {					if (index == length) {						tvItem.state = 0;						OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);					}				} else {					if (index != length) {						tvItem.state = OS.TVIS_SELECTED;						OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);					}				}			}		}	}	OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);}