for (int i=phdn.iItem+1; i<count; i++) { if (!newColumns [i].isDisposed ()) { newColumns [i].sendEvent (SWT.Move);
int [] order = new int [count]; OS.SendMessage (handle, OS.LVM_GETCOLUMNORDERARRAY, count, order); boolean moved = false; for (int i=0; i<count; i++) { TableColumn nextColumn = newColumns [order [i]]; if (moved && !nextColumn.isDisposed ()) { nextColumn.sendEvent (SWT.Move);
LRESULT WM_NOTIFY (int wParam, int lParam) {	NMHDR hdr = new NMHDR ();	OS.MoveMemory (hdr, lParam, NMHDR.sizeof);	int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);	if (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);				TableColumn column = columns [phdn.iItem];				if (column != null && !column.getResizable ()) {					return LRESULT.ONE;				}				break;			}			case OS.HDN_ITEMCHANGEDW:			case OS.HDN_ITEMCHANGEDA: {				/*				* Bug in Windows.  When a table has the LVS_EX_GRIDLINES extended				* style and the user drags any column over the first column in the				* table, making the size become zero, when the user drags a column				* such that the size of the first column becomes non-zero, the grid				* lines are not redrawn.  The fix is to detect the case and force				* a redraw of the first column.				*/				int width = OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, 0, 0);				if (lastWidth == 0 && width > 0) {					int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);					if ((bits & OS.LVS_EX_GRIDLINES) != 0) {						RECT rect = new RECT ();						OS.GetClientRect (handle, rect);						rect.right = rect.left + width;						OS.InvalidateRect (handle, rect, true);					}				}				lastWidth = width;				if (!ignoreResize) {					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) {							TableColumn column = columns [phdn.iItem];							if (column != null) {								column.sendEvent (SWT.Resize);								/*								* It is possible (but unlikely), that application								* code could have disposed the widget in the resize								* event.  If this happens, end the processing of the								* Windows message by returning zero as the result of								* the window proc.								*/								if (isDisposed ()) return LRESULT.ZERO;									int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);								if (count == 1 && columns [0] == null) count = 0;								/*								* It is possible (but unlikely), that application								* code could have disposed the column in the move								* event.  If this happens, process the move event								* for those columns that have not been destroyed.								*/								TableColumn [] newColumns = new TableColumn [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);				TableColumn column = columns [phdn.iItem];				if (column != null) {					column.postEvent (SWT.DefaultSelection);				}				break;			}		}	}	LRESULT result = super.WM_NOTIFY (wParam, lParam);	if (result != null) return result;	switch (hdr.code) {		case OS.TTN_GETDISPINFOA:		case OS.TTN_GETDISPINFOW: {			tipRequested = true;			int code = callWindowProc (handle, OS.WM_NOTIFY, wParam, lParam);			tipRequested = false;			return new LRESULT (code);		}	}	return result;}