Buggy code:
int getSelection ( int hItem , TVITEM tvItem , TreeItem [ ] selection , int count ) { } public TreeItem [ ] getSelection ( ) { } public int getSelectionCount ( ) { } public TreeColumn getSortColumn ( ) { } public int getSortDirection ( ) { } public TreeItem getTopItem ( ) { } int imageIndex ( Image image , int index ) { } int imageIndexHeader ( Image image ) { } public int indexOf ( TreeColumn column ) { } public int indexOf ( TreeItem item ) { } void register ( ) { } void releaseItem ( int hItem , TVITEM tvItem , boolean release ) { } void releaseItems ( int hItem , TVITEM tvItem ) { } void releaseHandle ( ) { } void releaseChildren ( boolean destroy ) { } void releaseWidget ( ) { } public void removeAll ( ) { } public void removeSelectionListener ( SelectionListener listener ) { } public void removeTreeListener ( TreeListener listener ) { } public void setInsertMark ( TreeItem item , boolean before ) { } public void setItemCount ( int count ) { } void setItemCount ( int count , int hParent , int hItem ) { } void setItemHeight ( int itemHeight ) { } public void setLinesVisible ( boolean show ) { } int scrolledHandle ( ) { } void select ( int hItem , TVITEM tvItem ) { } public void selectAll ( ) { } void setBackgroundPixel ( int pixel ) { } void setBounds ( int x , int y , int width , int height , int flags ) { } void setCursor ( ) { } public void setColumnOrder ( int [ ] order ) { } void setCheckboxImageList ( ) { } void setForegroundPixel ( int pixel ) { } public void setHeaderVisible ( boolean show ) { } public void setRedraw ( boolean redraw ) { } void setScrollWidth ( ) { if ( ( ( hwndHeader ) == 0 ) || ( ( hwndParent ) == 0 ) ) return ; int width = 0 ; HDITEM hdItem = new HDITEM ( ) ; int count = OS . SendMessage ( hwndHeader , HDM_GETITEMCOUNT , 0 , 0 ) ; for ( int i = 0 ; i < count ; i ++ ) { hdItem . mask = OS . HDI_WIDTH ; OS . SendMessage ( hwndHeader , HDM_GETITEM , i , hdItem ) ; width += hdItem . cxy ; } int left = 0 ; RECT rect = new RECT ( ) ; SCROLLINFO info = new SCROLLINFO ( ) ; info . cbSize = SCROLLINFO . sizeof ; info . fMask = ( OS . SIF_RANGE ) | ( OS . SIF_PAGE ) ; if ( count == 0 ) { OS . GetScrollInfo ( hwndParent , SB_HORZ , info ) ; info . nPage = ( info . nMax ) + 1 ; OS . SetScrollInfo ( hwndParent , SB_HORZ , info , true ) ; OS . GetScrollInfo ( hwndParent , SB_VERT , info ) ; info . nPage = ( info . nMax ) + 1 ; OS . SetScrollInfo ( hwndParent , SB_VERT , info , true ) ; } else { OS . GetClientRect ( hwndParent , rect ) ; OS . GetScrollInfo ( hwndParent , SB_HORZ , info ) ; info . nMax = width ; <START_BUG> info . nPage = ( rect . right ) - ( rect . left ) ; <END_BUG> OS . SetScrollInfo ( hwndParent , SB_HORZ , info , true ) ; info . fMask = OS . SIF_POS ; OS . GetScrollInfo ( hwndParent , SB_HORZ , info ) ; left = info . nPos ; } OS . GetClientRect ( hwndParent , rect ) ; int hHeap = OS . GetProcessHeap ( ) ; HDLAYOUT playout = new HDLAYOUT ( ) ; playout . prc = OS . HeapAlloc ( hHeap , HEAP_ZERO_MEMORY , sizeof ) ; playout . pwpos = OS . HeapAlloc ( hHeap , HEAP_ZERO_MEMORY , WINDOWPOS . sizeof ) ; OS . MoveMemory ( playout . prc , rect , sizeof ) ; OS . SendMessage ( hwndHeader , HDM_LAYOUT , 0 , playout ) ; WINDOWPOS pos = new WINDOWPOS ( ) ; OS . MoveMemory ( pos , playout . pwpos , WINDOWPOS . sizeof ) ; if ( ( playout . prc ) != 0 ) OS . HeapFree ( hHeap , 0 , playout . prc ) ; if ( ( playout . pwpos ) != 0 ) OS . HeapFree ( hHeap , 0 , playout . pwpos ) ; SetWindowPos ( hwndHeader , HWND_TOP , ( ( pos . x ) - left ) , pos . y , ( ( pos . cx ) + left ) , pos . cy , SWP_NOACTIVATE ) ; int w = ( pos . cx ) + ( count == 0 ? 0 : OS . GetSystemMetrics ( SM_CXVSCROLL ) ) ; int h = ( ( rect . bottom ) - ( rect . top ) ) - ( pos . cy ) ; boolean oldIgnore = ignoreResize ; ignoreResize = true ; SetWindowPos ( handle , 0 , ( ( pos . x ) - left ) , ( ( pos . y ) + ( pos . cy ) ) , ( w + left ) , h , ( ( OS . SWP_NOACTIVATE ) | ( OS . SWP_NOZORDER ) ) ) ; ignoreResize = oldIgnore ; } void setSelection ( int hItem , TVITEM tvItem , TreeItem [ ] selection ) { } public void setSelection ( TreeItem [ ] items ) { } public void setSortColumn ( TreeColumn column ) { } public void setSortDirection ( int direction ) { } public void setTopItem ( TreeItem item ) { } void showItem ( int hItem ) { }

Fix:
info . nPage = ( ( rect . right ) - ( rect . left ) ) + 1 ;