Buggy code:
RECT pClipRect = new RECT ( ) ; OS . SetRect ( pClipRect , width , nmcd . top , nmcd . right , nmcd . bottom ) ; if ( explorerTheme ) { if ( hooks ( EraseItem ) ) { RECT itemRect = item . getBounds ( index , true , true , false , false , false , hDC ) ; if ( explorerTheme ) { itemRect . left -= Tree . EXPLORER_EXTRA ; itemRect . right += Tree . EXPLORER_EXTRA ; } pClipRect . left = itemRect . left ; } RECT pRect = new RECT ( ) ; OS . SetRect ( pRect , nmcd . left , nmcd . top , nmcd . right , nmcd . bottom ) ; if ( ( count > 0 ) && ( ( hwndHeader ) != 0 ) ) { int totalWidth = 0 ; HDITEM hdItem = new HDITEM ( ) ; hdItem . mask = OS . HDI_WIDTH ; for ( int j = 0 ; j < count ; j ++ ) { OS . SendMessage ( hwndHeader , HDM_GETITEM , j , hdItem ) ; totalWidth += hdItem . cxy ; } if ( totalWidth > ( ( clientRect . right ) - ( clientRect . left ) ) ) { pRect . left = 0 ; pRect . right = totalWidth ; } else { pRect . left = clientRect . left ; pRect . right = clientRect . right ; } } draw = false ; int hTheme = OS . OpenThemeData ( handle , TREEVIEW ) ; int iStateId = ( selected ) ? OS . TREIS_SELECTED : OS . TREIS_HOT ; if ( ( ( ( OS . GetFocus ( ) ) != ( handle ) ) && selected ) && ( ! hot ) ) iStateId = OS . TREIS_SELECTEDNOTFOCUS ; OS . DrawThemeBackground ( hTheme , hDC , TVP_TREEITEM , iStateId , pRect , pClipRect ) ; OS . CloseThemeData ( hTheme ) ; } if ( draw ) fillBackground ( hDC , OS . GetBkColor ( hDC ) , pClipRect ) ; } } else { if ( ( explorerTheme ) && ( hooks ( EraseItem ) ) ) { boolean hot = ( explorerTheme ) && ( ( ( nmcd . uItemState ) & ( OS . CDIS_HOT ) ) != 0 ) ; if ( ( selected || hot ) && ( ! ( ignoreDrawSelection ) ) ) { RECT pRect = item . getBounds ( index , true , true , false , false , false , hDC ) ; RECT pClipRect = item . getBounds ( index , true , true , false , false , true , hDC ) ; pRect . left -= Tree . EXPLORER_EXTRA ; pRect . right += Tree . EXPLORER_EXTRA ; pClipRect . left -= Tree . EXPLORER_EXTRA ; pClipRect . right += Tree . EXPLORER_EXTRA ; int hTheme = OS . OpenThemeData ( handle , TREEVIEW ) ; int iStateId = ( selected ) ? OS . TREIS_SELECTED : OS . TREIS_HOT ; if ( ( ( ( OS . GetFocus ( ) ) != ( handle ) ) && selected ) && ( ! hot ) ) iStateId = OS . TREIS_SELECTEDNOTFOCUS ; OS . DrawThemeBackground ( hTheme , hDC , TVP_TREEITEM , iStateId , pRect , pClipRect ) ; OS . CloseThemeData ( hTheme ) ; } } } } if ( ( x + width ) > ( clientRect . left ) ) { RECT rect = new RECT ( ) ; RECT backgroundRect = null ; boolean drawItem = true ; boolean drawText = true ; boolean drawImage = true ; boolean drawBackground = false ; if ( i == 0 ) { drawItem = drawImage = drawText = false ; if ( ( findImageControl ( ) ) != null ) { if ( explorerTheme ) { <START_BUG> if ( OS . IsWindowEnabled ( handle ) ) { <END_BUG> Image image = null ; if ( index == 0 ) { image = item . image ; } else { Image [ ] images = item . images ; if ( images != null ) image = images [ index ] ; } if ( image != null ) { Rectangle bounds = image . getBounds ( ) ; if ( size == null ) size = getImageSize ( ) ; if ( ! ( ignoreDrawForeground ) ) { GCData data = new GCData ( ) ; data . device = display ; GC gc = GC . win32_new ( hDC , data ) ; RECT iconRect = item . getBounds ( index , false , true , false , false , true , hDC ) ; gc . setClipping ( iconRect . left , iconRect . top , ( ( iconRect . right ) - ( iconRect . left ) ) , ( ( iconRect . bottom ) - ( iconRect . top ) ) ) ; gc . drawImage ( image , 0 , 0 , bounds . width , bounds . height , iconRect . left , iconRect . top , size . x , size . y ) ; OS . SelectClipRgn ( hDC , 0 ) ; gc . dispose ( ) ; } } } } else { drawItem = drawText = drawBackground = true ; rect = item . getBounds ( index , true , false , false , false , true , hDC ) ; if ( linesVisible ) { ( rect . right ) ++ ; ( rect . bottom ) ++ ; } } } if ( ( selected && ( ! ( ignoreDrawSelection ) ) ) && ( ! ( ignoreDrawBackground ) ) ) { if ( ! ( explorerTheme ) ) fillBackground ( hDC , OS . GetBkColor ( hDC ) , rect ) ; drawBackground = false ;

Fix:
if ( ( OS . IsWindowEnabled ( handle ) ) && ( ! ( hooks ( EraseItem ) ) ) ) {