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 » Problem in tree grid Collapse All
Subject Author Date
Rado Manzela Mar 8, 2010 - 8:27 AM

I need to display some rows in CExtTreeGridWnd with the same background as outer cells. I’ve overrided OnGridHookCellPaintBackground(), but I need to get row’s HTREEITEM to assign correct background (as efficiently as possible). How can I do this?

I’ve tried this:


 


bool CChildView::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 {        const CExtTreeGridDataProvider &dp = GetTreeData();     const CExtTreeGridCellNode *_c = dp.TreeNodeGetByVisibleRowIndex(nRowNo);


but the last line asserts here in the very first call:



CExtTreeGridCellNode * CExtTreeGridDataProvider::_Tree_NodeGetByVisibleRowIndex( ULONG nRowNo )
{
    ASSERT_VALID( this );
CExtGridDataProvider & _DP = _Tree_GetCacheDP();
    nRowNo = _Tree_MapRowToCache( nRowNo );
CExtTreeGridCellNode * pNode =
        STATIC_DOWNCAST(
            CExtTreeGridCellNode,
            _DP.CellGet( 0, nRowNo )
            );
    ASSERT_VALID( pNode );  // ASSERTS (pNode=NULL)
    return pNode;
}

Is it bug, or am I doing something wrong? (I’m using 2.87)


Thank you

Technical Support Mar 9, 2010 - 8:37 AM

The CExtTreeGridWnd::ItemGetByVisibleRowIndex() method can convert the nRowNo parameter into a HTREEITEM tree row handle. The tree rows under collapsed tree rows do not have visible row indices. But the painting methods are always invoked for displayed tree rows which have plain row indices. You should not access the tree grid data provider because it can reserve additional invisible rows and columns at run-time. That’s why you can come across unwanted assertion failures.

Rado Manzela Mar 10, 2010 - 1:15 AM

What is the solution then? My tree contains more types of cells derived from string, numeric, currency cells so I don’t like idea to override OnPaintBackground in each cell type.

Technical Support Mar 10, 2010 - 2:06 PM

You don’t have to override the CExtGridCell::OnPaintBackground() virtual method of many grid cell classes. You really should override only the CExtGridWnd::OnGridHookCellPaintBackground() virtual method in your tree grid class and return true flag from your overridden virtual method only for those grid cells whose background was repainted by your method. We explained you how to get the HTREEITEM handle of the tree row. Now you should decide whether to paint custom background for all/some grid cells in this tree row. Only you can really know which of tree rows should have custom background. For instance, you can get some grid cell from some column and analyze its data, then decide whether you should paint custom background in this tree row. We need to know more details about your task to provide you with ready to use source code.
For your information: the wndGrid.PmBridge_GetPM()->Grid_PaintHeaderBackground( . . . ) code draws the header cell background. You can see how to do this in the CExtGridCell::OnPaintBackground() virtual method.
Additionally, we think you should not paint custom background for the selected and/or focused grid rows. The dwHelperPaintFlags parameter is present in all the painting methods of grid cells and grid control. This parameter contains a set of the __EGCPF_*** flags. If both the __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN|__EGCPF_HIGHLIGHTED_BY_FOCUSED_ROW flags present, then the grid cell is focused. If both the __EGCPF_HIGHLIGHTED_BY_SELECTED_COLUMN|__EGCPF_HIGHLIGHTED_BY_SELECTED_ROW flags present, then the grid cell is selected. If you are using the full row selection model, then you should test only the __EGCPF_HIGHLIGHTED_BY_FOCUSED_COLUMN and __EGCPF_HIGHLIGHTED_BY_SELECTED_COLUMN flags presence.

Rado Manzela Mar 11, 2010 - 2:00 AM

Thank you for your help. I apologize I haven’t realized that you’ve suggested me different function than I was using, I’ve thought you are just telling me that I cannot do that.

Rado Manzela Mar 9, 2010 - 8:08 AM

I’ve also added test to filter out outer cells at beginning of the function, but it didn’t help



 



 


if (nRowType || nColType)return false;