Buggy code:
int nSavedDC = OS . SaveDC ( hDC ) ; GCData data = new GCData ( ) ; data . device = display ; data . foreground = OS . GetTextColor ( hDC ) ; data . background = OS . GetBkColor ( hDC ) ; if ( ( ! selected ) || ( ( ( style ) & ( SWT . FULL_SELECTION ) ) == 0 ) ) { if ( clrText != ( - 1 ) ) data . foreground = clrText ; if ( clrTextBk != ( - 1 ) ) data . background = clrTextBk ; } data . font = item . getFont ( index ) ; data . uiState = ( ( int ) ( OS . SendMessage ( handle , WM_QUERYUISTATE , 0 , 0 ) ) ) ; GC gc = GC . win32_new ( hDC , data ) ; Event event = new Event ( ) ; event . item = item ; event . index = index ; event . gc = gc ; event . detail |= SWT . FOREGROUND ; if ( clrTextBk != ( - 1 ) ) event . detail |= SWT . BACKGROUND ; if ( ( ( style ) & ( SWT . FULL_SELECTION ) ) != 0 ) { if ( hot ) event . detail |= SWT . HOT ; if ( selected ) event . detail |= SWT . SELECTED ; if ( ! ( explorerTheme ) ) { if ( ( OS . SendMessage ( handle , TVM_GETNEXTITEM , TVGN_CARET , 0 ) ) == ( nmcd . dwItemSpec ) ) { if ( ( handle ) == ( OS . GetFocus ( ) ) ) { int uiState = ( ( int ) ( OS . SendMessage ( handle , WM_QUERYUISTATE , 0 , 0 ) ) ) ; if ( ( uiState & ( OS . UISF_HIDEFOCUS ) ) == 0 ) event . detail |= SWT . FOCUSED ; } } } } event . x = cellRect . left ; event . y = cellRect . top ; event . width = ( cellRect . right ) - ( cellRect . left ) ; event . height = ( cellRect . bottom ) - ( cellRect . top ) ; gc . setClipping ( event . x , event . y , event . width , event . height ) ; sendEvent ( EraseItem , event ) ; event . gc = null ; int newTextClr = data . foreground ; gc . dispose ( ) ; OS . RestoreDC ( hDC , nSavedDC ) ; if ( ( isDisposed ( ) ) || ( item . isDisposed ( ) ) ) break ; if ( event . doit ) { ignoreDrawForeground = ( ( event . detail ) & ( SWT . FOREGROUND ) ) == 0 ; ignoreDrawBackground = ( ( event . detail ) & ( SWT . BACKGROUND ) ) == 0 ; if ( ( ( style ) & ( SWT . FULL_SELECTION ) ) != 0 ) { ignoreDrawSelection = ( ( event . detail ) & ( SWT . SELECTED ) ) == 0 ; ignoreDrawFocus = ( ( event . detail ) & ( SWT . FOCUSED ) ) == 0 ; ignoreDrawHot = ( ( event . detail ) & ( SWT . HOT ) ) == 0 ; } } else { ignoreDrawForeground = ignoreDrawBackground = ignoreDrawSelection = ignoreDrawFocus = ignoreDrawHot = true ; } if ( selected && ( ignoreDrawSelection ) ) ignoreDrawHot = true ; if ( ( ( style ) & ( SWT . FULL_SELECTION ) ) != 0 ) { if ( ignoreDrawSelection ) ignoreFullSelection = true ; if ( ( ! ( ignoreDrawSelection ) ) || ( ! ( ignoreDrawHot ) ) ) { if ( ( ! selected ) && ( ! hot ) ) { selectionForeground = OS . GetSysColor ( COLOR_HIGHLIGHTTEXT ) ; } else { if ( ! ( explorerTheme ) ) { drawBackground = true ; ignoreDrawBackground = false ; <START_BUG> if ( ( ( handle ) == ( OS . GetFocus ( ) ) ) && ( OS . IsWindowEnabled ( handle ) ) ) { <END_BUG> clrTextBk = OS . GetSysColor ( COLOR_HIGHLIGHT ) ; } else { clrTextBk = OS . GetSysColor ( COLOR_3DFACE ) ; } if ( ( ! ( ignoreFullSelection ) ) && ( index == ( ( columnCount ) - 1 ) ) ) { RECT selectionRect = new RECT ( ) ; OS . SetRect ( selectionRect , backgroundRect . left , backgroundRect . top , nmcd . right , backgroundRect . bottom ) ; backgroundRect = selectionRect ; } } else { RECT pRect = new RECT ( ) ; OS . SetRect ( pRect , nmcd . left , nmcd . top , nmcd . right , nmcd . bottom ) ; if ( ( ( columnCount ) > 0 ) && ( ( hwndHeader ) != 0 ) ) { int totalWidth = 0 ; HDITEM hdItem = new HDITEM ( ) ; hdItem . mask = OS . HDI_WIDTH ; for ( int j = 0 ; j < ( columnCount ) ; 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 ; } if ( index == ( ( columnCount ) - 1 ) ) { RECT selectionRect = new RECT ( ) ;

Fix:
if ( ( ( ( handle ) == ( OS . GetFocus ( ) ) ) || ( display . getHighContrast ( ) ) ) && ( OS . IsWindowEnabled ( handle ) ) ) {