case OS.HDN_ITEMCLICKW: case OS.HDN_ITEMCLICKA: { NMHEADER phdn = new NMHEADER (); OS.MoveMemory (phdn, lParam, NMHEADER.sizeof); TreeColumn column = columns [phdn.iItem]; if (column != null) { column.postEvent (SWT.Selection); } break; }
LRESULT WM_NOTIFY (int wParam, int lParam) {	NMHDR hdr = new NMHDR ();	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);	if (hwndHeader != 0 && hdr.hwndFrom == hwndHeader) {		/*		* Feature in Windows.  On NT, the automatically created		* header control is created as a UNICODE window, not an		* ANSI window despite the fact that the parent is created		* as an ANSI window.  This means that it sends UNICODE		* notification messages to the parent window on NT for		* no good reason.  The data and size in the NMHEADER and		* HDITEM structs is identical between the platforms so no		* different message is actually necessary.  Despite this,		* Windows sends different messages.  The fix is to look		* for both messages, despite the platform.  This works		* because only one will be sent on either platform, never		* both.		*/		switch (hdr.code) {			case OS.HDN_BEGINTRACKW:			case OS.HDN_BEGINTRACKA:			case OS.HDN_DIVIDERDBLCLICKW:			case OS.HDN_DIVIDERDBLCLICKA: {				NMHEADER phdn = new NMHEADER ();				OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);				TreeColumn column = columns [phdn.iItem];				if (column != null && !column.getResizable ()) {					return LRESULT.ONE;				}				break;			}			case OS.HDN_ITEMCHANGINGW:			case OS.HDN_ITEMCHANGINGA: {				NMHEADER phdn = new NMHEADER ();				OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);				if (phdn.pitem != 0) {					HDITEM newItem = new HDITEM ();					OS.MoveMemory (newItem, phdn.pitem, HDITEM.sizeof);					if ((newItem.mask & OS.HDI_WIDTH) != 0) {						int inset = 2;						HDITEM oldItem = new HDITEM ();						oldItem.mask = OS.HDI_WIDTH;						OS.SendMessage (hwndHeader, OS.HDM_GETITEM, phdn.iItem, oldItem);						int deltaX = newItem.cxy - oldItem.cxy;						RECT rect = new RECT (), itemRect = new RECT ();						OS.GetClientRect (handle, rect);						OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, phdn.iItem, itemRect);						rect.left = itemRect.right - inset + 1;						int flags = OS.SW_INVALIDATE | OS.SW_ERASE;						OS.ScrollWindowEx (handle, deltaX, 0, rect, null, 0, null, flags);						//TODO - column flashes when resized						if (phdn.iItem != 0) {							rect.left = itemRect.left;							rect.right = itemRect.right;							OS.InvalidateRect (handle, rect, true);						}						setScrollWidth ();					}				}				break;			}			case OS.HDN_ITEMCHANGEDW:			case OS.HDN_ITEMCHANGEDA: {				NMHEADER phdn = new NMHEADER ();				OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);				if (phdn.pitem != 0) {					HDITEM pitem = new HDITEM ();					OS.MoveMemory (pitem, phdn.pitem, HDITEM.sizeof);					if ((pitem.mask & OS.HDI_WIDTH) != 0) {						TreeColumn column = columns [phdn.iItem];						if (column != null) {							column.sendEvent (SWT.Resize);							if (isDisposed ()) return LRESULT.ZERO;								int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);							TreeColumn [] newColumns = new TreeColumn [count];							System.arraycopy (columns, 0, newColumns, 0, count);							for (int i=phdn.iItem+1; i<count; i++) {								if (!newColumns [i].isDisposed ()) {									newColumns [i].sendEvent (SWT.Move);								}							}						}					}				}				break;			}			case OS.HDN_ITEMDBLCLICKW:      			case OS.HDN_ITEMDBLCLICKA: {				NMHEADER phdn = new NMHEADER ();				OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);				TreeColumn column = columns [phdn.iItem];				if (column != null) {					column.postEvent (SWT.DefaultSelection);				}				break;			}		}	}	return super.WM_NOTIFY (wParam, lParam);}