Here is how to paint a red background for all cells:
bool CYourTreeGrid::OnGridHookCellPaintBackground( const CExtGridCell & _cell, CDC & dc, LONG nVisibleColNo, LONG nVisibleRowNo, LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, const RECT & rcCellExtra, const RECT & rcCell, const RECT & rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags ) const
{
dc.FillSolidRect( &rcCell, RGB(255,0,0) );
return false;
}
Here is how to paint red background for property values, green for categories:
bool CYourTreeGrid::OnGridHookCellPaintBackground( const CExtGridCell & _cell, CDC & dc, LONG nVisibleColNo, LONG nVisibleRowNo, LONG nColNo, LONG nRowNo, INT nColType, INT nRowType, const RECT & rcCellExtra, const RECT & rcCell, const RECT & rcVisibleRange, DWORD dwAreaFlags, DWORD dwHelperPaintFlags ) const
{
HTREEITEM hti = ItemGetByVisibleRowIndex( nRowNo );
ASSERT( hti != NULL );
CExtPropertyItem * pPI = PropertyItemFromTreeItem( hti );
ASSERT( pPI != NULL );
if( pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyValue) ) )
dc.FillSolidRect( &rcCell, RGB(255,0,0) );
else if( pPropertyItem->IsKindOf( RUNTIME_CLASS(CExtPropertyCategory) ) )
dc.FillSolidRect( &rcCell, RGB(0,255,0) );
return false;
}
If this virtual method paints a custom background and returns
false
, the tree grid control assumes there is no custom background and paints only the selected background for selected tree rows. The normal background (not selected) is not painted: it is a white background of the tree grid control. If this virtual method returns
true
, the tree grid assumes your code is completely responsible for painting cell backgrounds.