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 » BackstageView crash in CExtRichContentScrollWnd::OnRcsAnalyzeMouseClickEvent Collapse All
Subject Author Date
Wilhelm Falkner May 12, 2012 - 8:21 AM

Hi,


when real working with BackstageView, the programm is crashing in CExtRichContentScrollWnd::OnRcsAnalyzeMouseClickEvent (Line 10536 of ExtScrollWnd.cpp V2.93). This happens when doning a real action. e.g. having a command "Open File". When opening the file, the crash happens. It crash, if I make the BSV invisable or not. What I tried is to modify Your code by checking again, if _ht_item.m_pRCI is valid. But I’m not sure, if this is the right solution. Can You please advise?


 


TIA


Willi

Technical Support May 23, 2012 - 11:45 AM

We reproduced this issue. Thank you. To fix it please update the source code for the following method:

bool CExtRichContentScrollWnd::OnRcsAnalyzeMouseClickEvent(
    UINT nChar, // VK_LBUTTON, VK_RBUTTON or VK_MBUTTON only
    UINT nRepCnt, // 0 - button up, 1 - single click, 2 - double click, 3 - post single click & begin editing
    UINT nFlags, // mouse event flags
    CPoint point // mouse pointer in client coordinates
    )
{
    ASSERT_VALID( this );
    if( m_nMouseActivateCode == MA_ACTIVATE && ::GetFocus() != m_hWnd )
        SetFocus();
CExtRichContentLayout * pRCL = RcsLayoutGet();
CExtRichContentItem * pRootRCI = ( pRCL->m_listHeap.GetCount() > 0 ) ? pRCL->m_listHeap.GetHead() : NULL;
    if( pRootRCI == NULL )
        return true;
    if( nChar != VK_LBUTTON )
        return true;
CExtRichContentHitTestInfo htInfoPressed( point + OnSwGetScrollPos(), *pRCL );
    htInfoPressed.HitTest();
    if(        nRepCnt == 1
        &&    htInfoPressed.m_listHtBranch.GetCount() > 0
        &&    ( ( htInfoPressed.m_listHtBranch.GetTail().m_dwHtFlags & (__ERCHT_ON_ANY_SCROLL_BAR|__ERCHT_ON_SB_DISABLED) ) != 0 )
        )
    {
        OnRcsAnalyzeScrollBarMouseClickEvent( htInfoPressed );
        return true;
    }
bool bQuickReStyleMode = ( ( RcsGetStyle() & __EXT_RCS_QUICK_RESTYLE_MODE ) ) ? true : false;
bool bRecalcPassed = false;
//    if( m_htInfoPressed == htInfoPressed )
//        return true;
CList < CExtRichContentHitTestInfo::ht_item_t, CExtRichContentHitTestInfo::ht_item_t & > & _listHtBranch =
        ( nRepCnt == 1 ) ? htInfoPressed.m_listHtBranch : m_htInfoPressed.m_listHtBranch;
POSITION pos = _listHtBranch.GetHeadPosition();
bool bHaveElementsWithResetStyles = false;
CExtRichContentItem * pRCI_LastSupportingPressed = NULL;
CExtRichStyleDescription::pseudo_class_def_t statesFocusOnly;
    statesFocusOnly.m_eynFocus = CExtRichStyleDescription::e_ui_yn_yes;
CExtRichStyleDescription::pseudo_class_def_t statesPressedOnly;
    statesPressedOnly.m_eynPressed = CExtRichStyleDescription::e_ui_yn_yes;
CExtRichContentItem * pRCI_next_focus = NULL, * pResetStyleRCI;
    for( pResetStyleRCI = NULL; pos != NULL; )
    {
        CExtRichContentHitTestInfo::ht_item_t & _ht_item = _listHtBranch.GetNext( pos );
        __EXT_DEBUG_RICH_CONTENT_ASSERT( _ht_item.m_pRCI != NULL );
        if( nRepCnt == 0 || nRepCnt == 2 )
        {
            _ht_item.m_pRCI->RciEvent_OnPressedLeave( nChar, nRepCnt, nFlags, m_htInfoPressed, htInfoPressed, m_hWnd );
            _ht_item.m_pRCI->ResetElementStateInfo( statesPressedOnly, CExtRichStyleDescription::e_ui_yn_unspecified );
            if( _ht_item.m_pRCI->HaveAffectedCssPseudoClasses( statesPressedOnly ) )
            {
                bHaveElementsWithResetStyles = true;
                pResetStyleRCI = _ht_item.m_pRCI;
            }
        }
        else if( nRepCnt == 1 )
        {
            _ht_item.m_pRCI->RciEvent_OnPressedEnter( nChar, nRepCnt, nFlags, m_htInfoPressed, htInfoPressed, m_hWnd );
            _ht_item.m_pRCI->ResetElementStateInfo( statesPressedOnly, CExtRichStyleDescription::e_ui_yn_yes );
            if( _ht_item.m_pRCI->HaveAffectedCssPseudoClasses( statesPressedOnly ) )
            {
                bHaveElementsWithResetStyles = true;
                pResetStyleRCI = _ht_item.m_pRCI;
            }
        }
        if( _ht_item.m_pRCI->HaveAffectedCssPseudoClasses( statesPressedOnly ) )
        {
            bHaveElementsWithResetStyles = true;
            pRCI_LastSupportingPressed = _ht_item.m_pRCI;
            pResetStyleRCI = _ht_item.m_pRCI;
        }
        if( _ht_item.m_pRCI->HaveAffectedCssPseudoClasses( statesFocusOnly ) )
            pRCI_next_focus = _ht_item.m_pRCI;
    } // for( pResetStyleRCI = NULL; pos != NULL; )
    if( pResetStyleRCI != NULL )
        OnRcsResetElementStyle( pResetStyleRCI );

    if( bHaveElementsWithResetStyles )
        OnSwInvalidate( m_bRedrawErase );

bool bRecalc = false;
    if( nRepCnt == 0 || nRepCnt == 2 )
    {
        bRecalc = true;
        m_bPressedTracking = false;
        m_bProcessingCancelMode = true;
        if( ::GetCapture() == m_hWnd )
            ::ReleaseCapture();
        m_bProcessingCancelMode = false;
        if( m_nVkPressed == nChar && pRCI_LastSupportingPressed != NULL && pRCI_LastSupportingPressed->CalcEffectiveRect().PtInRect( point ) )
        {
            POSITION pos = _listHtBranch.GetHeadPosition();
            for( pResetStyleRCI = NULL; pos != NULL; )
            {
                CExtRichContentHitTestInfo::ht_item_t & _ht_item = _listHtBranch.GetNext( pos );
                __EXT_DEBUG_RICH_CONTENT_ASSERT( _ht_item.m_pRCI != NULL );
                HWND hWndOwn = m_hWnd;
                bool bOwnWindowVisible_Old = ( ( ( ::__EXT_MFC_GetWindowLong( hWndOwn, GWL_STYLE ) ) & WS_VISIBLE ) != 0 ) ? true : false;
                if( nRepCnt == 0 )
                    _ht_item.m_pRCI->RciEvent_OnClick( nChar, nFlags, m_htInfoPressed, htInfoPressed, m_hWnd );
                else if( nRepCnt == 2 )
                    _ht_item.m_pRCI->RciEvent_OnDoubleClick( nChar, nFlags, m_htInfoPressed, htInfoPressed, m_hWnd );
                if( ! ::IsWindow(hWndOwn) )
                    return true;
                bool bOwnWindowVisible_New = ( ( ( ::__EXT_MFC_GetWindowLong( hWndOwn, GWL_STYLE ) ) & WS_VISIBLE ) != 0 ) ? true : false;
                if( bOwnWindowVisible_Old != bOwnWindowVisible_New )
                    return true;
                if( _ht_item.m_pRCI->HaveAffectedCssPseudoClasses( statesFocusOnly ) )
                {
                    bHaveElementsWithResetStyles = true;
                    pResetStyleRCI = _ht_item.m_pRCI;
                }
            } // for( pResetStyleRCI = NULL; pos != NULL; )
            if( pResetStyleRCI != NULL )
                OnRcsResetElementStyle( pResetStyleRCI );

            if(  pRCI_next_focus != NULL && LPVOID(pRCI_next_focus) != LPVOID(m_pRCI_focus) )
            {
                bHaveElementsWithResetStyles = true;

#if (defined __EXT_RCS_WND_APPLY_HOVER_RESET_WORKAROUND__)
                // BEGIN // temporarily solution, reset hovered state to avoid incorrect inheritance from parent element inside OnRcsResetElementStates()
                if( ! m_htInfoHover.IsEmpty() )
                {
                    m_htInfoHover.Empty();
                    CExtRichStyleDescription::pseudo_class_def_t statesHoverOnly;
                    statesHoverOnly.m_eynHover = CExtRichStyleDescription::e_ui_yn_yes;
                    OnRcsResetElementStates( pRootRCI, statesHoverOnly, CExtRichStyleDescription::e_ui_yn_unspecified );
                }
                //  END  // temporarily solution, reset hovered state to avoid incorrect inheritance from parent element inside OnRcsResetElementStates()
#endif // (defined __EXT_RCS_WND_APPLY_HOVER_RESET_WORKAROUND__)

                CExtRichContentItem * pOldFocusRCI = m_pRCI_focus;
                if( m_pRCI_focus != NULL )
                {
                    m_pRCI_focus->RciEvent_OnFocusLeave( m_hWnd, pRCI_next_focus );
                    if( OnRcsResetElementStates( m_pRCI_focus, statesFocusOnly, CExtRichStyleDescription::e_ui_yn_unspecified ) )
                        bHaveElementsWithResetStyles = true;
                }
                m_pRCI_focus = pRCI_next_focus;
                m_pRCI_focus->RciEvent_OnFocusEnter( m_hWnd, pOldFocusRCI );
                OnSwInvalidate( m_bRedrawErase );
                if( OnRcsResetElementStates( m_pRCI_focus, statesFocusOnly, CExtRichStyleDescription::e_ui_yn_yes ) )
                    bHaveElementsWithResetStyles = true;
                bRecalcPassed = true;
                if( ! bQuickReStyleMode )
                {
                    RcsDelayRecalcLayout();
                    OnSwRecalcLayout( true );
                }
            } // if( pRCI_next_focus != NULL && LPVOID(pRCI_next_focus) != LPVOID(m_pRCI_focus) )
        } // if( m_nVkPressed == nChar && pRCI_LastSupportingPressed != NULL && pRCI_LastSupportingPressed->CalcEffectiveRect().PtInRect( point ) )
        OnRcsAnalyzeMouseMoveEvent( nFlags, point );
    } // if( nRepCnt == 0 || nRepCnt == 2 )
    else if( nRepCnt == 1 )
    {
        if( ! bHaveElementsWithResetStyles )
            return true;
        bRecalc = true;
        m_bPressedTracking = true;
        m_nVkPressed = nChar;
        m_htInfoPressed = htInfoPressed;
        if( htInfoPressed.IsEmpty() )
        {
            if( ::GetCapture() == m_hWnd )
                ::ReleaseCapture();
        }
        else
        {
            if( ::GetCapture() != m_hWnd )
                ::SetCapture( m_hWnd );
        }
    } // else if( nRepCnt == 1 )

    if( bRecalc )
    {
        if( ! bQuickReStyleMode )
        {
            if( ! bRecalcPassed )
            {
                RcsDelayRecalcLayout();
                OnSwRecalcLayout( true );
            }
            OnSwUpdateScrollBars();
        }
        OnSwInvalidate( m_bRedrawErase );
    }

    return true;
}

