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 » Timer __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER causes the WinAPP ::OnIdle to loop. Collapse All
Subject Author Date
Christan HIRIGOYEN Jan 10, 2008 - 4:49 AM

The timer __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER (#9950) causes the WinAPP ::OnIdle to loop permanently even if you don’t move the mouse.
It is not normal, it consumes unneeded CPU time.

You can reproduce this problem with the MDI sample. Just override the WinAPP::OnIdle with those lines.
BOOL CMDIApp::OnIdle(LONG lCount)
{
    static int foo=0;
    TRACE("%d OnIdle(%d)\n", foo++, lCount);
    return CWinApp::OnIdle(lCount);
}
Launch program. The trace is done only if you move the mouse in the drawing area.
If you go over the toolbar, the trace becomes permanent, without any mouse move.

Is it a bug?
Or is it a wanted implementation?

In my case I do some Application Task in the OnIde, lCount is never increased and each 100 milliseconds an UpdateDialogControls (..) appears. (This can take a while if you have a lot of visible toolbar, controlbar…)

Is it a bug?

Technical Support Jan 10, 2008 - 9:11 AM

Thank you for reporting this issue. We noticed the timer is not killed in in several particular situations. Please update the source code for the following method:

void CExtToolControlBar::OnTimer(__EXT_MFC_UINT_PTR nIDEvent) 
{
      switch( nIDEvent )
      {
            case __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER:
            {
                  bool bStateClear = false;
                  INT nIndex, nCount = GetButtonsCount();
                  for( nIndex = 0; nIndex < nCount; nIndex ++ )
                  {
                        CExtBarButton * pTBB = GetButton( nIndex );
                        ASSERT_VALID( pTBB );
                        if(         ( ! pTBB->IsVisible() )
                              ||    ( pTBB->GetStyle() & TBBS_HIDDEN ) != 0
                              )
                              continue;
                        bool bHover = pTBB->IsHover();
                        if( bHover && m_nBtnIdxHover != nIndex )
                        {
                              pTBB->SetHover( false );
                              _InvalidateButton( nIndex );
                              bStateClear = true;
                              break;
                        }
                  }
                  if( bStateClear )
                  {
                        KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
                        return;
                  }
                  bool bActiveHover =
                        (     ( m_nBtnIdxHover >= 0 )
                        ||    CExtPopupMenuWnd::TestHoverEnabledFromActiveHWND( m_hWnd )
                        ) ? true : false;
                  if( bActiveHover )
                  {
                        CPoint point;
                        if( ::GetCursorPos( &point ) )
                        {
                              if( ::WindowFromPoint( point ) != m_hWnd )
                                    bActiveHover = false;
                        }
                        else
                              bActiveHover = false;
                  }
                  if(         bActiveHover
                        &&    m_pDockSite->GetSafeHwnd() != NULL
                        &&    ( ! m_pDockSite->IsWindowEnabled() )
                        )
                        bActiveHover = false;
                  if( ! bActiveHover )
                  {
                        _UpdateHoverButton( CPoint(32767,32767), false );
                        KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
                        CExtPopupMenuTipWnd * pATTW =
                              OnAdvancedPopupMenuTipWndGet();
                        if( pATTW != NULL )
                              pATTW->Hide();
                        CWnd::CancelToolTips();
                  }
                  else
                  {
                        if( m_nBtnIdxHover >= 0 )
                        {
                              CPoint pt;
                              if( ::GetCursorPos( &pt ) )
                              {
                                    ScreenToClient( &pt );
                                    INT nHT = HitTest( pt );
                                    if( nHT != m_nBtnIdxHover )
                                    {
                                          KillTimer( __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER );
                                          if( ! CExtPopupMenuWnd::IsMenuTracking() )
                                                _UpdateHoverButton( pt, false );
                                    }
                              }
                        }
                  }
            }
            return; // case __EXT_MFC_ID_TOOLBAR_HOVER_PROTECTION_TIMER
      } // switch( nIDEvent )
      CExtControlBar::OnTimer(nIDEvent);
}