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 » Tooltip flickers heavily Collapse All
Subject Author Date
Offer Har Aug 14, 2011 - 6:44 AM

Dear Support,


I added a tooltip to a CExtEdit derived class.


When I hover over the edit box the tooltip appears. then, if I move the mouse inside the edit box, each move generates flicker in the tooltip. If I move the mouse fast, the flickering is very annoying.


Please fix.


Thanks,


Ron.

Technical Support Aug 15, 2011 - 7:30 AM

You need to use your tooltip window only if you created your tooltip class and modified its behavior.

Offer Har Aug 17, 2011 - 12:34 AM

As I explained, the problem is SetIcon that causes redraws which causes flickers:


1) Why isn’t the drawing of the tooltip double-buffers to reduce flicker?


2) Why does the SetIcon causes redraw while other setters functions do not?

Technical Support Aug 18, 2011 - 2:11 AM

Prof-UIS always use the CExtPopupMenuTipWnd as a styled replacement of a classic tooltip. Classic tooltips never change on the fly. But, of course, we can implement double buffered painting to avoid flicker when your app invokes the CExtPopupMenuTipWnd::SetIcon() API. Please update the source code for the following method:

void CExtPopupMenuTipWnd::_DoPaint(
    CDC & dcPaint,
    bool bUseBackBuffer //= true
    )
{
    bUseBackBuffer;
CRect rcLayout;
    GetClientRect( &rcLayout );
CExtMemoryDC dc( &dcPaint, &rcLayout );
HRGN hRegion = CreateRectRgnIndirect( &rcLayout );
    GetWindowRgn( hRegion );
CRgn * pRegion = CRgn::FromHandle( hRegion );

CExtPaintManager * pPM = PmBridge_GetPM();
    ASSERT_VALID( pPM );
CFont * pAdvTipFont = &m_fontAdvTip;
    if( pAdvTipFont->GetSafeHandle() == NULL )
        pAdvTipFont = pPM->AdvTip_GetFont( this );
    if( pAdvTipFont->GetSafeHandle() == NULL )
        pAdvTipFont = &(pPM->m_FontNormal);
COLORREF clrAdvTipText = pPM->AdvTip_GetTextColor( this );
    if( clrAdvTipText == COLORREF(-1L) )
        clrAdvTipText = pPM->GetColor( COLOR_INFOTEXT, this );
e_tip_style_t eTS = GetTipStyle();
    switch( eTS )
    {
    case __ETS_BALLOON:
    case __ETS_BALLOON_NO_ICON:
    {
        CBrush brushWindow;
        brushWindow.CreateSolidBrush(
            //pPM->GetColor( COLOR_INFOBK, this )
            ::GetSysColor( COLOR_INFOBK )
            );
        CBrush brushFrame;
        brushFrame.CreateSolidBrush(
            //pPM->GetColor( COLOR_3DDKSHADOW, this )
            ::GetSysColor( COLOR_3DDKSHADOW )
            );
        CBrush brushInnerFrame;
        brushInnerFrame.CreateSolidBrush(
            //pPM->GetColor( COLOR_3DFACE, this)
            ::GetSysColor( COLOR_3DFACE )
            );
        // frame
        dc.FillRgn( pRegion, &brushWindow );
        dc.FrameRgn( pRegion, &brushInnerFrame, 3, 3 );
        dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
        // adjust icon’s area
        rcLayout.DeflateRect( m_sizeRounders.cx, m_sizeRounders.cy, 0, 0 );
        if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
            rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
        CFont * pOldFont = dc.SelectObject( pAdvTipFont );
        int nOldBkMode = dc.SetBkMode( TRANSPARENT );
        int nIconVertPos = m_sizeRounders.cy;
        if( m_bFlipVert )
        {
            rcLayout.OffsetRect( 0, m_sizeLeader.cy );
            nIconVertPos += m_sizeLeader.cy;
        }
        COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
        CExtRichContentLayout::stat_DrawText(
            dc.m_hDC,
            LPCTSTR(m_sText), m_sText.GetLength(),
            &rcLayout,
            DT_TOP|DT_LEFT, 0
            );
        dc.SetBkMode( nOldBkMode );
        dc.SetTextColor( clrOldTextColor );
        dc.SelectObject( pOldFont );
        // icon
        if( eTS != __ETS_BALLOON_NO_ICON && (! m_icon.IsEmpty() ) )
        {
            m_icon.Paint(
                pPM,
                dc.GetSafeHdc(),
                 m_sizeRounders.cx,
                 nIconVertPos,
                 m_sizeRenderingIcon.cx,
                 m_sizeRenderingIcon.cy
                );
        }
    } // cases __ETS_BALLOON, __ETS_BALLOON_NO_ICON
    break;
    case __ETS_RECTANGLE:
    case __ETS_RECTANGLE_NO_ICON:
    case __ETS_INV_RECTANGLE:
    case __ETS_INV_RECTANGLE_NO_ICON:
    {
        int nSizeShadow = CalcShadowSize();
        ASSERT( nSizeShadow >= 0 );
        if( nSizeShadow > 0 )
        {
            rcLayout.DeflateRect( 0, 0, nSizeShadow, nSizeShadow );
            m_shadow.Paint(
                pPM,
                dc,
                rcLayout,
                CRect( 0, 0, 0, 0 ),
                CRect( 0, 0, 0, 0 ),
                nSizeShadow,
                70,
                95
                );
        }

        bool bAdvTipWithShadow =
            (    m_nSizeShadow > 0
            ||    (    m_ctrlShadow.GetSafeHwnd() != NULL
                &&    ( m_ctrlShadow.GetStyle() & WS_VISIBLE ) != 0
                )
            ) ? true : false;
        if(    ! pPM->AdvTip_PaintBackground(
                dc,
                rcLayout,
                bAdvTipWithShadow,
                this
                )
            )
        {
            // frame
            //dc.FillRgn( pRegion, &brushWindow );
            //dc.FrameRgn( pRegion, &brushFrame, 1, 1 );
            dc.FillSolidRect(
                &rcLayout,
                ::GetSysColor( COLOR_INFOBK )
                );
            dc.Draw3dRect(
                &rcLayout,
                pPM->GetColor( COLOR_3DDKSHADOW, this ),
                pPM->GetColor( COLOR_3DDKSHADOW, this )
                );
        }

        // adjust icon’s area
        rcLayout.DeflateRect( m_sizeClassicMargins );
        if(        eTS != __ETS_RECTANGLE_NO_ICON
            &&    eTS != __ETS_INV_RECTANGLE_NO_ICON
            &&    (! m_icon.IsEmpty() )
            )
            rcLayout.left += m_sizeRenderingIcon.cx + m_nIconMarginDX;
        
        CFont * pOldFont = dc.SelectObject( pAdvTipFont );
        int nOldBkMode = dc.SetBkMode( TRANSPARENT );
        COLORREF clrOldTextColor = dc.SetTextColor( clrAdvTipText );
        CExtRichContentLayout::stat_DrawText(
            dc.m_hDC,
            LPCTSTR(m_sText), m_sText.GetLength(),
            &rcLayout,
            DT_TOP|DT_LEFT|DT_VCENTER, 0
            );
        dc.SetBkMode( nOldBkMode );
        dc.SetTextColor( clrOldTextColor );
        dc.SelectObject( pOldFont );

        // icon
        if(        eTS != __ETS_RECTANGLE_NO_ICON
            &&    eTS != __ETS_INV_RECTANGLE_NO_ICON
            &&    (! m_icon.IsEmpty() )
            )
        {
            int nIconHorzPos =
                rcLayout.left
                - m_sizeRenderingIcon.cx
                - m_nIconMarginDX
                ;
            int nIconVertPos =
                rcLayout.top
                + ( rcLayout.Height() - m_sizeRenderingIcon.cy ) / 2
                ;
            m_icon.Paint(
                pPM,
                dc.GetSafeHdc(),
                nIconHorzPos,
                nIconVertPos,
                m_sizeRenderingIcon.cx,
                m_sizeRenderingIcon.cy
                );
        }
    } // rectangle cases
    break;
#ifdef _DEBUG
    default:
        ASSERT( FALSE );
    break;
#endif // _DEBUG
    } // switch( eTS )
    ::DeleteObject( hRegion );
}

Technical Support Aug 14, 2011 - 9:20 AM

This looks like a conflict of two tooltip controls. The CExtEdit class provides tooltip support. You don’t need to code the same in your CExtEdit-derived class

Offer Har Aug 15, 2011 - 4:59 AM

Hi,


I found the problem - it happens because of my implementation of OnAdvancedPopupMenuTipWndDisplay. In this function, I set the icon of the tooltip by calling _ATTW.SetIcon(...). This function at its end calls RedrawWindow.


The problem is that OnAdvancedPopupMenuTipWndDisplay is called in every mouse move, even if I did not leave the control, so it generated a call the redraw the tooltip.


I bypassed it, because I don’t update the icon very often, but I suggest that you’ll look into it.


Thanks,


Ron.

Offer Har Aug 14, 2011 - 11:47 AM

There is no conflict - I just call the built-in CExtEdit functions.