case OS.WM_PAINT: painted = true; break;
int callWindowProc (int hwnd, int msg, int wParam, int lParam) {	if (handle == 0) return 0;	if (hwndParent != 0 && hwnd == hwndParent) {		return OS.DefWindowProc (hwnd, msg, wParam, lParam);	}	if (hwndHeader != 0 && hwnd == hwndHeader) {		return OS.CallWindowProc (HeaderProc, hwnd, msg, wParam, lParam);	}	switch (msg) {		case OS.WM_SETFOCUS: {			/*			* Feature in Windows.  When a tree control processes WM_SETFOCUS,			* if no item is selected, the first item in the tree is selected.			* This is unexpected and might clear the previous selection.			* The fix is to detect that there is no selection and set it to			* the first item in the tree.  If the item was not selected,			* only the focus is assigned.			*/			if ((style & SWT.SINGLE) != 0) break;			int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);			if (hItem == 0) {				hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);				if (hItem != 0) {					TVITEM tvItem = new TVITEM ();					tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;					tvItem.hItem = hItem;					OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);					ignoreDeselect = ignoreSelect = lockSelection = true;					OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hItem);					if ((tvItem.state & OS.TVIS_SELECTED) == 0) {						OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);					}					ignoreDeselect = ignoreSelect = lockSelection = false;				}			}			break;		}		}	int hItem = 0;	switch (msg) {		/* Keyboard messages */		case OS.WM_KEYDOWN:			if (wParam == OS.VK_CONTROL || wParam == OS.VK_SHIFT) break;			//FALL THROUGH		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:			//FALL THROUGH					/* Scroll messages */		case OS.WM_HSCROLL:		case OS.WM_VSCROLL:			//FALL THROUGH					/* Resize messages */		case OS.WM_SIZE:			if (backgroundImage != null && drawCount == 0) {				OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);			}			//FALL THROUGH					/* Mouse messages */		case OS.WM_LBUTTONDBLCLK:		case OS.WM_LBUTTONDOWN:		case OS.WM_LBUTTONUP:		case OS.WM_MBUTTONDBLCLK:		case OS.WM_MBUTTONDOWN:		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_RBUTTONDOWN:		case OS.WM_RBUTTONUP:		case OS.WM_XBUTTONDBLCLK:		case OS.WM_XBUTTONDOWN:		case OS.WM_XBUTTONUP:			//FALL THROUGH					/* Other messages */		case OS.WM_SETFONT:		case OS.WM_TIMER: {			if (backgroundImage != null) {				hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);			}		}	}	int code = OS.CallWindowProc (TreeProc, hwnd, msg, wParam, lParam);	switch (msg) {		/* Keyboard messages */		case OS.WM_KEYDOWN:			if (wParam == OS.VK_CONTROL || wParam == OS.VK_SHIFT) break;			//FALL THROUGH		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:			//FALL THROUGH					/* Scroll messages */		case OS.WM_HSCROLL:		case OS.WM_VSCROLL:			//FALL THROUGH					/* Resize messages */		case OS.WM_SIZE:			if (backgroundImage != null && drawCount == 0) {				OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);				OS.InvalidateRect (handle, null, true);				if (hwndHeader != 0) OS.InvalidateRect (hwndHeader, null, true);			}			//FALL THROUGH					/* Mouse messages */		case OS.WM_LBUTTONDBLCLK:		case OS.WM_LBUTTONDOWN:		case OS.WM_LBUTTONUP:		case OS.WM_MBUTTONDBLCLK:		case OS.WM_MBUTTONDOWN:		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_RBUTTONDOWN:		case OS.WM_RBUTTONUP:		case OS.WM_XBUTTONDBLCLK:		case OS.WM_XBUTTONDOWN:		case OS.WM_XBUTTONUP:			//FALL THROUGH					/* Other messages */		case OS.WM_SETFONT:		case OS.WM_TIMER: {			if (backgroundImage != null) {				if (hItem != OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0)) {					OS.InvalidateRect (handle, null, true);				}			}			updateScrollBar ();		}	}	return code;}