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 » CExtControlBar and hide/show event Collapse All
Subject Author Date
Sergio Buonanno Jan 23, 2009 - 3:01 AM

Is there any event to inform when a CExtControlBar is hiding or showing (autohide set) ?

Sergio Buonanno Jan 26, 2009 - 6:19 AM

It doesn’t work, OnControlBarPositionChange is not called every time the user displays the control bar, so it’s useless for me. I need an event fired every time the user moves the mouse pointer on the collapsed (hidden) bar to show it. Before the bar is displayed I need to be notified in order to do some initialization tasks.

Sergio Buonanno Jan 26, 2009 - 6:19 AM

It doesn’t work, OnControlBarPositionChange is not called every time the user displays the control bar, so it’s useless for me. I need an event fired every time the user moves the mouse pointer on the collapsed (hidden) bar to show it. Before the bar is displayed I need to be notified in order to do some initialization tasks.

Sergio Buonanno Jan 26, 2009 - 6:19 AM

It doesn’t work, OnControlBarPositionChange is not called every time the user displays the control bar, so it’s useless for me. I need an event fired every time the user moves the mouse pointer on the collapsed (hidden) bar to show it. Before the bar is displayed I need to be notified in order to do some initialization tasks.

Technical Support Jan 23, 2009 - 12:44 PM

First of all, the CControlBar::IsVisible() method should be used for detecting visibility of any MFC/Prof-UIS control bar. You should override the CExtControlBar::OnControlBarPositionChange() virtual method to track position changing events of docked or floating control bar. The CExtControlBar::AutoHideModeSet() method is virtual and it’s used by Prof-UIS for switching control bar into auto-hidden state and back to docked state.

Sergio Buonanno Jan 26, 2009 - 6:12 AM

It doesn’t work, OnControlBarPositionChange is not called every time the user displays the control bar, so it’s useless for me. I need an event fired every time the user moves the mouse pointer on the collapsed (hidden) bar to show it. Before the bar is displayed I need to be notified in order to do some initialization tasks.

Technical Support Jan 26, 2009 - 12:04 PM

We are sorry, but we forgot to mention that you should update the source code for the following method first:

