Buggy code:
TreeColumn [ ] columns ; ImageList imageList ; ImageList headerImageList ; TreeItem currentItem ; TreeColumn sortColumn ; int hwndParent ; int hwndHeader ; int hAnchor ; int hInsert ; int lastID ; int hFirstIndexOf ; int hLastIndexOf ; int lastIndexOf ; int itemCount ; int sortDirection ; boolean dragStarted ; boolean gestureCompleted ; boolean insertAfter ; boolean shrink ; boolean ignoreSelect ; boolean ignoreExpand ; boolean ignoreDeselect ; boolean ignoreResize ; boolean lockSelection ; boolean oldSelected ; boolean newSelected ; boolean ignoreColumnMove ; boolean linesVisible ; boolean customDraw ; boolean printClient ; boolean painted ; boolean ignoreItemHeight ; boolean ignoreDraw ; boolean ignoreDrawSelection ; boolean ignoreDrawBackground ; int scrollWidth ; int headerToolTipHandle ; int selectionForeground ; static final int INSET = 3 ; static final int GRID_WIDTH = 1 ; static final int SORT_WIDTH = 10 ; static final int HEADER_MARGIN = 12 ; static final int HEADER_EXTRA = 3 ; static final int INCREMENT = 5 ; static final int TreeProc ; static final TCHAR TreeClass = new TCHAR ( 0 , OS . WC_TREEVIEW , true ) ; static final int HeaderProc ; static final TCHAR HeaderClass = new TCHAR ( 0 , OS . WC_HEADER , true ) ; public Tree ( Composite parent , int style ) { } static int checkStyle ( int style ) { } void _addListener ( int eventType , Listener listener ) { } TreeItem _getItem ( int hItem ) { } TreeItem _getItem ( int hItem , int id ) { } void _setBackgroundPixel ( int newPixel ) { } public void addSelectionListener ( SelectionListener listener ) { } public void addTreeListener ( TreeListener listener ) { } int borderHandle ( ) { } LRESULT CDDS_ITEMPOSTPAINT ( int wParam , int lParam ) { } LRESULT CDDS_ITEMPREPAINT ( int wParam , int lParam ) { NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW ( ) ; OS . MoveMemory ( nmcd , lParam , sizeof ) ; int id = nmcd . lItemlParam ; if ( ( ( style ) & ( SWT . VIRTUAL ) ) != 0 ) { if ( id == ( - 1 ) ) { TVITEM tvItem = new TVITEM ( ) ; tvItem . mask = ( OS . TVIF_HANDLE ) | ( OS . TVIF_PARAM ) ; tvItem . hItem = nmcd . dwItemSpec ; OS . SendMessage ( handle , TVM_GETITEM , 0 , tvItem ) ; id = tvItem . lParam ; } } TreeItem item = _getItem ( nmcd . dwItemSpec , id ) ; if ( item == null ) return null ; RECT clipRect = null ; int index = 0 ; int count = 0 ; if ( ( hwndHeader ) != 0 ) { index = OS . SendMessage ( hwndHeader , HDM_ORDERTOINDEX , 0 , 0 ) ; count = OS . SendMessage ( hwndHeader , HDM_GETITEMCOUNT , 0 , 0 ) ; <START_BUG> if ( count != 0 ) { <END_BUG> clipRect = new RECT ( ) ; HDITEM hdItem = new HDITEM ( ) ; hdItem . mask = OS . HDI_WIDTH ; OS . SendMessage ( hwndHeader , HDM_GETITEM , index , hdItem ) ; OS . SetRect ( clipRect , nmcd . left , nmcd . top , ( ( nmcd . left ) + ( hdItem . cxy ) ) , nmcd . bottom ) ; } } int clrText = - 1 ; int clrTextBk = - 1 ; int hFont = ( ( item . cellFont ) != null ) ? item . cellFont [ index ] : - 1 ; if ( hFont == ( - 1 ) ) hFont = item . font ; if ( OS . IsWindowEnabled ( handle ) ) { clrText = ( ( item . cellForeground ) != null ) ? item . cellForeground [ index ] : - 1 ; if ( clrText == ( - 1 ) ) clrText = item . foreground ; clrTextBk = ( ( item . cellBackground ) != null ) ? item . cellBackground [ index ] : - 1 ; if ( clrTextBk == ( - 1 ) ) clrTextBk = item . background ; } int clrSortBk = - 1 ; if ( ( ( OS . COMCTL32_MAJOR ) >= 6 ) && ( OS . IsAppThemed ( ) ) ) { if ( ( ( sortColumn ) != null ) && ( ( sortDirection ) != ( SWT . NONE ) ) ) { if ( ( findImageControl ( ) ) == null ) { if ( ( indexOf ( sortColumn ) ) == index ) { clrTextBk = clrSortBk = getSortColumnPixel ( ) ; } } } } int hDC = nmcd . hdc ; boolean selected = false ; if ( OS . IsWindowEnabled ( handle ) ) { TVITEM tvItem = new TVITEM ( ) ; tvItem . mask = ( OS . TVIF_HANDLE ) | ( OS . TVIF_STATE ) ; tvItem . hItem = item . handle ; OS . SendMessage ( handle , TVM_GETITEM , 0 , tvItem ) ; if ( ( ( tvItem . state ) & ( ( OS . TVIS_SELECTED ) | ( OS . TVIS_DROPHILITED ) ) ) != 0 ) { selected = true ; if ( ( handle ) == ( OS . GetFocus ( ) ) ) { if ( ( OS . GetTextColor ( hDC ) ) != ( OS . GetSysColor ( COLOR_HIGHLIGHTTEXT ) ) ) { selected = false ; } else { if ( ( OS . GetBkColor ( hDC ) ) != ( OS . GetSysColor ( COLOR_HIGHLIGHT ) ) ) { selected = false ; } } } } }

Fix:
if ( ( count != 0 ) && ( ! ( printClient ) ) ) {