Wilhelm Falkner May 23, 2012 - 12:36 PM

It now working


Many tanks for Your support


Willi

Wilhelm Falkner May 16, 2012 - 3:49 AM

In OnCmdMsg of my MainFrame I call for some Commands, invoked by BSV, the sequence:


    if ( ((nID    == ID_FILE_OPEN)            ||

          (nID    == ID_FILE_PRINT)            ||

          (nID    == ID_FILE_PRINT_PREVIEW)    ||                                    //    Print page preview

          ((nID    >= ID_FILE_MRU_FILE1) && (nID    <= ID_FILE_MRU_FILE16)) ||        //    Recent File open

          ((nID    >= ID_BV_OPEN_ALL_TYPES) && (nID    <= ID_BV_OPEN_EXTRA_LAST))    ||        //    Open special Type of file

          ((nID    >= ID_BV_NEW_DOC_00) && (nID    <= (ID_BV_NEW_DOC_00 + (UINT)theApp.m_pSaveValues->m_templateListNew.GetCount() + 1)))        //    Create New

         )

        && (nCode == CN_COMMAND) && (pExtra == NULL) ) {

        if (m_wndRibbonBar.BackstageView_IsVisible()) {

            m_wndRibbonBar.BackstageView_EnsureHidden();

        }


But the crash happend also, if I don’t call it. It also happens, if I close the BSV by clicking with the mouse

Technical Support May 16, 2012 - 3:00 AM

You wrote "It crash, if I make the BSV invisable". Which code did you invoke for that and where?