LRESULT CExtControlBar::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
            switch( message )
            {
            case WM_NCMOUSEMOVE:
                        {
                                    if( ! OnQueryBarHoverProcessingEnabled() )
                                                return 0;
                                    CExtPopupMenuTipWnd * pATTW = OnAdvancedPopupMenuTipWndGet();
                                    if( pATTW == NULL )
                                                return 0;
                                    CPoint ptScreen;
                                    if( ! ::GetCursorPos(&ptScreen) )
                                                return 0;
                                    CExtBarNcAreaButton * pBtn = NULL;
                                    NcButtons_HitTest( ptScreen, &pBtn );
                                    if( pBtn != NULL )
                                    {
                                                ASSERT_VALID( pBtn );
                                                TOOLINFO _ti;
                                                ::memset( &_ti, 0, sizeof(AFX_OLDTOOLINFO) );
                                                _ti.cbSize = sizeof( TOOLINFO );
                                                _ti.hinst = ::AfxGetInstanceHandle();
                                                if( pBtn->OnToolHitTest( ptScreen, &_ti ) > 0 )
                                                {
                                                            if( _ti.lpszText != NULL && _ti.lpszText != LPSTR_TEXTCALLBACK && _tcslen( _ti.lpszText ) > 0 )
                                                            {
                                                                        CRect rcArea = *pBtn;
                                                                        CRect rcDefOffsetWnd;
                                                                        GetWindowRect( &rcDefOffsetWnd );
                                                                        rcArea.OffsetRect( rcDefOffsetWnd.TopLeft() );
                                                                        OnAdvancedPopupMenuTipWndDisplay( *pATTW, rcArea, _ti.lpszText );
                                                            }
                                                }
                                                if( _ti.lpszText != NULL && _ti.lpszText != LPSTR_TEXTCALLBACK )
                                                            ::free( _ti.lpszText );
                                    }
                        }
                        break;
            case WM_PRINT:
            case WM_PRINTCLIENT:
                        {
                                    CDC * pDC = CDC::FromHandle( (HDC) wParam );
                                    CRect rcRgnWnd, rcRgnClient;
                                    GetWindowRect( &rcRgnWnd );
                                    GetClientRect( &rcRgnClient );
                                    if( IsFloating() )
                                    {
                                                CRect rcFloatClient;
                                                GetParentFrame()->GetClientRect( &rcFloatClient );
                                                if( rcRgnClient.Width() > rcFloatClient.Width() )
                                                            rcRgnClient.right = rcRgnClient.left + rcFloatClient.Width();
                                                if( rcRgnClient.Height() > rcFloatClient.Height() )
                                                            rcRgnClient.bottom = rcRgnClient.top + rcFloatClient.Height();
                                    }
                                    if( (lParam&PRF_NONCLIENT) != 0 )
                                    {
                                                CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
                                                ClientToScreen( &rcClient );
                                                rcClient.OffsetRect( -rcWnd.TopLeft() );
                                                rcWnd.OffsetRect( -rcWnd.TopLeft() );
                                                CRgn rgnWnd;
                                                if( rgnWnd.CreateRectRgnIndirect(&rcWnd) )
                                                            pDC->SelectClipRgn( &rgnWnd );
                                                pDC->ExcludeClipRect( &rcClient );
                                                DoPaintNC( pDC );
                                                pDC->SelectClipRgn( NULL );
                                    }
                                    if( (lParam&(PRF_CLIENT|PRF_ERASEBKGND)) != 0 )
                                    {
                                                CPoint ptVpOffset( 0, 0 );
                                                if( (lParam&PRF_NONCLIENT) != 0 )
                                                {
                                                            CRect rcWnd = rcRgnWnd, rcClient = rcRgnClient;
                                                            ClientToScreen( &rcClient );
                                                            ptVpOffset.x = rcWnd.left - rcClient.left;
                                                            ptVpOffset.y = rcWnd.top - rcClient.top;
                                                }
                                                if( ptVpOffset.x != 0 || ptVpOffset.y != 0 )
                                                            pDC->OffsetViewportOrg( -ptVpOffset.x, -ptVpOffset.y );
                                                CDC dcSurface;
                                                CBitmap bmpSurface;
                                                CWindowDC dcDesktop( NULL );
                                                if(                     dcSurface.CreateCompatibleDC( NULL )
                                                            &&        bmpSurface.CreateCompatibleBitmap( &dcDesktop, rcRgnClient.Width(), rcRgnClient.Height() )
                                                            )
                                                {
                                                            CBitmap * pOldBmp = dcSurface.SelectObject( &bmpSurface );
                                                            DoEraseBk( &dcSurface );
                                                            DoPaint( &dcSurface );
                                                            pDC->BitBlt( 0, 0, rcRgnClient.Width(), rcRgnClient.Height(), &dcSurface, 0, 0, SRCCOPY );
                                                            dcSurface.SelectObject( pOldBmp );
                                                }
                                                if( ptVpOffset.x != 0 || ptVpOffset.y != 0 )
                                                            pDC->OffsetViewportOrg( ptVpOffset.x, ptVpOffset.y );
                                    }
                                    if( (lParam&PRF_CHILDREN) != 0 )
                                                CExtPaintManager::stat_PrintChildren( m_hWnd, message, pDC->GetSafeHdc(), lParam, false );
                        }
                        return (!0);
            case WM_TIMER:
                                    if( wParam == __TIMER_ID_DRELAYED_REPAINT_FAKE )
                                    {
                                                RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ERASENOW|RDW_ALLCHILDREN|RDW_FRAME );
                                                KillTimer( __TIMER_ID_DRELAYED_REPAINT_FAKE );
                                                return    0L;
                                    }
                                    if( AnimationSite_OnHookTimer( UINT(wParam) ) )
                                                return 0L;
                        break;
            case WM_CLOSE:
                        m_bInCustomModeUpdateCmdUI = true;
                        return 0;
            case WM_DESTROY:
                        AnimationSite_ClientRemove();
#if (_MFC_VER >= 0x700) && (_MFC_VER <= 0x710)
                        if( m_pDockSite != NULL && m_pDockSite->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) ) )
                        {
                                    CFrameWnd * pFrame = GetParentFrame();
                                    if( pFrame != m_pDockSite )
                                                m_bHelperSuppressDestruction = true;
                        }
