Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Focused cell in grid with __EGBS_SFB_FULL_ROWS style Collapse All
Subject Author Date
Suhai Gyorgy Aug 28, 2007 - 9:19 AM

Dear Support,

I have a grid with the __EGBS_SFB_FULL_ROWS style set. If I use the mouse to make a cell focused and then change rows with down arrow, the focused cell stays to be in the same column as before (I can check this by pressing Enter key, thus getting into edit mode). But pressing left/right arrow does not change the focused cell in the same row.

In another way: let’s say the user edits a cell, then presses Enter (comes out of inplace editor) then presses left or right arrow and then presses Enter again. Right now the same cell gets to be edited as before. I’d like to change this behaviour and have the cell on the left/right to get into edit mode.

Could you please consider this feature?
Thank you!

Technical Support Aug 29, 2007 - 12:36 PM

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
                        );
      }