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 » ASSERT fails in CExtGridCell::OnQueryBackColor() Collapse All
Subject Author Date
Bob Sabiston Apr 27, 2006 - 6:27 PM

I’m using a CExtGridCell-based class (Prof-UIS 2.50) to implement an interface component. After the columns are layed out and the header created, code like the following is used to populate the cells.

    CExtGridCellString * pCellName =
    static_cast <CExtGridCellString *>
        (GridCellGet(
            1L,
            m_iKnt,
            0,
            0,
            RUNTIME_CLASS(CExtGridCellString),
            false,
            false
        ));    
    pCellName->TextSet(sName.c_str());

    if (m_bInRedo)
    {
        pCellName->BackColorSet(CExtGridCell::__ECS_NORMAL, sm_BkClrRedo);
        pCellName->BackColorSet(CExtGridCell::__ECS_SELECTED, sm_BkHiClrRedo);
    }
    else
    {
        pCellName->BackColorSet(CExtGridCell::__ECS_NORMAL, sm_BkClrUndo);
        pCellName->BackColorSet(CExtGridCell::__ECS_SELECTED, sm_BkHiClrUndo);
    }

This code works fine and appears to set the background colors as desired (i.e., there is no failure so long as the window is not visible), but when the window becomes visible, I get a "Debug Assertion Failed" message. It seems to be this ASSERT in CExtGridCell::OnQueryBackColor():

    if( clrBack != COLORREF(-1L) )
    {
        DWORD dwSiwStyleEx = wndGrid.SiwGetStyleEx();
        ASSERT( ( dwSiwStyleEx & (__EGBS_EX_HVI_EVENT_CELLS|__EGBS_EX_HVO_EVENT_CELLS) ) != 0 );
        return clrBack;
    }

It is the case that neither of these options are not set, but I’m (currently) not interested in hovering behaviour, just customizing the normal and selected background colours. NOTE: Non-debug builds exhibit no problems, and the grid appears and behaves as expected. Suggestions?

Bob Sabiston Apr 27, 2006 - 6:57 PM

1) In my initial post I neglected to include the most important code, that which sets the styles:


        SiwModifyStyle(
                __ESIS_STH_ITEM
            |    __ESIS_STV_ITEM
            | __EGBS_SFB_FULL_ROWS
            | __EGBS_GRIDLINES
            | __EGBS_NO_HIDE_SELECTION    
            ,
            0,
            false
            );

        SiwModifyStyleEx(
            __EGBS_EX_CELL_EXPANDING_OUTER_B
            ,
            0,
            false
            );

        BseModifyStyle(
        0L
        ,
        __EGWS_BSE_DEFAULT,
        false
        );

2) I tried OR’ing EGBS_EX_HVI_EVENT_CELLS with the SiwModifyStyleEx() arg, and, sure enough, the problem went away!

This is good, but is still magic to me. Any information that might clarify what styles are required when would be greatly appreciated.

Technical Support Apr 30, 2006 - 7:10 AM

The __EGBS_EX_HVI_EVENT_CELLS style, if applied, allows inner data cells to receive hover events. The __EGBS_EX_HVO_EVENT_CELLS style, if applied, allows outer header cells to receive hover events. The hover event allows you to change the font, text color, or background color of a cell when the cell gets hovered by the mouse pointer. You can do that in the CExtGridCell::OnHover() virtual method. Although these two styles can be used even if you do not need to change any cell styles, the grid control works faster if the hover events are not generated. In case of your grid, these styles should be used.