#endif
                        m_bInCustomModeUpdateCmdUI = true;
                        break;
            case WM_NCDESTROY:
                        AnimationSite_ClientRemove();
                        if( m_pDockContext != NULL )
                        {
                                    m_pDockBar = NULL;
                                    delete m_pDockContext;
                                    m_pDockContext = NULL;
                        }
                        m_bInCustomModeUpdateCmdUI = true;
                        NcButtons_RemoveAll();
                        break;
            case WM_SETFOCUS:
                        {
                                    LRESULT lResult = CControlBar::WindowProc(message, wParam, lParam);
                                    if( IsMinimizedOnRow() )
                                                MaximizeOnRow();
                                    if( ! IsFixedMode() )
                                    {
                                                CWnd * pWnd = GetWindow(GW_CHILD);
                                                if( pWnd != NULL && stat_QueryFocusChangingEnabled( this, pWnd->m_hWnd ) )
                                                            pWnd->SetFocus();
                                    }
                                    return lResult;
                        }
            case WM_ERASEBKGND:
                        if( ! m_bDoNotEraseClientBackground )
                                    return !0;
                        CExtPaintManager::stat_ExcludeChildAreas( (HDC)wParam, *this );
                        return CControlBar::WindowProc(message, wParam, lParam);
            case WM_CREATE:
                        {
                                    if( ( ! m_bPresubclassDialogMode ) && ( ! IsFixedMode() ) )
                                    {
                                                ASSERT( GetSafeHwnd() != NULL );
                                                ASSERT( ::IsWindow(GetSafeHwnd()) );
                                                HWND hWndParent = ::GetParent( GetSafeHwnd() );
                                                CFrameWnd * pFrame = NULL;
                                                do
                                                {
                                                            ASSERT( hWndParent != NULL );
                                                            ASSERT( ::IsWindow(hWndParent) );
                                                            CWnd * pWnd = CWnd::FromHandle( hWndParent );
                                                            if( pWnd->IsKindOf(RUNTIME_CLASS(CFrameWnd)) )
                                                            {
                                                                        pFrame = (CFrameWnd *)pWnd;
                                                                        break;
                                                            }
                                                } while( pFrame == NULL );
                                                ASSERT( pFrame != NULL );
                                                ASSERT_VALID( pFrame );
                                                if( pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) )
                                                {
                                                            pFrame = pFrame->GetParentFrame();
                                                            ASSERT( pFrame != NULL );
                                                            ASSERT_VALID( pFrame );
                                                            ASSERT( !pFrame->IsKindOf(RUNTIME_CLASS(CMiniFrameWnd)) );
                                                }
                                                VERIFY( _FrameEnableDockingImpl( pFrame ) );
                                    }
                        }
                        break;
            case WM_SHOWWINDOW:
            case WM_SIZE:
                                    m_bDelelayRepaintNcButtons = true;
                                    OnControlBarPositionChange( this, __ECBPC_MUTUAL_DEPENDENCY, true, true );
                        break;
            case WM_WINDOWPOSCHANGED:
                        {
                                    CExtPopupMenuTipWnd * pATTW = OnAdvancedPopupMenuTipWndGet();
                                    if( pATTW != NULL )
                                                pATTW->Hide();
#if (!defined __EXT_MFC_NO_CUSTOMIZE)
                                    CExtCustomizeSite * pSite = NotifiedCustomizeSiteGet();
                                    if( pSite != NULL )
                                                pSite->OnBarStateChanged( this );
#endif
                                    if( m_pDockBar == NULL && (!m_bPresubclassDialogMode) )
                                                break;
                                    LPWINDOWPOS lpWindowPos = reinterpret_cast < LPWINDOWPOS > (lParam);
                                    ASSERT( lpWindowPos != NULL );
                                    if( ! IsFixedMode() )
                                                _UpdateVisibilityInChain();
                                    CExtControlBar * pBar = this;
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
                                    CExtDynTabControlBar * pTabBar = _GetNearestTabbedContainer();
                                    if( pTabBar != NULL && pTabBar != this )
                                                pBar = pTabBar;
#endif
                                    pBar->m_bDelelayRepaintNcButtons = true;
                                    pBar->PostMessage( WM_NCPAINT );
                                    if( (lpWindowPos->flags & SWP_FRAMECHANGED) == 0 )
                                                _RecalcNcArea();
                                    OnControlBarPositionChange( this, __ECBPC_MUTUAL_DEPENDENCY, true, true );
                                    break;
                        }
            case WM_WINDOWPOSCHANGING:
                        {
                                    m_bDelelayRepaintNcButtons = true;
                                    if( m_pDockBar == NULL && (!m_bPresubclassDialogMode) )
                                                break;
                                    LPWINDOWPOS lpWindowPos = reinterpret_cast < LPWINDOWPOS > (lParam);
                                    ASSERT( lpWindowPos != NULL );
                                    lpWindowPos->flags |= SWP_FRAMECHANGED;
                                    break;
                        }
            case WM_SETTEXT:
                        {
                                    m_bDelelayRepaintNcButtons = true;
                                    LRESULT lResult = CControlBar::WindowProc(message, wParam, lParam);
                                    if( (! IsFixedMode() ) && (! IsKindOf( RUNTIME_CLASS(CExtDynControlBar) ) ) )
                                    {
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
                                                if( AutoHideModeGet() )
                                                {
                                                            CExtDynAutoHideArea * pTabs = CExtDynAutoHideArea::stat_FindAreaOfBar( this );
                                                            if( pTabs != NULL )
                                                            {
                                                                        ASSERT_VALID( pTabs );
                                                                        pTabs->UpdateTabWnd();
                                                                        CExtDynAutoHideSlider * pAutoHideSlider = pTabs->GetAutoHideSlider();
                                                                        if(                     pAutoHideSlider->GetSafeHwnd() != NULL
                                                                                    &&        (pAutoHideSlider->GetStyle()&WS_VISIBLE) != 0
                                                                                    )
                                                                                    pAutoHideSlider->SendMessage( WM_NCPAINT );
                                                            }
                                                }
                                                else
#endif
                                                            if( IsVisible() )
                                                {
#if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
                                                            CWnd * pWnd = GetParent();
                                                            bool bRecalcThisNcArea = true;
                                                            if(                     pWnd != NULL
                                                                        &&        pWnd->IsKindOf( RUNTIME_CLASS(CExtDockDynTabBar) )
                                                                        )
                                                            {
                                                                        ASSERT_VALID( pWnd );
                                                                        pWnd = pWnd->GetParent();
                                                                        ASSERT_VALID( pWnd );
                                                                        CExtDynTabControlBar * pTabBar = DYNAMIC_DOWNCAST( CExtDynTabControlBar, pWnd );
                                                                        if( pTabBar != NULL )
                                                                        {
                                                                                    pTabBar->InvalidateSwitcher();
                                                                                    CFrameWnd * pFrame = pTabBar->GetParentFrame();
                                                                                    ASSERT_VALID( pFrame );
                                                                                    pFrame->DelayRecalcLayout();
                                                                                    pFrame->PostMessage( WM_NULL );
                                                                                    LONG nSelIdx = pTabBar->GetSwitcherSelection();
                                                                                    if( nSelIdx >= 0 )
                                                                                    {
                                                                                                CExtControlBar * pBarTest = pTabBar->GetBarAt( nSelIdx, true );
                                                                                                if( pBarTest == this )
                                                                                                {
                                                                                                            CString strText;
                                                                                                            GetWindowText( strText );
                                                                                                            pTabBar->SetWindowText( strText );
                                                                                                }
                                                                                    }
                                                                                    ((CExtControlBar*)pTabBar)->_RecalcNcArea();
                                                                                    bRecalcThisNcArea = false;
                                                                        }
                                                            }
                                                            if( bRecalcThisNcArea )
#endif
                                                                        _RecalcNcArea();
                                                }
                                    }
                                    return lResult;
                        }
            }
            return CControlBar::WindowProc( message, wParam, lParam );
}
The control bar in the auto hidden mode is really the hidden control bar which is marked as auto hidden. When the mouse pointer is moved over the tab item corresponding to the auto-hidden bar, the bar’s window is temporarily moved into the CExtDynAutoHideSlider window displayed from tabs area with sliding animation. This event should be handled as position changing (WM_WINDOWPOSCHANGED) of bar’s child window.