for (int i=index + 1; i<columns.length; i++) { if (!columns [i].isDisposed ()) { columns [i].sendEvent (SWT.Move);
for (int i=0; i<order.length; i++) { TableColumn column = columns [order [i]]; if (moved && !column.isDisposed ()) { column.sendEvent (SWT.Move);
public void pack () {	checkWidget ();	int index = parent.indexOf (this);	if (index == -1) return;	int hwnd = parent.handle;	int oldWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);	TCHAR buffer = new TCHAR (parent.getCodePage (), text, true);	int headerWidth = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Table.HEADER_MARGIN;	if (image != null) {		int margin = 0;		if (OS.COMCTL32_VERSION >= OS.VERSION (5, 80)) {			int hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);			margin = OS.SendMessage (hwndHeader, OS.HDM_GETBITMAPMARGIN, 0, 0);		} else {			margin = OS.GetSystemMetrics (OS.SM_CXEDGE) * 3;		}		Rectangle rect = image.getBounds ();		headerWidth += rect.width + margin * 2;	}	boolean oldIgnoreRezize = parent.ignoreResize;	parent.ignoreResize = true;	OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);	int columnWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);	/*	* Bug in Windows.  When LVM_SETCOLUMNWIDTH is used with LVSCW_AUTOSIZE	* where each item has I_IMAGECALLBACK but there are no images in the	* table, the size computed by LVM_SETCOLUMNWIDTH is too small for the	* first column, causing long items to be clipped with '...'.  The fix	* is to increase the value by a small amount. 	*/	if (index == 0 && parent.imageList == null) columnWidth += 2;	if (headerWidth > columnWidth) {		if (image == null) {			/*			* Feature in Windows.  When LVSCW_AUTOSIZE_USEHEADER is used			* with LVM_SETCOLUMNWIDTH to resize the last column, the last			* column is expanded to fill the client area.  The fix is to			* resize the table to be small, set the column width and then			* restor the table to its original size.			*/			RECT rect = null;			boolean fixWidth = index == parent.getColumnCount () - 1;			if (fixWidth) {				rect = new RECT ();				OS.GetWindowRect (hwnd, rect);				OS.UpdateWindow (hwnd);				int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;				SetWindowPos (hwnd, 0, 0, 0, 0, rect.bottom - rect.top, flags);			}			OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE_USEHEADER);			if (fixWidth) {				int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOZORDER;				SetWindowPos (hwnd, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags);			}		} else {			OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, headerWidth);		}	} else {		if (index == 0) {			OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, columnWidth);		}	}	parent.ignoreResize = oldIgnoreRezize;	int newWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);	if (oldWidth != newWidth) {		sendEvent (SWT.Resize);		if (isDisposed ()) return;		TableColumn [] columns = parent.getColumns ();		for (int i=index + 1; i<columns.length; i++) {			if (!columns [i].isDisposed ()) {				columns [i].sendEvent (SWT.Move);			}		}	}}