Buggy code:
if ( ( ( phdn . iItem ) != ( - 1 ) ) && ( ( phdn . pitem ) != 0 ) ) { HDITEM pitem = new HDITEM ( ) ; OS . MoveMemory ( pitem , phdn . pitem , HDITEM . sizeof ) ; if ( ( ( ( pitem . mask ) & ( OS . HDI_ORDER ) ) != 0 ) && ( ( pitem . iOrder ) != ( - 1 ) ) ) { int count = OS . SendMessage ( hwndHeader , HDM_GETITEMCOUNT , 0 , 0 ) ; int [ ] order = new int [ count ] ; OS . SendMessage ( hwndHeader , HDM_GETORDERARRAY , count , order ) ; int index = 0 ; while ( index < ( order . length ) ) { if ( ( order [ index ] ) == ( phdn . iItem ) ) break ; index ++ ; } if ( index == ( order . length ) ) index = 0 ; if ( index == ( pitem . iOrder ) ) break ; int start = Math . min ( index , pitem . iOrder ) ; int end = Math . max ( index , pitem . iOrder ) ; RECT rect = new RECT ( ) ; RECT headerRect = new RECT ( ) ; OS . GetClientRect ( handle , rect ) ; OS . SendMessage ( hwndHeader , HDM_GETITEMRECT , order [ start ] , headerRect ) ; rect . left = Math . max ( rect . left , headerRect . left ) ; OS . SendMessage ( hwndHeader , HDM_GETITEMRECT , order [ end ] , headerRect ) ; rect . right = Math . min ( rect . right , headerRect . right ) ; OS . InvalidateRect ( handle , rect , true ) ; ignoreColumnMove = false ; for ( int i = start ; i <= end ; i ++ ) { TreeColumn column = columns [ order [ i ] ] ; if ( ! ( column . isDisposed ( ) ) ) { column . postEvent ( Move ) ; } } } } 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 ) { RECT rect = new RECT ( ) ; OS . GetClientRect ( handle , rect ) ; RECT headerRect = new RECT ( ) ; int count = OS . SendMessage ( hwndHeader , HDM_GETITEMCOUNT , 0 , 0 ) ; int index = OS . SendMessage ( hwndHeader , HDM_ORDERTOINDEX , ( count - 1 ) , 0 ) ; OS . SendMessage ( hwndHeader , HDM_GETITEMRECT , index , headerRect ) ; rect . right = Math . max ( rect . right , headerRect . right ) ; OS . SendMessage ( hwndHeader , HDM_GETITEMRECT , phdn . iItem , headerRect ) ; int gridWidth = ( getLinesVisible ( ) ) ? Tree . GRID_WIDTH : 0 ; rect . left = ( headerRect . right ) - gridWidth ; if ( ( findImageControl ( ) ) != null ) { OS . InvalidateRect ( handle , rect , true ) ; } else { HDITEM oldItem = new HDITEM ( ) ; oldItem . mask = OS . HDI_WIDTH ; OS . SendMessage ( hwndHeader , HDM_GETITEM , phdn . iItem , oldItem ) ; int deltaX = ( newItem . cxy ) - ( oldItem . cxy ) ; int flags = ( OS . SW_INVALIDATE ) | ( OS . SW_ERASE ) ; OS . ScrollWindowEx ( handle , deltaX , 0 , rect , null , 0 , null , flags ) ; } <START_BUG> if ( ( phdn . iItem ) != 0 ) { <END_BUG> rect . left = headerRect . left ; rect . right = headerRect . 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 ) { if ( ( ( style ) & ( SWT . DOUBLE_BUFFERED ) ) == 0 ) { if ( ignoreColumnMove ) { int oldStyle = style ; style |= SWT . DOUBLE_BUFFERED ; OS . UpdateWindow ( handle ) ; style = oldStyle ; } } TreeColumn column = columns [ phdn . iItem ] ; if ( column != null ) { column . updateToolTip ( phdn . iItem ) ; column . sendEvent ( Resize ) ; if ( isDisposed ( ) ) return LRESULT . ZERO ; int count = OS . SendMessage ( hwndHeader , HDM_GETITEMCOUNT , 0 , 0 ) ; TreeColumn [ ] newColumns = new TreeColumn [ count ] ; System . arraycopy ( columns , 0 , newColumns , 0 , count ) ; int [ ] order = new int [ count ] ; OS . SendMessage ( hwndHeader , HDM_GETORDERARRAY , count , order ) ;

Fix:
if ( ( OS . SendMessage ( hwndHeader , HDM_ORDERTOINDEX , phdn . iItem , 0 ) ) != 0 ) {