First of all, you will need to override the CExtTreeCtrl::OnPaintEntireTree()
virtual method in your CExtTreeCtrl
-derived class:
void C_YOUR_TreeCtrl::OnPaintEntireTree( CDC & dc )
{
ASSERT_VALID( this );
ASSERT( dc.GetSafeHdc() != NULL );
CRect rcClient;
GetClientRect( &rcClient );
COLORREF clrTreeBkColor = TreeBkColorGet();
if( clrTreeBkColor == COLORREF(-1L) )
clrTreeBkColor = ::GetSysColor( COLOR_WINDOW );
if( ! PmBridge_GetPM()->PaintDockerBkgnd( true, dc, this ) ) // try to paint themed dialog background first
dc.FillSolidRect( &rcClient, clrTreeBkColor ); // if paint manager does not support it, then paint default background
CFont * pOldFont = dc.SelectObject( &m_fontNormal );
COLORREF clrBackgroundOld = dc.SetBkColor( clrTreeBkColor );
COLORREF clrText = ::GetSysColor( COLOR_BTNTEXT );
COLORREF clrTextOld = dc.SetTextColor( clrText );
int nOldBkMode = dc.SetBkMode( TRANSPARENT );
bool bFocusedWindow = OnQueryWindowFocusedState();
HTREEITEM htiFirst = GetNextItem( NULL, TVGN_FIRSTVISIBLE );
HTREEITEM htiFocus = GetFocusedItem();
HTREEITEM htiDH = GetNextItem( NULL, TVGN_DROPHILITE );
HTREEITEM hti = htiFirst;
for( ; hti != NULL; hti = GetNextItem( hti, TVGN_NEXTVISIBLE ) )
{
bool bDisabledItem = ! OnQueryItemEnabledState( hti );
bool bFocusedItem = ( hti == htiFocus ) ? true : false;
bool bSelectedItem = IsItemSelected( hti );
bool bDH = ( hti == htiDH ) ? true : false;
CRect rcItemEntire;
TreeItemRectGet( hti, rcItemEntire, e_tirt_entire );
if( rcItemEntire.top > rcClient.bottom )
break;
OnPaintTreeItem(
hti,
dc,
rcItemEntire,
bFocusedWindow,
bDisabledItem,
bSelectedItem,
bFocusedItem,
bDH/*,
clrBackground*/
);
dc.SetBkColor( clrTreeBkColor );
dc.SetTextColor( clrText );
}
dc.SetBkMode( nOldBkMode );
dc.SetTextColor( clrTextOld );
dc.SetBkColor( clrBackgroundOld );
dc.SelectObject( pOldFont );
}
This method provides the tree control with the themed dialog background.
Second, you should provide all the tree items with the white text color in the normal non-selected state. The
CExtTreeCtrl::TREEITEMINFO_t::m_clrTextNormal
property of each tree item should be set to the
RGB(255,255,255)
value. I.e. you should adjust this text color after inserting each tree item.