The full row/focus selection model means grid cells are not editable or only one column is editable. This approach is used in tree grids inside the property grid. We think you should use the full row selection model with column-based focus like in the report grid model. This is a bit tricky implementation of the selection mode. The CExtGridWnd
control is configured for any cell range selection. But each selected cell range is automatically converted/extended on-the-fly for covering all the columns. The focused cell is re-painted with a non-selected background. Such grid has the full-row selection model and the single cell focus model. First of all, you should initialize your CExtGridWnd
control with __EGBS_SFB_CELLS
or __EGBS_SFM_CELLS
selection type. Second, you should use your own CExtGridWnd
-derived class which implements the following virtual methods:
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
);
}