If your grid window uses the full-row selection model, any stand-alone grid cells cannot be focused nor selected. Please use the __EGBS_SFM_CELLS_HV
style instead and add the following virtual methods to your grid class:
virtual CRect & _SelectionAreaConvert( CRect & rcArea ) const
{
ASSERT_VALID( this );
rcArea.left = 0;
rcArea.right = ColumnCountGet();
if( rcArea.right > 0 )
rcArea.right --;
return rcArea;
}
virtual COLORREF OnGridCellQueryTextColor(
const CExtGridCell & _cell,
CDC & dc,
LONG nVisibleColNo,
LONG nVisibleRowNo,
LONG nColNo,
LONG nRowNo,
INT nColType,
INT nRowType,
DWORD dwAreaFlags,
DWORD dwHelperPaintFlags
) const
{
ASSERT_VALID( this );
COLORREF clrText =
CExtGridWnd::OnGridCellQueryTextColor(
_cell,
dc,
nVisibleColNo,
nVisibleRowNo,
nColNo,
nRowNo,
nColType,
nRowType,
dwAreaFlags,
dwHelperPaintFlags
);
if( clrText != COLORREF(-1L) )
return clrText;
if( (SiwGetStyle()&__EGBS_SFB_MASK) == __EGBS_SFB_CELLS )
{
if( nColType == 0 && nRowType == 0 && nColNo >= 0 && nRowNo >= 0 )
{
CPoint ptFocus = FocusGet();
if( ptFocus.x == nColNo && ptFocus.y == nRowNo )
return OnSiwGetSysColor( COLOR_BTNTEXT );
}
}
return COLORREF(-1L);
}
virtual bool 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
{
ASSERT_VALID( this );
if( ( dwAreaFlags & __EGBWA_INNER_CELLS ) != 0 )
{
CPoint ptFocus = FocusGet();
if( ptFocus.x == nColNo && ptFocus.y == nRowNo )
{
COLORREF clrAlternativeFocus1 =
OnSiwGetSysColor( COLOR_HIGHLIGHT );
COLORREF clrAlternativeFocus2 =
OnSiwGetSysColor( COLOR_WINDOW );
COLORREF clrAlternativeFocus =
CExtPaintManager::stat_RGB_Enlight(
clrAlternativeFocus1,
clrAlternativeFocus2,
32
);
dc.FillSolidRect(
&rcCell,
clrAlternativeFocus
);
return true;
}
}
return
CExtGridWnd::OnGridHookCellPaintBackground(
_cell,
dc,
nVisibleColNo,
nVisibleRowNo,
nColNo,
nRowNo,
nColType,
nRowType,
rcCellExtra,
rcCell,
rcVisibleRange,
dwAreaFlags,
dwHelperPaintFlags
);
}
As a result, your grid window will use the full-row selection and column based focus models.