ExtControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:775k
- if( ! ( ::IsWindow( m_hWndMarkerTarget ) ) )
- {
- ShowMarkers( g_arrDockMarkerWndsInner, false, true );
- CExtControlBar * pDraggedBar =
- CExtControlBar::_DraggingGetBar();
- if( pDraggedBar == NULL )
- return;
- ASSERT_VALID( pDraggedBar );
- CPoint ptCursor( 0, 0 );
- ::GetCursorPos( &ptCursor );
- pDraggedBar->ScreenToClient( &ptCursor );
- pDraggedBar->PostMessage(
- WM_MOUSEMOVE,
- CExtPopupMenuWnd::IsKeyPressed(VK_CONTROL) ? (VK_CONTROL) : 0L,
- MAKELPARAM( ptCursor.x, ptCursor.y )
- );
- return;
- } // if( ! ( ::IsWindow( m_hWndMarkerTarget ) ) )
- } // if( m_hWndMarkerTarget != NULL )
- eMouseTrackState_t eMTS = __EMTS_OUT;
- CPoint ptCursor;
- if( ::GetCursorPos( &ptCursor ) )
- {
- HWND hWnd = ::WindowFromPoint( ptCursor );
- if( m_hWnd == hWnd )
- eMTS = __EMTS_HOVER;
- } // if( ::GetCursorPos( &ptCursor ) )
- if( m_eMTS == eMTS )
- return;
- m_eMTS = eMTS;
- if( eMTS != __EMTS_HOVER )
- HighlightMarkerTarget( false );
- //m_hWndLastHoverDepenentMarker = NULL;
- if( (! m_bSparsedMode )
- && m_eMarkerType != int(CExtPaintManager::__EDMT_2005_CENTER)
- )
- {
- CExtDynDockMarkerWnd * pDynDockMarkerWnd =
- stat_FindMarker(
- m_hWndMarkerTarget,
- int(CExtPaintManager::__EDMT_2005_CENTER),
- m_bSparsedMode
- );
- if( pDynDockMarkerWnd->GetSafeHwnd() != NULL )
- {
- if( eMTS == __EMTS_HOVER )
- {
- pDynDockMarkerWnd->m_hWndLastHoverDepenentMarker = m_hWnd;
- pDynDockMarkerWnd->Invalidate();
- pDynDockMarkerWnd->UpdateWindow();
- }
- else if( pDynDockMarkerWnd->m_hWndLastHoverDepenentMarker == m_hWnd )
- {
- pDynDockMarkerWnd->m_hWndLastHoverDepenentMarker = NULL;
- pDynDockMarkerWnd->Invalidate();
- pDynDockMarkerWnd->UpdateWindow();
- }
- }
- } // if( ! m_bSparsedMode ...
- //if( ! IsStateApplyable() )
- // UnHighlightAllMarkers();
- Invalidate();
- UpdateWindow();
- return;
- } // if( nIDEvent == __DYNDOCKMARKER_TIMER_ID_TEMP )
- CWnd::OnTimer(nIDEvent);
- }
- BOOL CExtDynDockMarkerWnd::DestroyWindow()
- {
- HighlightMarkerTarget( false );
- return CWnd::DestroyWindow();
- }
- #endif // (!defined __EXT_MFC_NO_DOCK_MARKERS)
- void CExtControlBar::MsgDrawTrackedAreaData_t::NotifyOrDrawDefault()
- {
- if( ! Notify() )
- DrawDefault();
- }
- bool CExtControlBar::MsgDrawTrackedAreaData_t::Notify()
- {
- ASSERT_VALID( (&m_wndBar) );
- ASSERT(
- m_wndBar.GetSafeHwnd() != NULL
- && ::IsWindow( m_wndBar.GetSafeHwnd() )
- );
- ASSERT( m_dcDraw.GetSafeHdc() != NULL );
- CFrameWnd * pFrame = m_wndBar.GetParentFrame();
- if( pFrame == NULL )
- return false;
- if( pFrame->IsKindOf( RUNTIME_CLASS(CExtMiniDockFrameWnd) ) )
- {
- pFrame = pFrame->GetParentFrame();
- if( pFrame == NULL )
- return false;
- } // if( pFrame->IsKindOf( RUNTIME_CLASS(CExtMiniDockFrameWnd) ) )
- pFrame->SendMessage(
- CExtControlBar::g_nMsgDrawTrackedArea,
- WPARAM( this )
- );
- return m_bMessageHandled;
- }
- void CExtControlBar::MsgDrawTrackedAreaData_t::DrawDefault()
- {
- ASSERT_VALID( (&m_wndBar) );
- ASSERT(
- m_wndBar.GetSafeHwnd() != NULL
- && ::IsWindow( m_wndBar.GetSafeHwnd() )
- );
- ASSERT( m_dcDraw.GetSafeHdc() != NULL );
- HBRUSH hBrush = (HBRUSH) CDC::GetHalftoneBrush()->GetSafeHandle();
- ASSERT( hBrush != NULL );
- Draw( hBrush, PATINVERT );
- }
- void CExtControlBar::MsgDrawTrackedAreaData_t::Draw(
- HBRUSH hBrush,
- DWORD dwPatBltROP // raster operation code for invoking PatBlt()
- )
- {
- ASSERT_VALID( (&m_wndBar) );
- ASSERT(
- m_wndBar.GetSafeHwnd() != NULL
- && ::IsWindow( m_wndBar.GetSafeHwnd() )
- );
- ASSERT( m_dcDraw.GetSafeHdc() != NULL );
- ASSERT( hBrush != NULL );
- HGDIOBJ hBrushOld = m_dcDraw.SelectObject( hBrush );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool bTabShape = false;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- switch( m_eDTAT )
- {
- case __EDTAT_RESIZING_ENTIRE_ROW:
- case __EDTAT_RESIZING_PART_OF_ROW:
- m_dcDraw.PatBlt(
- m_rcDrawArea.left,
- m_rcDrawArea.top,
- m_rcDrawArea.Width(),
- m_rcDrawArea.Height(),
- dwPatBltROP
- );
- break;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- case __EDTAT_TAB_FRAME:
- bTabShape = true;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- case __EDTAT_RECTANGULAR_FRAME:
- {
- INT nTrackerBorderH = ::GetSystemMetrics( SM_CXSIZEFRAME );
- INT nTrackerBorderV = ::GetSystemMetrics( SM_CYSIZEFRAME );
- CRect rcTrackerInner( m_rcDrawArea );
- rcTrackerInner.DeflateRect(
- nTrackerBorderH,
- nTrackerBorderV
- );
- bool bRgnCreated = false;
- CRgn
- rgnPaint,
- rgnInner, rgnOuter,
- rgnTabMainArea,
- rgnTabBottomLeftArea,
- rgnTabBottomMiddleArea,
- rgnTabBottomRightArea;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( bTabShape )
- {
- int nTabHeight = CExtControlBar::g_nTabShapeMaxHeight;
- int nTrackerHeight = m_rcDrawArea.Height();
- if( nTrackerHeight < (CExtControlBar::g_nTabShapeMaxHeight * 2) )
- nTabHeight = nTrackerHeight / 2;
- //if( nTabHeight >= (nTrackerBorderV * 3 + 3) )
- //{
- CRect rcTabMainArea( rcTrackerInner );
- if( CExtControlBar::g_bTabsAtTop )
- rcTabMainArea.top += nTabHeight;
- else
- rcTabMainArea.bottom -= nTabHeight;
- ASSERT( rcTabMainArea.bottom > rcTabMainArea.top );
-
- CRect rcTabBottomLeftArea( m_rcDrawArea );
- rcTabBottomLeftArea.right =
- rcTabBottomLeftArea.left
- + CExtControlBar::g_nTabShapeBottomLeftAreaWidth
- ;
- if( CExtControlBar::g_bTabsAtTop )
- rcTabBottomLeftArea.bottom =
- rcTabBottomLeftArea.top + nTabHeight;
- else
- rcTabBottomLeftArea.top =
- rcTabBottomLeftArea.bottom - nTabHeight;
- CRect rcTabBottomMiddleArea( rcTabBottomLeftArea );
- rcTabBottomMiddleArea.OffsetRect(
- nTrackerBorderH + rcTabBottomLeftArea.Width(),
- CExtControlBar::g_bTabsAtTop ? nTrackerBorderV : (-nTrackerBorderV)
- );
- rcTabBottomMiddleArea.right =
- rcTabBottomMiddleArea.left
- + CExtControlBar::g_nTabShapeBottomMiddleAreaWidth
- ;
- if( rcTabBottomMiddleArea.right > rcTrackerInner.right )
- rcTabBottomMiddleArea.right =
- rcTabBottomMiddleArea.left
- + (rcTrackerInner.right - rcTabBottomMiddleArea.left) / 2
- ;
-
- CRect rcTabBottomRightArea( rcTabBottomLeftArea );
- rcTabBottomRightArea.right = m_rcDrawArea.right;
- rcTabBottomRightArea.left =
- rcTabBottomMiddleArea.right
- + nTrackerBorderH;
- if( m_wndBar.m_pDockSite != NULL )
- {
- ASSERT_VALID( m_wndBar.m_pDockSite );
- ASSERT( m_wndBar.m_pDockSite->GetSafeHwnd() != NULL );
- if( (m_wndBar.m_pDockSite->GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- {
- rcTabBottomRightArea.left =
- rcTabBottomRightArea.right
- - rcTabBottomLeftArea.Width()
- - nTrackerBorderH
- ;
- rcTabBottomMiddleArea.OffsetRect(
- rcTabBottomRightArea.left
- - rcTabBottomMiddleArea.right
- - nTrackerBorderH
- ,
- 0
- );
- rcTabBottomLeftArea.right =
- rcTabBottomMiddleArea.left
- - nTrackerBorderH
- ;
- } // if( (m_wndBar.m_pDockSite->GetExStyle()&WS_EX_LAYOUTRTL) != 0 )
- } // if( m_wndBar.m_pDockSite != NULL )
- if( rgnOuter.CreateRectRgnIndirect(
- &m_rcDrawArea
- )
- && rgnTabMainArea.CreateRectRgnIndirect(
- &rcTabMainArea
- )
- && rgnTabBottomLeftArea.CreateRectRgnIndirect(
- &rcTabBottomLeftArea
- )
- && rgnTabBottomMiddleArea.CreateRectRgnIndirect(
- &rcTabBottomMiddleArea
- )
- && rgnTabBottomRightArea.CreateRectRgnIndirect(
- &rcTabBottomRightArea
- )
- && rgnPaint.CreateRectRgnIndirect(
- &m_rcDrawArea
- )
- )
- { // if regions created successfully
- int nRgnPaintCombineResult =
- rgnTabMainArea.CombineRgn(
- &rgnTabMainArea,
- &rgnTabBottomLeftArea,
- RGN_OR
- );
- if( nRgnPaintCombineResult != ERROR
- && nRgnPaintCombineResult != NULLREGION
- )
- {
- nRgnPaintCombineResult =
- rgnTabMainArea.CombineRgn(
- &rgnTabMainArea,
- &rgnTabBottomMiddleArea,
- RGN_OR
- );
- if( nRgnPaintCombineResult != ERROR
- && nRgnPaintCombineResult != NULLREGION
- )
- {
- nRgnPaintCombineResult =
- rgnTabMainArea.CombineRgn(
- &rgnTabMainArea,
- &rgnTabBottomRightArea,
- RGN_OR
- );
- if( nRgnPaintCombineResult != ERROR
- && nRgnPaintCombineResult != NULLREGION
- )
- {
- nRgnPaintCombineResult =
- rgnPaint.CombineRgn(
- &rgnPaint,
- &rgnTabMainArea,
- RGN_DIFF
- );
- if( nRgnPaintCombineResult != ERROR
- && nRgnPaintCombineResult != NULLREGION
- )
- { // if paint region created successfully & non-empty
- bRgnCreated = true;
- } // if paint region created successfully & non-empty
- }
- }
- }
- } // if regions created successfully
- //} // if( nTabHeight >= (nTrackerBorderV * 3 + 3) )
- } // if( bTabShape )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
-
- if( ! bRgnCreated )
- { // create non-tabbed shape
- if( rgnOuter.CreateRectRgnIndirect(
- &m_rcDrawArea
- )
- && rgnInner.CreateRectRgnIndirect(
- &rcTrackerInner
- )
- && rgnPaint.CreateRectRgn(0,0,0,0)
- )
- { // if regions created successfully
- int nRgnPaintCombineResult =
- rgnPaint.CombineRgn(
- &rgnOuter,
- &rgnInner,
- RGN_DIFF
- );
- if( nRgnPaintCombineResult != ERROR
- && nRgnPaintCombineResult != NULLREGION
- )
- { // if paint region created successfully & non-empty
- bRgnCreated = true;
- } // if paint region created successfully & non-empty
- } // if regions created successfully
- } // create non-tabbed shape
- if( bRgnCreated )
- { // if we have sense to paint pattern
- m_dcDraw.SelectClipRgn( &rgnPaint );
- m_dcDraw.PatBlt(
- m_rcDrawArea.left,
- m_rcDrawArea.top,
- m_rcDrawArea.Width(),
- m_rcDrawArea.Height(),
- dwPatBltROP
- );
- m_dcDraw.SelectClipRgn( NULL );
- } // if we have sense to paint pattern
- }
- break;
- #ifdef _DEBUG
- default:
- {
- ASSERT( FALSE );
- }
- break;
- #endif // _DEBUG
- } // switch( m_eDTAT )
- m_dcDraw.SelectObject( hBrushOld );
- }
- #if (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicBarNcAreaButtonMenu
- IMPLEMENT_DYNCREATE( CExtDynamicBarNcAreaButtonMenu, CExtBarNcAreaButtonMenu );
- CExtDynamicBarNcAreaButtonMenu::CExtDynamicBarNcAreaButtonMenu(
- CExtControlBar * pBar // = NULL
- )
- : CExtBarNcAreaButtonMenu( pBar )
- {
- }
- bool CExtDynamicBarNcAreaButtonMenu::OnQueryVisibility() const
- {
- ASSERT_VALID( this );
- bool bButtonIsVisible = true;
- CExtControlBar * pBar = const_cast < CExtControlBar * > ( GetBar() );
- ASSERT_VALID( pBar );
- if( pBar->NcButtons_HandleQueryVisibility(
- bButtonIsVisible,
- const_cast < CExtDynamicBarNcAreaButtonMenu * > ( this ),
- pBar,
- NULL
- )
- )
- return bButtonIsVisible;
- if( ! pBar->IsKindOf( RUNTIME_CLASS(CExtDynamicControlBar) ) )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynamicTabbedControlBar * pDTB =
- DYNAMIC_DOWNCAST( CExtDynamicTabbedControlBar, pBar );
- if( pDTB == NULL )
- return false;
- LONG nSel = pDTB->GetSwitcherSelection();
- if( nSel < 0 )
- return false;
- CExtControlBar * pSelBar = pDTB->GetBarAt( nSel, true );
- if( pSelBar == NULL )
- return false;
- if( ! pSelBar->IsKindOf( RUNTIME_CLASS(CExtDynamicControlBar) ) )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- return false;
- }
- if( ! pBar->_NcMenuButtonIsEnabled( pBar ) )
- return false;
- if( IsBarFixedMode() )
- return false;
- return true;
- }
- bool CExtDynamicBarNcAreaButtonMenu::OnQueryDeactivateAutohideSlider() const
- {
- ASSERT_VALID( this );
- return false;
- }
- bool CExtDynamicBarNcAreaButtonMenu::OnNcAreaClicked( CPoint point )
- {
- ASSERT_VALID( this );
- m_bHover = m_bPushed = false;
- CExtControlBar * pExtBar = GetBar();
- ASSERT_VALID( pExtBar );
- HWND hWndBar = pExtBar->GetSafeHwnd();
- if( pExtBar->NcButtons_HandleClick( this, point, pExtBar, NULL ) )
- return true;
- ASSERT_VALID( pExtBar );
- CExtDynamicControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- pExtBar
- );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pBar == NULL )
- {
- CExtDynamicTabbedControlBar * pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynamicTabbedControlBar,
- pExtBar
- );
- LONG nSel = pTabbedBar->GetSwitcherSelection();
- if( nSel < 0 )
- {
- if( pTabbedBar->GetSwitcherItemCount() == 0 )
- return true;
- nSel = 0;
- }
- pBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- pTabbedBar->GetBarAt(
- nSel,
- true
- )
- );
- if( pBar == NULL )
- return true;
- } // if( pBar == NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite = pBar->NotifiedCustomizeSiteGet();
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- {
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( CExtControlBar::FindHelpMode( pBar ) )
- {
- return true;
- }
- if( ! m_rc.PtInRect( point ) )
- {
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return false; // continue asking nc-buttons
- }
- //CFrameWnd * pFrame = GetDockingFrame();
- // ASSERT_VALID( pFrame );
- //HWND hWndTrack = pFrame->GetSafeHwnd();
- HWND hWndTrack = pBar->GetSafeHwnd();
- ASSERT(
- hWndTrack != NULL
- && ::IsWindow( hWndTrack )
- );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- pExtBar->GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- if( ! pPopup->CreatePopupMenu( hWndTrack ) )
- {
- ASSERT( FALSE );
- delete pPopup;
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return false;
- }
- CExtControlBar::POPUP_MENU_EVENT_DATA _pmed(
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NCBTNMENU_DYNSTATE,
- pPopup,
- m_pBar,
- CPoint( -1, -1 ),
- WM_NCLBUTTONDOWN,
- this
- );
- if( ! _pmed.NotifyTarget( false ) )
- {
- if( ! pBar->OnInitDbsMenu(
- pPopup,
- hWndTrack,
- this
- )
- )
- {
- ASSERT( FALSE );
- delete pPopup;
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return false;
- }
- } // if( ! _pmed.NotifyTarget( false ) )
- _pmed.NotifyTarget( true );
- if( pPopup->ItemGetCount() == 0 )
- {
- delete pPopup;
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return false;
- }
- CRect rcBarWnd;
- VERIFY( GetBarNcAreaInfo( NULL, &rcBarWnd ) );
- CRect rcBtnScreen( m_rc );
- m_bHover = m_bPushed = true;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pBar->AutoHideModeGet() )
- {
- CExtDynAutoHideArea * pTabs =
- CExtDynAutoHideArea::stat_FindAreaOfBar( pBar );
- if( pTabs == NULL )
- return true;
- CExtDynAutoHideSlider * pSlider =
- pTabs->GetAutoHideSlider();
- ASSERT_VALID( pSlider );
- if( CExtControlBar::stat_QueryFocusChangingEnabled( pBar, pSlider->m_hWnd ) )
- pSlider->SetFocus();
- pSlider->PostMessage( WM_NCPAINT );
- } // if( pBar->AutoHideModeGet() )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- if( CExtControlBar::stat_QueryFocusChangingEnabled( pBar, pBar->m_hWnd ) )
- pBar->SetFocus();
- ((CExtDynamicControlBar *)pBar)->m_bWindowActive = true;
- pBar->PostMessage( WM_NCPAINT );
- HWND hWndBar = pBar->m_hWnd;
- CExtPopupMenuWnd::PassMsgLoop( true );
- if( ! ::IsWindow(hWndBar) )
- return true;
- }
- CExtPaintManager::stat_PassPaintMessages();
- rcBtnScreen.InflateRect( 1, 1 );
- rcBtnScreen.OffsetRect( rcBarWnd.TopLeft() );
- CPoint ptCursor = rcBtnScreen.CenterPoint();
- if( ! pPopup->TrackPopupMenu(
- TPMX_TOPALIGN|TPMX_COMBINE_NONE|TPMX_OWNERDRAW_FIXED,
- ptCursor.x, ptCursor.y,
- &rcBtnScreen,
- this,
- _CbPaintCombinedContent,
- NULL,
- true
- )
- )
- {
- //delete pPopup;
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return false;
- }
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return true;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicBarNcAreaButtonAutoHide
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- IMPLEMENT_DYNCREATE( CExtDynamicBarNcAreaButtonAutoHide, CExtBarNcAreaButtonAutoHide );
- CExtDynamicBarNcAreaButtonAutoHide::CExtDynamicBarNcAreaButtonAutoHide(
- CExtControlBar * pBar // = NULL
- )
- : CExtBarNcAreaButtonAutoHide( pBar )
- {
- }
- bool CExtDynamicBarNcAreaButtonAutoHide::OnNcAreaClicked( CPoint point )
- {
- ASSERT_VALID( this );
- CExtControlBar * pExtBar = GetBar();
- ASSERT_VALID( pExtBar );
- HWND hWndBar = pExtBar->GetSafeHwnd();
- if( pExtBar->NcButtons_HandleClick( this, point, pExtBar, NULL ) )
- return true;
- ASSERT_VALID( pExtBar );
- bool bRetVal = CExtBarNcAreaButtonAutoHide::OnNcAreaClicked( point );
- if( bRetVal )
- {
- m_bHover = m_bPushed = false;
- CExtDynTabControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST(
- CExtDynTabControlBar,
- pExtBar
- );
- if( pTabbedBar == NULL )
- {
- CExtDockDynTabBar * pDynDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockDynTabBar,
- pExtBar->GetParent()
- );
- if( pDynDockBar != NULL )
- {
- pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynTabControlBar,
- pDynDockBar->GetParent()
- );
- } // if( pDynDockBar != NULL )
- } // if( pTabbedBar == NULL )
- if( pTabbedBar != NULL )
- {
- LONG nPos, nCount = pTabbedBar->GetSwitcherItemCount();
- for( nPos = 0; nPos < nCount; nPos++ )
- {
- CExtControlBar * pContainedBar =
- pTabbedBar->GetBarAt( nPos, true );
- CExtDynamicControlBar * pDynamicBar =
- DYNAMIC_DOWNCAST( CExtDynamicControlBar, pContainedBar );
- if( pDynamicBar != NULL )
- {
- if( pDynamicBar->m_eDBS != CExtDynamicControlBar::__EDBS_DOCUMENT )
- pDynamicBar->m_eDBS =
- pDynamicBar->AutoHideModeGet()
- ? CExtDynamicControlBar::__EDBS_AUTO_HIDDEN
- : CExtDynamicControlBar::__EDBS_DOCKED
- ;
- } // if( pDynamicBar != NULL )
- } // for( nPos = 0; nPos < nCount; nPos++ )
- } // if( pTabbedBar != NULL )
- else
- {
- CExtDynamicControlBar * pDynamicBar =
- DYNAMIC_DOWNCAST( CExtDynamicControlBar, pExtBar );
- if( pDynamicBar != NULL )
- pDynamicBar->m_eDBS =
- pDynamicBar->AutoHideModeGet()
- ? CExtDynamicControlBar::__EDBS_AUTO_HIDDEN
- : CExtDynamicControlBar::__EDBS_DOCKED
- ;
- } // else if( pTabbedBar != NULL )
- // ASSERT_VALID( pExtBar->m_pDockBar );
- // CExtDockBar * pExtDockBar =
- // STATIC_DOWNCAST(
- // CExtDockBar,
- // pExtBar->m_pDockBar
- // );
- // CExtDynAutoHideArea * pAutoHideArea =
- // pExtDockBar->_GetAutoHideArea();
- // ASSERT_VALID( pAutoHideArea );
- // CExtDynAutoHideSlider * pAutoHideSlider =
- // pAutoHideArea->GetAutoHideSlider();
- // ASSERT_VALID( pAutoHideSlider );
- // CExtPopupMenuWnd::PassMsgLoop( false );
- // pAutoHideSlider->PostMessage( WM_NCPAINT );
- }
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return bRetVal;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicBarNcAreaButtonClose
- IMPLEMENT_DYNCREATE( CExtDynamicBarNcAreaButtonClose, CExtBarNcAreaButtonClose );
- CExtDynamicBarNcAreaButtonClose::CExtDynamicBarNcAreaButtonClose(
- CExtControlBar * pBar // = NULL
- )
- : CExtBarNcAreaButtonClose( pBar )
- {
- }
- bool CExtDynamicBarNcAreaButtonClose::OnNcAreaClicked( CPoint point )
- {
- ASSERT_VALID( this );
- if( ! m_rc.PtInRect( point ) )
- return false; // continue asking nc-buttons
- m_bHover = m_bPushed = false;
- CExtControlBar * pExtBar = GetBar();
- ASSERT_VALID( pExtBar );
- HWND hWndBar = pExtBar->GetSafeHwnd();
- CExtBarNcAreaButtonClose::OnNcAreaClicked( point );
- if( hWndBar == NULL
- || (! ::IsWindow( hWndBar ) )
- )
- return true;
- if( pExtBar->NcButtons_HandleClick( this, point, pExtBar, NULL ) )
- return true;
- if( hWndBar == NULL
- || (! ::IsWindow( hWndBar ) )
- )
- return true;
- ASSERT_VALID( pExtBar );
- CExtDynamicControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- pExtBar
- );
- if( pBar != NULL )
- pBar->BarStateSet( pBar->BarStateGet(), false );
- if( hWndBar != NULL
- && ::IsWindow( hWndBar )
- )
- pExtBar->NcButtons_PostClick( this, point, pExtBar, NULL );
- return true;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicControlBar
- IMPLEMENT_SERIAL( CExtDynamicControlBar, CExtControlBar, VERSIONABLE_SCHEMA|1 );
- bool CExtDynamicControlBar::g_bInsertToHeadOfTPC = true;
- CExtDynamicControlBar::CExtDynamicControlBar()
- : m_bPersistentBar( false )
- , m_pDBS( NULL )
- , m_eDBS( CExtDynamicControlBar::__EDBS_DOCKED )
- , m_hWndChildCached( NULL )
- , m_nMdiMenuResourceID( 0 )
- , m_nMdiAccelTableResourceID( 0 )
- , m_dwAdditionalStateFlags( CExtDynamicControlBar::__EASF_INIT_VALUE )
- , m_eHelperSwitchingDBS( CExtDynamicControlBar::__EDBS_DOCKED )
- , m_bHelperSwitchingIntoVisibleState( false )
- , m_bInsertToHeadOfTPC( g_bInsertToHeadOfTPC )
- {
- }
- CExtDynamicControlBar::~CExtDynamicControlBar()
- {
- if( m_pDockContext != NULL )
- {
- m_pDockContext->m_pDockSite = NULL;
- delete m_pDockContext;
- m_pDockContext = NULL;
- } // if( m_pDockContext != NULL )
- }
- bool CExtDynamicControlBar::IsPersistentBar() const
- {
- ASSERT_VALID( this );
- return m_bPersistentBar;
- }
- void CExtDynamicControlBar::OnGetBarCaptionText(
- CExtControlBar::e_bar_caption_text_t eBCT,
- CExtSafeString & strCaptionText
- ) const
- {
- ASSERT_VALID( this );
- if( ! m_strCaptionText.IsEmpty() )
- {
- strCaptionText = m_strCaptionText;
- return;
- } // if( ! m_strCaptionText.IsEmpty() )
- CExtControlBar::OnGetBarCaptionText(
- eBCT,
- strCaptionText
- );
- }
- bool CExtDynamicControlBar::NcButtons_HandleClick(
- CExtBarNcAreaButton * pNcAreaButton,
- CPoint point,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pNcAreaButton );
- }
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pBarEventSource );
- }
- #endif // _DEBUG
- return
- CExtControlBar::NcButtons_HandleClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- void CExtDynamicControlBar::NcButtons_PostClick(
- CExtBarNcAreaButton * pNcAreaButton,
- CPoint point,
- CExtControlBar * pBarEventSource,
- CExtControlBar * pBarActiveInContainer
- )
- {
- ASSERT_VALID( this );
- #ifdef _DEBUG
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pNcAreaButton );
- }
- if( pBarEventSource != NULL )
- {
- ASSERT_VALID( pBarEventSource );
- }
- #endif // _DEBUG
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( (! IsCloseOnlyOneBarInTabGroup() )
- && pNcAreaButton->IsKindOf( RUNTIME_CLASS(CExtBarNcAreaButtonClose) )
- )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- bool bIsVisible = false;
- CExtDynamicControlBar::eDynamicBarState_t eDBS =
- BarStateGet( &bIsVisible );
- if( bIsVisible
- && ( eDBS == CExtDynamicControlBar::__EDBS_DOCKED
- || eDBS == CExtDynamicControlBar::__EDBS_FLOATING
- )
- )
- BarStateSet( eDBS, false );
- }// if( pNcAreaButton->IsKindOf( RUNTIME_CLASS(CExtBarNcAreaButtonClose) ) )
- CExtControlBar::NcButtons_PostClick(
- pNcAreaButton,
- point,
- pBarEventSource,
- pBarActiveInContainer
- );
- }
- CExtDynamicBarSite * CExtDynamicControlBar::GetBarSite()
- {
- ASSERT_VALID( this );
- if( m_pDBS == NULL )
- m_pDBS = CExtDynamicBarSite::FindBarSite( this );
- return m_pDBS;
- }
- void CExtDynamicControlBar::PostNcDestroy()
- {
- ASSERT_VALID( this );
- delete this;
- }
- void CExtDynamicControlBar::OnNcAreaButtonsReinitialize()
- {
- ASSERT_VALID( this );
- INT nCountOfNcButtons = NcButtons_GetCount();
- if( nCountOfNcButtons > 0 )
- return;
- NcButtons_Add( new CExtDynamicBarNcAreaButtonClose(this) );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- NcButtons_Add( new CExtDynamicBarNcAreaButtonAutoHide(this) );
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- NcButtons_Add( new CExtDynamicBarNcAreaButtonMenu(this) );
- }
- LRESULT CExtDynamicControlBar::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
- {
- switch( message )
- {
- case WM_DESTROY:
- {
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS != NULL ) // shutdown mode issue
- pDBS->_BarFreeImpl( this, true, false );
- return 0;
- }
- break; // case WM_DESTROY
- case WM_COMMAND:
- {
- UINT nCmdID = (UINT)wParam;
- switch( nCmdID )
- {
- case ID_EXT_DYN_BAR_FLOATING:
- BarStateSet( __EDBS_FLOATING, true );
- break;
- case ID_EXT_DYN_BAR_DOCKABLE:
- BarStateSet( __EDBS_DOCKED, true );
- break;
- case ID_EXT_DYN_BAR_TABBED_DOCUMENT:
- case ID_EXT_DYN_BAR_MDI_DOCUMENT:
- BarStateSet( __EDBS_DOCUMENT, true );
- break;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- case ID_EXT_DYN_BAR_AUTO_HIDE:
- BarStateSet( __EDBS_AUTO_HIDDEN, true );
- break;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- case ID_EXT_DYN_BAR_HIDE:
- BarStateSet( BarStateGet(), false );
- break;
- default:
- return CExtControlBar::WindowProc( message, wParam, lParam );
- } // switch( nCmdID )
- return 0;
- }
- break; // case WM_COMMAND
- case WM_SHOWWINDOW:
- case WM_SIZE:
- case WM_WINDOWPOSCHANGED:
- {
- if( m_pDockSite == NULL
- || (! ProfileBarStateIsSerializing( m_pDockSite ) )
- )
- {
- if( IsVisible() )
- {
- m_dwAdditionalStateFlags &= ~__EASF_INVISIBLE;
- }
- else
- {
- eDynamicBarState_t eDBS = BarStateGet();
- if( eDBS == __EDBS_FLOATING || eDBS == __EDBS_DOCKED )
- m_dwAdditionalStateFlags |= __EASF_INVISIBLE;
- }
- }
- }
- break;
- } // switch( message )
- return CExtControlBar::WindowProc( message, wParam, lParam );
- }
- bool CExtDynamicControlBar::_CanDockLTRB(
- CExtControlBar * pDestBar
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDestBar );
- eDynamicBarState_t eDBS = BarStateGet();
- if( eDBS != __EDBS_DOCKED )
- return false;
- CExtDynamicControlBar * pSameKindOfBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- pDestBar
- );
- if( pSameKindOfBar != NULL )
- {
- CExtDynamicControlBar::eDynamicBarState_t eDBS =
- pSameKindOfBar->BarStateGet();
- if( eDBS != CExtDynamicControlBar::__EDBS_DOCKED )
- return false;
- } // if( pSameKindOfBar != NULL )
- return CExtControlBar::_CanDockLTRB( pDestBar );
- }
- bool CExtDynamicControlBar::_CanDockToTabbedContainers(
- CExtControlBar * pDestBar
- ) const
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pDestBar );
- return _CanDockLTRB( pDestBar );
- }
- void CExtDynamicControlBar::_DraggingUpdateState(
- const CPoint & point,
- bool bForceFloatMode
- )
- {
- ASSERT_VALID( this );
- CExtControlBar::_DraggingUpdateState(
- point,
- ( BarStateGet() == __EDBS_FLOATING )
- ? true
- : bForceFloatMode
- );
- }
- bool CExtDynamicControlBar::OnQueryUseCheckMarkCommand()
- {
- ASSERT_VALID( this );
- return false;
- }
- bool CExtDynamicControlBar::OnInitDbsMenu(
- CExtPopupMenuWnd * pPopup,
- HWND hWndTrack,
- CObject * pHelperSrc,
- LPARAM lParamHelper // = 0
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pPopup );
- ASSERT( hWndTrack != NULL && ::IsWindow( hWndTrack ) );
- ASSERT_VALID( pHelperSrc );
- pHelperSrc;
- lParamHelper;
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- CExtDynamicBarSite::eDetectedUiType_t eDUIT =
- pDBS->GetDetectedUiType();
- if( eDUIT == CExtDynamicBarSite::__EDUIT_UNSUPPORTED_ENVIRONMENT )
- {
- ASSERT( FALSE );
- return false;
- }
- INT nCountInitial = pPopup->ItemGetCount();
- if( nCountInitial == 0 )
- {
- if( ! pPopup->LoadMenu(
- hWndTrack,
- IDR_NC_MENU_DYN_BAR,
- true,
- true
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- } // if( nCountInitial == 0 )
- else
- {
- if( ! pPopup->ItemGetInfo( nCountInitial - 1 ).IsSeparator() )
- {
- VERIFY( pPopup->ItemInsert() );
- nCountInitial++;
- } // if( ! pPopup->ItemGetInfo( nCountInitial - 1 ).IsSeparator() )
- CMenu _menu;
- if( ! g_ResourceManager->LoadMenu(
- _menu,
- IDR_NC_MENU_DYN_BAR
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- ASSERT( _menu.GetSafeHmenu() != NULL );
- CMenu * pSubMenu = _menu.GetSubMenu( 0 );
- if( pSubMenu == NULL )
- {
- ASSERT( FALSE );
- return false;
- }
- INT nPos;
- INT nCount = (INT)pSubMenu->GetMenuItemCount();
- for( nPos = 0; nPos < nCount; nPos++ )
- {
- CExtSafeString sMenuText;
- MENUITEMINFO _mii;
- ::memset( &_mii, 0, sizeof(MENUITEMINFO) );
- _mii.cbSize = sizeof(MENUITEMINFO);
- _mii.fMask =
- MIIM_CHECKMARKS
- |MIIM_DATA
- |MIIM_ID
- |MIIM_STATE
- |MIIM_SUBMENU
- |MIIM_TYPE
- ;
- _mii.cch = __MAX_UI_ITEM_TEXT;
- _mii.dwTypeData = sMenuText.GetBuffer( 1024 );
- ASSERT( _mii.dwTypeData != NULL );
- if( _mii.dwTypeData == NULL )
- {
- ASSERT( FALSE );
- continue;
- }
- if( ! ::GetMenuItemInfo(
- pSubMenu->GetSafeHmenu(),
- (UINT)nPos,
- TRUE,
- &_mii
- )
- )
- {
- sMenuText.ReleaseBuffer();
- ASSERT( FALSE );
- continue;
- }
- sMenuText.ReleaseBuffer();
- if( (_mii.fType & MFT_SEPARATOR) != 0
- || _mii.hSubMenu != NULL
- )
- continue;
- if( ! CExtCmdManager::IsCommand( _mii.wID ) )
- continue;
- sMenuText.Replace( _T("n"), _T("") );
- sMenuText.Replace( _T("r"), _T("") );
- sMenuText.TrimLeft();
- sMenuText.TrimRight();
- if( sMenuText.IsEmpty() )
- continue;
- int nSep =
- sMenuText.ReverseFind( _T('t') );
- if( nSep >= 0 )
- {
- CExtSafeString sTmp;
- sTmp = sMenuText.Left( nSep );
- sTmp.TrimLeft();
- sTmp.TrimRight();
- sMenuText = sTmp;
- } // if( nSep >= 0 )
- VERIFY(
- pPopup->ItemInsertCommand(
- _mii.wID,
- -1,
- LPCTSTR(sMenuText),
- NULL,
- NULL,
- false,
- 0,
- hWndTrack
- )
- );
- } // for( nPos = 0; nPos < nCount; nPos++ )
- } // else from if( nCountInitial == 0 )
- CExtDynamicControlBar::eDynamicBarState_t eDBS =
- BarStateGet();
- INT nPos;
- INT nCount = pPopup->ItemGetCount();
- for( nPos = 0; nPos < nCount; nPos ++ )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _mii = pPopup->ItemGetInfo( nPos );
- if( _mii.IsPopup() || _mii.IsSeparator() )
- continue;
- UINT nCmdID = _mii.GetCmdID();
- if( CExtCmdManager::IsSystemCommand( nCmdID ) )
- {
- _mii.SetNoCmdUI( true );
- }
- }
- for( nPos = nCountInitial; nPos < nCount; )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _mii =
- pPopup->ItemGetInfo( nPos );
- if( _mii.IsPopup() || _mii.IsSeparator() )
- {
- nPos++; // fix by Dave Kymlicka
- continue;
- }
- UINT nCmdID = _mii.GetCmdID();
- switch( nCmdID )
- {
- case ID_EXT_DYN_BAR_FLOATING:
- _mii.Check(
- ( eDBS == CExtDynamicControlBar::__EDBS_FLOATING )
- ? true : false
- );
- _mii.Enable(
- ( ( eDBS == CExtDynamicControlBar::__EDBS_FLOATING
- || eDBS == CExtDynamicControlBar::__EDBS_DOCKED
- || eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT
- )
- && _FloatStateChangingIsEnabled( this )
- ) ? true : false
- );
- break;
- case ID_EXT_DYN_BAR_DOCKABLE:
- _mii.Check(
- ( eDBS == CExtDynamicControlBar::__EDBS_DOCKED )
- ? true : false
- );
- _mii.Enable(
- ( ( eDBS == CExtDynamicControlBar::__EDBS_FLOATING
- || eDBS == CExtDynamicControlBar::__EDBS_DOCKED
- || eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT
- )
- && _FloatStateChangingIsEnabled( this )
- ) ? true : false
- );
- break;
- case ID_EXT_DYN_BAR_TABBED_DOCUMENT:
- case ID_EXT_DYN_BAR_MDI_DOCUMENT:
- if( eDUIT == CExtDynamicBarSite::__EDUIT_MDI_ORDINARY )
- {
- if( nCmdID == ID_EXT_DYN_BAR_TABBED_DOCUMENT )
- {
- VERIFY( pPopup->ItemRemove( nPos ) );
- nCount--;
- continue;
- }
- }
- else if(
- eDUIT == CExtDynamicBarSite::__EDUIT_MDI_WITH_TABS
- || eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER
- )
- {
- if( nCmdID == ID_EXT_DYN_BAR_MDI_DOCUMENT )
- {
- VERIFY( pPopup->ItemRemove( nPos ) );
- nCount--;
- continue;
- }
- }
- _mii.Check(
- ( eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT )
- ? true : false
- );
- _mii.Enable(
- ( ( eDBS == CExtDynamicControlBar::__EDBS_FLOATING
- || eDBS == CExtDynamicControlBar::__EDBS_DOCKED
- || eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT
- )
- && _FloatStateChangingIsEnabled( this )
- ) ? true : false
- );
- break;
- case ID_EXT_DYN_BAR_AUTO_HIDE:
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- _mii.Check(
- ( eDBS == CExtDynamicControlBar::__EDBS_AUTO_HIDDEN )
- ? true : false
- );
- _mii.Enable(
- ( ( eDBS == CExtDynamicControlBar::__EDBS_AUTO_HIDDEN
- || ( eDBS == CExtDynamicControlBar::__EDBS_DOCKED
- && GetParentFrame() == m_pDockSite
- )
- )
- && _AutoHidingIsEnabled( this )
- ) ? true : false
- );
- #else
- VERIFY( pPopup->ItemRemove( nPos ) );
- nCount--;
- continue;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- break;
- case ID_EXT_DYN_BAR_HIDE:
- _mii.Check( false );
- _mii.Enable( _ClosingIsEnabled( this ) );
- break;
- default:
- _mii.Check( false );
- _mii.Enable( false );
- break;
- } // switch( nCmdID )
- nPos++;
- } // for( nPos = nCountInitial; nPos < nCount; )
- if( ! _ClosingIsEnabled( this ) )
- {
- INT nPosToRemove = pPopup->ItemFindPosForCmdID( SC_CLOSE );
- for( ; nPosToRemove >= 0; nPosToRemove = pPopup->ItemFindPosForCmdID( SC_CLOSE ) )
- {
- pPopup->ItemRemove( nPosToRemove );
- if( nPosToRemove > 0
- && pPopup->ItemGetInfo( nPosToRemove -1 ).IsSeparator()
- )
- pPopup->ItemRemove( nPosToRemove - 1 );
- } // for( ; nPosToRemove >= 0; nPosToRemove = pPopup->ItemFindPosForCmdID( SC_CLOSE ) )
- } // if( ! _ClosingIsEnabled( this ) )
- return true;
- }
- void CExtDynamicControlBar::PmBridge_OnPaintManagerChanged(
- CExtPaintManager * pGlobalPM
- )
- {
- m_icon.OnEmptyGeneratedBitmaps();
- CExtControlBar::PmBridge_OnPaintManagerChanged( pGlobalPM );
- }
- HWND CExtDynamicControlBar::OnQueryChildHWND()
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- HWND hWnd = ::GetWindow( m_hWnd, GW_CHILD );
- if( m_hWndChildCached == NULL && hWnd != NULL )
- m_hWndChildCached = hWnd;
- return m_hWndChildCached;
- }
- void CExtDynamicControlBar::OnMoveChildToDocument()
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- HWND hWndChild = OnQueryChildHWND();
- if( hWndChild == NULL )
- return;
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- return;
- CExtDynamicBarSite::eDetectedUiType_t eDUIT =
- pDBS->GetDetectedUiType();
- HWND hWndContainer = ::GetParent( hWndChild );
- ASSERT( hWndContainer != NULL );
- if( hWndContainer != m_hWnd )
- {
- CWnd * pWndPermanent = CWnd::FromHandlePermanent( hWndContainer );
- if( pWndPermanent != NULL )
- {
- CExtDynamicMDIChildWnd * pWndMdiChild =
- DYNAMIC_DOWNCAST(
- CExtDynamicMDIChildWnd,
- pWndPermanent
- );
- if( pWndMdiChild != NULL )
- {
- CMDIFrameWnd * pMDIFrame =
- STATIC_DOWNCAST(
- CMDIFrameWnd,
- pWndMdiChild->GetParentFrame()
- );
- ASSERT_VALID( pMDIFrame );
- CMDIChildWnd * pActive = pMDIFrame->MDIGetActive();
- if( pWndMdiChild != pActive )
- pWndMdiChild->MDIActivate();
- } // if( pWndMdiChild != NULL )
- else
- {
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- {
- CExtTabPageContainerWnd * pWndTabPageContainer =
- DYNAMIC_DOWNCAST(
- CExtTabPageContainerWnd,
- pWndPermanent
- );
- if( pWndTabPageContainer != NULL )
- {
- CExtTabWnd * pWndTabs = pWndTabPageContainer->GetSafeTabWindow();
- ASSERT_VALID( pWndTabs );
- int nPageIdx = pWndTabs->ItemFindByLParam( LPARAM(OnQueryChildHWND()) );
- if( nPageIdx >= 0 )
- {
- CExtTabWnd::TAB_ITEM_INFO * pTII = pWndTabs->ItemGet( nPageIdx );
- ASSERT_VALID( pTII );
- pTII->EventProviderSet( this );
- if( pDBS->m_listBarsInDocMode.Find( this ) == NULL )
- pDBS->m_listBarsInDocMode.AddHead( this );
- return;
- } // if( nPageIdx >= 0 )
- } // if( pWndTabPageContainer != NULL )
- } // if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- } // else from if( pWndMdiChild != NULL )
- } // if( pWndPermanent != NULL )
- return;
- } // if( hWndContainer != m_hWnd )
- if( eDUIT == CExtDynamicBarSite::__EDUIT_UNSUPPORTED_ENVIRONMENT )
- return;
- CExtSafeString sDocumentCaptionText;
- OnGetBarCaptionText(
- __EBCT_DOCUMENT_CONTAINER_CAPTION,
- sDocumentCaptionText
- );
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- {
- CExtTabPageContainerWnd * pWndTabPageContainer =
- pDBS->GetTabPageContainer();
- ASSERT_VALID( pWndTabPageContainer );
- ASSERT( pWndTabPageContainer->GetDlgCtrlID() == AFX_IDW_PANE_FIRST );
- ::ShowWindow( hWndChild, SW_HIDE );
- ::SetParent( hWndChild, pWndTabPageContainer->m_hWnd );
- CRect rcClient;
- pWndTabPageContainer->GetClientRect( &rcClient );
- CWnd::RepositionBars(
- 0,
- 0x0FFFF,
- 0x101,
- CWnd::reposQuery,
- &rcClient,
- &rcClient,
- TRUE
- );
- ::SetWindowPos(
- hWndChild,
- HWND_BOTTOM,
- rcClient.left,
- rcClient.top,
- rcClient.Width(),
- rcClient.Height(),
- SWP_NOACTIVATE|SWP_NOCOPYBITS
- );
- int nPageIdx = m_bInsertToHeadOfTPC ? 0 : pWndTabPageContainer->PageGetCount();
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_ONENOTE_CTRL)
- CExtTabPageContainerOneNoteWnd * pOneNoteTPC =
- DYNAMIC_DOWNCAST(
- CExtTabPageContainerOneNoteWnd,
- pWndTabPageContainer
- );
- if( pOneNoteTPC != NULL )
- {
- VERIFY(
- pOneNoteTPC->PageInsert(
- CWnd::FromHandle( hWndChild ),
- m_icon,
- sDocumentCaptionText.IsEmpty() ? _T("") : LPCTSTR(sDocumentCaptionText),
- nPageIdx,
- true
- )
- );
- } // if( pOneNoteTPC != NULL )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_ONENOTE_CTRL)
- {
- VERIFY(
- pWndTabPageContainer->PageInsert(
- CWnd::FromHandle( hWndChild ),
- m_icon,
- sDocumentCaptionText.IsEmpty() ? _T("") : LPCTSTR(sDocumentCaptionText),
- nPageIdx,
- true
- )
- );
- } // else from if( pOneNoteTPC != NULL )
- if( pWndTabPageContainer->ShowBtnCloseGet() )
- pWndTabPageContainer->EnabledBtnCloseSet( true );
- CExtTabWnd * pWndTabs = pWndTabPageContainer->GetSafeTabWindow();
- ASSERT_VALID( pWndTabs );
- CExtTabWnd::TAB_ITEM_INFO * pTII = pWndTabs->ItemGet( nPageIdx );
- ASSERT_VALID( pTII );
- ASSERT( ((HWND)pTII->LParamGet()) != NULL );
- ASSERT( ((HWND)pTII->LParamGet()) == OnQueryChildHWND() );
- pTII->EventProviderSet( this );
- pDBS->m_listBarsInDocMode.AddHead( this );
- return;
- } // if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- CMDIFrameWnd * pMdiFrame =
- STATIC_DOWNCAST(
- CMDIFrameWnd,
- m_pDockSite
- );
- ASSERT_VALID( pMdiFrame );
- bool bMaximized = false;
- HWND hWndActiveMdiChildFrame =
- pDBS->GetActiveMdiChildFrameHWND( &bMaximized );
- if( hWndActiveMdiChildFrame == NULL )
- bMaximized = true;
- DWORD dwMdiChildFrameWindowStyles =
- ( (WS_OVERLAPPEDWINDOW) & (~WS_POPUP) )
- |WS_CHILD
- |WS_VISIBLE
- |FWS_ADDTOTITLE
- ;
- if( bMaximized )
- dwMdiChildFrameWindowStyles |= WS_MAXIMIZE;
- CExtDynamicMDIChildWnd * pWndMdiChild =
- OnCreateDynamicMDIChildWndInstance();
- if( pWndMdiChild == NULL )
- {
- ASSERT( FALSE );
- return;
- }
- ASSERT_VALID( pWndMdiChild );
- if( ! m_icon.IsEmpty() )
- pWndMdiChild->m_icon = m_icon;
- if( ! pWndMdiChild->Create(
- ::AfxRegisterWndClass(
- CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS
- ),
- sDocumentCaptionText.IsEmpty()
- ? _T("")
- : LPCTSTR(sDocumentCaptionText),
- dwMdiChildFrameWindowStyles,
- CFrameWnd::rectDefault,
- STATIC_DOWNCAST( CMDIFrameWnd, m_pDockSite )
- )
- )
- {
- ASSERT( FALSE );
- return;
- }
- pWndMdiChild->SetTitle(
- sDocumentCaptionText.IsEmpty() ? _T("") : LPCTSTR(sDocumentCaptionText)
- );
- pWndMdiChild->DelayUpdateFrameTitle();
- HMENU hMenuDefault = NULL;
- if( m_nMdiMenuResourceID != 0 )
- {
- CMenu _menu;
- if( g_ResourceManager->LoadMenu( _menu, m_nMdiMenuResourceID ) )
- {
- ASSERT( _menu.GetSafeHmenu() != NULL );
- hMenuDefault = _menu.Detach();
- } // if( g_ResourceManager->LoadMenu( _menu, m_nMdiMenuResourceID ) )
- } // if( m_nMdiMenuResourceID != 0 )
- if( hMenuDefault == NULL )
- hMenuDefault = pMdiFrame->m_hMenuDefault;
- HACCEL hAccelTable = pMdiFrame->m_hAccelTable;
- if( m_nMdiAccelTableResourceID != 0 )
- hAccelTable =
- g_ResourceManager->LoadAccelerators(
- m_nMdiMenuResourceID
- );
- if( hAccelTable == NULL )
- hAccelTable = pMdiFrame->m_hAccelTable;
- pWndMdiChild->SetHandles(
- hMenuDefault,
- hAccelTable
- );
- pWndMdiChild->MDIActivate();
- if( hMenuDefault != NULL )
- pMdiFrame->OnUpdateFrameMenu( hMenuDefault );
- pDBS->m_listBarsInDocMode.AddHead( this );
- }
- CExtDynamicMDIChildWnd * CExtDynamicControlBar::OnCreateDynamicMDIChildWndInstance()
- {
- ASSERT_VALID( this );
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- {
- ASSERT( FALSE );
- return NULL;
- }
- CExtDynamicMDIChildWnd * pWndMdiChild =
- pDBS->OnDbsCreateDynamicMDIChildWndInstance( this );
- return pWndMdiChild;
- }
- void CExtDynamicControlBar::OnMoveChildToBar()
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- HWND hWndChild = OnQueryChildHWND();
- if( hWndChild == NULL )
- return;
- HWND hWndContainer = ::GetParent( hWndChild );
- ASSERT( hWndContainer != NULL );
- if( hWndContainer == m_hWnd )
- return;
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- return;
- CExtDynamicBarSite::eDetectedUiType_t eDUIT =
- pDBS->GetDetectedUiType();
- if( eDUIT == CExtDynamicBarSite::__EDUIT_UNSUPPORTED_ENVIRONMENT )
- return;
- POSITION posInList = pDBS->m_listBarsInDocMode.Find( this );
- if( posInList != NULL )
- pDBS->m_listBarsInDocMode.RemoveAt( posInList );
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- {
- CExtTabPageContainerWnd * pWndTabPageContainer =
- pDBS->GetTabPageContainer();
- ASSERT_VALID( pWndTabPageContainer );
- ASSERT( pWndTabPageContainer->GetDlgCtrlID() == AFX_IDW_PANE_FIRST );
- int nSelPageIdx = pWndTabPageContainer->PageSelectionGet();
- if( nSelPageIdx < 0 )
- return;
- HWND hWndChild = OnQueryChildHWND();
- if( hWndChild != NULL && ::IsWindow( hWndChild ) )
- {
- HWND hWndChildInTPC = pWndTabPageContainer->PageHwndGetSafe( nSelPageIdx );
- ASSERT( hWndChildInTPC != NULL && ::IsWindow( hWndChildInTPC ) );
- if( hWndChild == hWndChildInTPC )
- {
- ::ShowWindow( hWndChild, SW_HIDE );
- ::SetParent( hWndChild, m_hWnd );
- pWndTabPageContainer->PageRemove( nSelPageIdx, 1, false );
- CRect rcClient;
- GetClientRect( &rcClient );
- ::MoveWindow(
- hWndChild,
- rcClient.left,
- rcClient.top,
- rcClient.Width(),
- rcClient.Height(),
- TRUE
- );
- GetParentFrame()->DelayRecalcLayout();
- ::ShowWindow( hWndChild, SW_SHOW );
- } // if( hWndChild == hWndChildInTPC )
- if( pWndTabPageContainer->ShowBtnCloseGet() )
- pWndTabPageContainer->EnabledBtnCloseSet(
- ( pWndTabPageContainer->PageGetCount() > 0 )
- ? true : false
- );
- pWndTabPageContainer->Invalidate();
- } // if( hWndChild != NULL && ::IsWindow( hWndChild ) )
- return;
- } // if( eDUIT == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- CWnd * pWndPermanent =
- CWnd::FromHandlePermanent(hWndContainer);
- if( pWndPermanent != NULL )
- {
- CExtDynamicMDIChildWnd * pWndMdiChild =
- DYNAMIC_DOWNCAST(
- CExtDynamicMDIChildWnd,
- pWndPermanent
- );
- if( pWndMdiChild != NULL )
- {
- ASSERT_VALID( pWndMdiChild );
- pWndMdiChild->DestroyWindow();
- } // if( pWndMdiChild != NULL )
- } // if( pWndPermanent != NULL )
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- bool CExtDynamicControlBar::AutoHideModeSet(
- bool bAutoHideMode,
- bool bAnimate,
- bool bRecalcLayout,
- bool bForceNoShow
- )
- {
- ASSERT_VALID( this );
- bool bRetVal =
- CExtControlBar::AutoHideModeSet(
- bAutoHideMode,
- bAnimate,
- bRecalcLayout,
- bForceNoShow
- );
- // if( m_eDBS == __EDBS_AUTO_HIDDEN
- // && ( ! bAutoHideMode )
- // )
- // m_eDBS = __EDBS_DOCKED;
- return bRetVal;
- }
- bool CExtDynamicControlBar::OnQueryVisibilityInAutoHideTabs() const
- {
- return OnQueryVisibilityInContainerTabs();
- }
- bool CExtDynamicControlBar::OnQueryVisibilityInContainerTabs() const
- {
- ASSERT_VALID( this );
- if( BarStateGet() == __EDBS_DOCUMENT )
- return false;
- return CExtControlBar::OnQueryVisibilityInAutoHideTabs();
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- void CExtDynamicControlBar::OnSerializeDynamicProps( CArchive & ar )
- {
- ASSERT_VALID( this );
- DWORD dwTmp = 0;
- if( ar.IsStoring() )
- {
- dwTmp = (DWORD)m_eDBS;
- ar << dwTmp;
- ar << m_dwAdditionalStateFlags;
- ar << DWORD(m_nMdiMenuResourceID);
- ar << DWORD(m_nMdiAccelTableResourceID);
- } // if( ar.IsStoring() )
- else
- {
- ar >> dwTmp;
- m_eDBS = (eDynamicBarState_t)dwTmp;
- ar >> m_dwAdditionalStateFlags;
- ar >> dwTmp;
- m_nMdiMenuResourceID = UINT(dwTmp);
- ar >> dwTmp;
- m_nMdiAccelTableResourceID = UINT(dwTmp);
- m_bAppearInDockSiteControlBarPopupMenu =
- ( m_eDBS == __EDBS_DOCUMENT ) ? false : true;
- if( ( m_dwAdditionalStateFlags & __EASF_INVISIBLE ) != 0 )
- DelayShow( FALSE );
- if( m_eDBS == __EDBS_DOCUMENT )
- OnMoveChildToDocument();
- else
- OnMoveChildToBar();
- } // else from if( ar.IsStoring() )
- }
- void CExtDynamicControlBar::OnExtBarStateSerializationComplete(
- bool bStore
- )
- {
- ASSERT_VALID( this );
- CExtControlBar::OnExtBarStateSerializationComplete(
- bStore
- );
- if( bStore )
- return;
- OnQueryChildHWND();
- bool bIsVisibleState;
- if( BarStateGet( &bIsVisibleState ) == __EDBS_DOCUMENT )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- ASSERT( ! AutoHideModeGet() );
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( bIsVisibleState )
- OnMoveChildToDocument();
- } // if( BarStateGet( &bIsVisibleState ) == __EDBS_DOCUMENT )
- }
- bool CExtDynamicControlBar::OnInsertDynamicBarCommandIntoPopupMenu(
- CExtPopupMenuWnd * pPopup,
- INT nInsertPos
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pPopup );
- ASSERT( 0 <= nInsertPos && nInsertPos <= pPopup->ItemGetCount() );
- UINT nCmdID = UINT( GetDlgCtrlID() );
- ASSERT(
- g_CmdManager->CmdGetPtr(
- g_CmdManager->ProfileNameFromWnd( m_hWnd ),
- nCmdID
- ) != 0
- );
- if( ! pPopup->ItemInsert(
- nCmdID,
- nInsertPos
- )
- )
- {
- ASSERT( FALSE );
- return false;
- }
- return true;
- }
- CExtDynamicControlBar::eDynamicBarState_t
- CExtDynamicControlBar::BarStateGet(
- bool * p_bIsVisibleState // = NULL
- ) const
- {
- ASSERT_VALID( this );
- if( p_bIsVisibleState != NULL )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( m_eDBS == __EDBS_AUTO_HIDDEN )
- {
- (*p_bIsVisibleState) = false;
- if( m_hWnd != NULL
- && ::IsWindow( m_hWnd )
- && ::GetWindow( m_hWnd, GW_CHILD ) == NULL
- && AutoHideModeGet()
- )
- {
- ASSERT_KINDOF( CExtDockBar, m_pDockBar );
- CExtDynAutoHideArea * pWndAutoHideArea =
- ((CExtDockBar*)m_pDockBar)->_GetAutoHideArea();
- ASSERT_VALID( pWndAutoHideArea );
- CExtDynAutoHideSlider * pWndSlider =
- pWndAutoHideArea->GetAutoHideSlider();
- if( LPCVOID(pWndSlider->GetBar()) == LPCVOID(this)
- && (pWndSlider->GetStyle()&WS_VISIBLE) != 0
- )
- (*p_bIsVisibleState) = true;
- }
- } // if( m_eDBS == __EDBS_AUTO_HIDDEN )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- (*p_bIsVisibleState) =
- ( ( m_dwAdditionalStateFlags & __EASF_INVISIBLE ) != 0 )
- ? false : true;
- }
- return m_eDBS;
- }
- bool CExtDynamicControlBar::BarStateSet(
- CExtDynamicControlBar::eDynamicBarState_t eDBS,
- bool bShow
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( m_pDockSite );
- // if( m_eDBS == eDBS )
- // return true;
- m_eHelperSwitchingDBS = eDBS;
- m_bHelperSwitchingIntoVisibleState = bShow;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( eDBS == __EDBS_AUTO_HIDDEN && (!bShow) )
- eDBS = __EDBS_DOCKED;
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- switch( eDBS )
- {
- case __EDBS_FLOATING:
- m_bAppearInDockSiteControlBarPopupMenu = true;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( AutoHideModeGet() )
- AutoHideModeSet( false, false, false, true );
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- OnMoveChildToBar();
- if( ! IsFloating() )
- FloatControlBar();
- // if( ! bShow )
- // m_pDockSite->ShowControlBar( this, FALSE, FALSE );
- // else
- // m_pDockSite->ShowControlBar( this, TRUE, FALSE );
- if( (! bShow ) && IsVisible()
- || bShow && (! IsVisible() )
- )
- {
- OnFrameBarCheckCmd( true ); // show/hide me
- GetParentFrame()->RecalcLayout();
- }
- break;
- case __EDBS_DOCKED:
- m_bAppearInDockSiteControlBarPopupMenu = true;
- OnMoveChildToBar();
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( AutoHideModeGet() )
- {
- AutoHideModeSet( false, false, true, true );
- if( bShow )
- OnFrameBarCheckCmd( false ); // show me
- } // if( AutoHideModeGet() )
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- {
- if( bShow )
- m_eDBS = eDBS; // for making OnQueryVisibilityInContainerTabs() returning true
- if( (! bShow ) && IsVisible()
- || bShow && (! IsVisible() )
- )
- {
- OnFrameBarCheckCmd( true ); // show/hide me
- GetParentFrame()->RecalcLayout();
- }
- } // else from if( AutoHideModeGet() )
- break;
- case __EDBS_DOCUMENT:
- if( OnQueryChildHWND() == NULL )
- {
- ASSERT( FALSE );
- return false;
- } // if( OnQueryChildHWND() == NULL )
- m_bAppearInDockSiteControlBarPopupMenu = false;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( AutoHideModeGet() )
- AutoHideModeSet( false, false, false, true );
- else
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( IsVisible() )
- {
- OnFrameBarCheckCmd( true ); // hide me
- GetParentFrame()->RecalcLayout();
- }
- if( bShow )
- OnMoveChildToDocument();
- else
- OnMoveChildToBar();
- break;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- case __EDBS_AUTO_HIDDEN:
- m_bAppearInDockSiteControlBarPopupMenu = true;
- ASSERT( bShow );
- if( ! AutoHideModeGet() )
- {
- OnMoveChildToBar();
- if( IsFloating()
- || GetParentFrame() != m_pDockSite
- )
- {
- VERIFY(
- DockControlBarInnerOuter(
- AFX_IDW_DOCKBAR_LEFT,
- false,
- m_pDockSite,
- false
- )
- );
- }
- VERIFY(
- AutoHideModeSet(
- true,
- false,
- true,
- false
- )
- );
- } // if( ! AutoHideModeGet() )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- break;
- #ifdef _DEBUG
- default:
- {
- ASSERT( FALSE );
- }
- break;
- #endif // _DEBUG
- } //switch( eDBS )
- m_eDBS = eDBS;
- if( bShow )
- m_dwAdditionalStateFlags &= ~__EASF_INVISIBLE;
- else
- m_dwAdditionalStateFlags |= __EASF_INVISIBLE;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- // if( eDBS != __EDBS_DOCUMENT && eDBS != __EDBS_FLOATING )
- if( eDBS == __EDBS_AUTO_HIDDEN )
- {
- CExtDockDynTabBar * pDynDockBar =
- DYNAMIC_DOWNCAST(
- CExtDockDynTabBar,
- GetParent()
- );
- if( pDynDockBar != NULL )
- {
- CExtDynTabControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST(
- CExtDynTabControlBar,
- pDynDockBar->GetParent()
- );
- LONG nPos, nCount = pTabbedBar->GetSwitcherItemCount();
- for( nPos = 0; nPos < nCount; nPos++ )
- {
- CExtControlBar * pContainedBar =
- pTabbedBar->GetBarAt( nPos, true );
- CExtDynamicControlBar * pDynamicBar =
- DYNAMIC_DOWNCAST( CExtDynamicControlBar, pContainedBar );
- if( pDynamicBar != NULL )
- pDynamicBar->m_eDBS = eDBS;
- } // for( nPos = 0; nPos < nCount; nPos++ )
- } // if( pDynDockBar != NULL )
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- return true;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicMDIChildWnd
- IMPLEMENT_DYNAMIC( CExtDynamicMDIChildWnd, CMDIChildWnd );
- CExtDynamicMDIChildWnd::CExtDynamicMDIChildWnd(
- CExtDynamicControlBar * pBar
- )
- : m_pDBS( NULL )
- , m_pBar( NULL )
- , m_hWndHelperBar( NULL )
- {
- if( pBar != NULL )
- AttachBar( pBar );
- }
- CExtDynamicMDIChildWnd::~CExtDynamicMDIChildWnd()
- {
- }
- void CExtDynamicMDIChildWnd::AttachBar( CExtDynamicControlBar * pBar )
- {
- ASSERT_VALID( this );
- m_pBar = pBar;
- ASSERT_VALID( m_pBar );
- m_hWndHelperBar = m_pBar->GetSafeHwnd();
- ASSERT( m_hWndHelperBar != NULL );
- ASSERT( ::GetWindow( m_hWndHelperBar, GW_CHILD ) != NULL );
- }
- void CExtDynamicMDIChildWnd::PostNcDestroy()
- {
- delete this;
- }
- CExtDynamicControlBar * CExtDynamicMDIChildWnd::GetBar()
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() == m_hWndHelperBar );
- return m_pBar;
- }
- CExtDynamicBarSite * CExtDynamicMDIChildWnd::GetBarSite()
- {
- ASSERT_VALID( this );
- ASSERT( GetSafeHwnd() != NULL );
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() == m_hWndHelperBar );
- if( m_pDBS == NULL )
- m_pDBS = m_pBar->GetBarSite();
- return m_pDBS;
- }
- //BOOL CExtDynamicMDIChildWnd::PreTranslateMessage(MSG* pMsg)
- //{
- // ASSERT_VALID( this );
- // if( m_pBar != NULL )
- // {
- // ASSERT_VALID( m_pBar );
- // if( m_pBar->PreTranslateMessage( pMSG ) )
- // return TRUE;
- // } // if( m_pBar != NULL )
- // return CMDIChildWnd::PreTranslateMessage( pMSG );
- //}
- BOOL CExtDynamicMDIChildWnd::OnCmdMsg(
- UINT nID,
- int nCode,
- void * pExtra,
- AFX_CMDHANDLERINFO * pHandlerInfo
- )
- {
- ASSERT_VALID( this );
- if( m_pBar != NULL )
- {
- ASSERT_VALID( m_pBar );
- if( m_pBar->OnCmdMsg(
- nID,
- nCode,
- pExtra,
- pHandlerInfo
- )
- )
- return TRUE;
- } // if( m_pBar != NULL )
- return
- CMDIChildWnd::OnCmdMsg(
- nID,
- nCode,
- pExtra,
- pHandlerInfo
- );
- }
- BOOL CExtDynamicMDIChildWnd::PreCreateWindow(CREATESTRUCT& cs)
- {
- ASSERT_VALID( this );
- if( ! CMDIChildWnd::PreCreateWindow(cs) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- cs.dwExStyle &= ~(WS_EX_CLIENTEDGE);
- return TRUE;
- }
- LRESULT CExtDynamicMDIChildWnd::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
- {
- if( message == WM_SETFOCUS )
- {
- ASSERT( m_hWndHelperBar != NULL );
- if( ::IsWindow(m_hWndHelperBar) )
- {
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() == m_hWndHelperBar );
- HWND hWndChild = m_pBar->OnQueryChildHWND();
- if( hWndChild != NULL
- && ::GetParent(hWndChild) == m_hWnd
- )
- {
- if( CExtControlBar::stat_QueryFocusChangingEnabled( m_pBar, hWndChild ) )
- ::SetFocus( hWndChild );
- }
- } // if( ::IsWindow(m_hWndHelperBar) )
- return 0;
- } // else if( message == WM_SETFOCUS )
- if( (message == WM_SYSCOMMAND && wParam == SC_CLOSE)
- || message == WM_CLOSE
- )
- { // closing messages
- ASSERT( m_hWndHelperBar != NULL );
- if( ::IsWindow(m_hWndHelperBar) )
- {
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() == m_hWndHelperBar );
- m_pBar->BarStateSet(
- CExtDynamicControlBar::__EDBS_DOCUMENT,
- false
- );
- } // if( ::IsWindow(m_hWndHelperBar) )
- return 0;
- } // closing messages
- // if( message == WM_NCPAINT )
- // {
- // // WM_NCPAINT and WM_WINDOWPOSCHANGED messages are
- // // handled to fix WinXP MDI interface flicker bug
- // CMDIFrameWnd * pMdiFrame =
- // STATIC_DOWNCAST( CMDIFrameWnd, GetParentFrame() );
- // ASSERT_VALID( pMdiFrame );
- // BOOL bMax = FALSE;
- // CMDIChildWnd * pActive = pMdiFrame->MDIGetActive( &bMax );
- // pActive;
- // if( bMax )
- // return 0 ;
- // } // if( message == WM_NCPAINT )
- // else if( message == WM_WINDOWPOSCHANGED )
- // {
- // // WM_NCPAINT and WM_WINDOWPOSCHANGED messages are
- // // handled to fix WinXP MDI interface flicker bug
- // CMDIFrameWnd * pMdiFrame =
- // STATIC_DOWNCAST( CMDIFrameWnd, GetParentFrame() );
- // ASSERT_VALID( pMdiFrame );
- // BOOL bMax = FALSE;
- // CMDIChildWnd * pActive = pMdiFrame->MDIGetActive( &bMax );
- // pActive;
- // if( ! bMax )
- // {
- // LRESULT lResult = CMDIChildWnd::WindowProc( message, wParam, lParam );
- // return lResult;
- // } // if( ! bMax )
- // SetRedraw( FALSE );
- // LRESULT lResult = CMDIChildWnd::WindowProc( message, wParam, lParam );
- // SetRedraw( TRUE );
- // RedrawWindow(
- // NULL, NULL,
- // RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN|RDW_FRAME
- // );
- // return lResult;
- // } // else if( message == WM_WINDOWPOSCHANGED )
- LRESULT lResult = CMDIChildWnd::WindowProc( message, wParam, lParam );
- if( message == WM_CREATE )
- {
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() == m_hWndHelperBar );
- HWND hWndChild = ::GetWindow( m_pBar->GetSafeHwnd(), GW_CHILD );
- ASSERT( hWndChild != NULL );
- ::__EXT_MFC_SetWindowLong( hWndChild, GWL_ID, AFX_IDW_PANE_FIRST );
- ::SetParent( hWndChild, m_hWnd );
- if( ! m_icon.IsEmpty() )
- {
- SetIcon( m_icon.ExtractHICON(), FALSE ); // NEW EXCTACT ICON 2.53
- SetIcon( m_icon.ExtractHICON(), TRUE ); // NEW EXCTACT ICON 2.53
- } // if( ! m_icon.IsEmpty() )
-
- CMenu * pSysMenu = GetSystemMenu( FALSE );
- if( pSysMenu != NULL )
- {
- ASSERT_KINDOF(CMenu, pSysMenu);
- pSysMenu->EnableMenuItem(
- SC_CLOSE,
- MF_BYCOMMAND
- | ( m_pBar->_ClosingIsEnabled( m_pBar ) ? MF_ENABLED : MF_DISABLED )
- );
- } // if( pSysMenu != NULL )
- } // if( message == WM_CREATE )
- return lResult;
- }
- BOOL CExtDynamicMDIChildWnd::DestroyWindow()
- {
- ASSERT_VALID( this );
- HWND hWndChild = ::GetWindow( m_hWnd, GW_CHILD );
- ASSERT( hWndChild != NULL );
- ASSERT_VALID( m_pBar );
- ASSERT( m_pBar->GetSafeHwnd() != NULL );
- if( ! m_pBar->_ClosingIsEnabled( m_pBar ) )
- return FALSE;
- ::SetParent( hWndChild, m_pBar->m_hWnd );
- CExtMiniDockFrameWnd * pMiniFrame =
- DYNAMIC_DOWNCAST( CExtMiniDockFrameWnd, m_pBar->GetParentFrame() );
- if( pMiniFrame != NULL )
- {
- bool bFloatingVisible = false;
- if( ( m_pBar->m_eHelperSwitchingDBS == CExtDynamicControlBar::__EDBS_FLOATING
- || m_pBar->m_eHelperSwitchingDBS == CExtDynamicControlBar::__EDBS_DOCKED
- )
- && m_pBar->m_bHelperSwitchingIntoVisibleState
- )
- bFloatingVisible = true;
- pMiniFrame->ModifyStyle( FWS_SNAPTOBARS, 0 );
- CSize _sizeF = m_pBar->GetSizeFloating();
- CRect rcWndBar( 0, 0, _sizeF.cx, _sizeF.cy );
- CRect rcClientFrame, rcWndFrame, rcFrameNC(0,0,0,0);
- pMiniFrame->GetWindowRect( &rcWndFrame );
- if( ! pMiniFrame->PmBridge_GetPM()->Bar_MiniDockFrameNcCalcSize(
- rcFrameNC,
- pMiniFrame,
- m_pBar
- )
- )
- {
- rcFrameNC.left = rcFrameNC.right = ::GetSystemMetrics( SM_CXSIZEFRAME );
- rcFrameNC.top = rcFrameNC.bottom = ::GetSystemMetrics( SM_CYSIZEFRAME );
- rcFrameNC.top += ::GetSystemMetrics( SM_CYSMCAPTION );
- }
- rcWndFrame.right = rcWndFrame.left + rcWndBar.Width(); // + rcFrameNC.left + rcFrameNC.right;
- rcWndFrame.bottom = rcWndFrame.top + rcWndBar.Height(); // + rcFrameNC.top + rcFrameNC.bottom;
- rcWndBar.right -= rcFrameNC.left + rcFrameNC.right;
- rcWndBar.bottom -= rcFrameNC.top + rcFrameNC.bottom;
- rcClientFrame = rcWndFrame;
- // rcClientFrame.DeflateRect(
- // rcFrameNC.left,
- // rcFrameNC.top,
- // rcFrameNC.right,
- // rcFrameNC.bottom
- // );
- rcClientFrame.DeflateRect(
- 0,
- 0,
- 4,
- 4
- );
- rcClientFrame.OffsetRect( -rcClientFrame.TopLeft() );
- // pMiniFrame->MoveWindow( &rcWndFrame );
- CRect rcMove = rcWndFrame;
- rcMove.right += rcFrameNC.left + rcFrameNC.right - 4;
- rcMove.bottom += rcFrameNC.top + rcFrameNC.bottom - 4;
- pMiniFrame->MoveWindow( &rcMove );
- m_pBar->MoveWindow( rcWndBar );
- pMiniFrame->DelayRecalcLayout();
- if( bFloatingVisible )
- m_pBar->DelayShow( TRUE );
- CSize _size = rcWndFrame.Size();
- m_pBar->SetInitDesiredSizeFloating( _size );
- m_pBar->m_pDockContext->m_sizeLast = _size;
- if( bFloatingVisible )
- {
- pMiniFrame->ShowWindow( SW_SHOWNOACTIVATE );
- pMiniFrame->RecalcLayout();
- }
- CRect rcClientFrameN, rcWndFrameN;
- pMiniFrame->GetClientRect( &rcClientFrameN );
- pMiniFrame->GetWindowRect( &rcWndFrameN );
- CRect rcClientBarN, rcWndBarN;
- m_pBar->GetClientRect( &rcClientBarN );
- m_pBar->GetWindowRect( &rcWndBarN );
- CSize _sizeBarN =
- rcWndBarN.Size()
- + rcClientFrameN.Size()
- - rcWndFrameN.Size()
- - rcClientBarN.Size()
- + rcWndBarN.Size()
- ;
- m_pBar->OnRepositionSingleChild(
- _sizeBarN.cx,
- _sizeBarN.cy,
- true
- );
- m_pBar->OnNcAreaButtonsReposition();
- } // if( pMiniFrame != NULL )
- else
- {
- CRect rcClient;
- m_pBar->GetClientRect( &rcClient );
- ::MoveWindow(
- hWndChild,
- rcClient.left,
- rcClient.top,
- rcClient.Width(),
- rcClient.Height(),
- TRUE
- );
- } // else from if( pMiniFrame != NULL )
- return CMDIChildWnd::DestroyWindow();
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicBarHookSink
- CExtDynamicBarHookSink::CExtDynamicBarHookSink()
- : m_pDBS( NULL )
- {
- }
- CExtDynamicBarHookSink::~CExtDynamicBarHookSink()
- {
- }
- CFrameWnd * CExtDynamicBarHookSink::DockSiteGet()
- {
- ASSERT( this != NULL );
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- return NULL;
- return pDBS->DockSiteGet();
- }
- CExtDynamicBarSite * CExtDynamicBarHookSink::GetBarSite()
- {
- ASSERT( this != NULL );
- return m_pDBS;
- }
- bool CExtDynamicBarHookSink::OnHookWndMsg(
- LRESULT & lResult,
- HWND hWndHooked,
- UINT nMessage,
- WPARAM & wParam,
- LPARAM & lParam
- )
- {
- ASSERT( this != NULL );
- CExtDynamicBarSite * pDBS = GetBarSite();
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() != NULL
- && hWndHooked == pDockSite->GetSafeHwnd()
- )
- {
- switch( nMessage )
- {
- case WM_DESTROY:
- {
- //pDBS->_BarFreeAllImpl( true );
- if( pDockSite->IsKindOf( RUNTIME_CLASS(CMDIChildWnd) ) )
- pDBS->BarFreeAll();
- }
- break; // case WM_DESTROY
- default:
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( nMessage == CExtControlBar::g_nMsgCreateTabbedBar )
- {
- lResult = 0L;
- CExtDynTabControlBar ** ppTabbedBar =
- (CExtDynTabControlBar **)wParam;
- ASSERT( ppTabbedBar != NULL );
- (*ppTabbedBar) = pDBS->OnDbsCreateTabbedBarInstance();
- ASSERT( (*ppTabbedBar) != NULL );
- return true;
- } // if( nMessage == CExtControlBar::g_nMsgCreateTabbedBar )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( nMessage == CExtDynamicBarSite::g_nMsgFindDynamicBarSite )
- {
- CExtDynamicBarSite ** ppDBS =
- (CExtDynamicBarSite **)wParam;
- ASSERT( ppDBS != NULL );
- (*ppDBS) = pDBS;
- lResult = 0L;
- return true;
- } // if( nMessage == CExtDynamicBarSite::g_nMsgFindDynamicBarSite )
- if( nMessage == CExtPopupMenuWnd::g_nMsgPrepareMenu )
- {
- CExtPopupMenuWnd::MsgPrepareMenuData_t * pData =
- reinterpret_cast
- < CExtPopupMenuWnd::MsgPrepareMenuData_t * >
- ( wParam );
- ASSERT( pData != NULL );
- CExtPopupMenuWnd * pPopup = pData->m_pPopup;
- ASSERT( pPopup != NULL );
- pData->m_bMenuChanged = OnPreparePopupMenu( pPopup );
- return false;
- } // if( nMessage == CExtPopupMenuWnd::g_nMsgPrepareMenu )
- if( nMessage == CExtMenuControlBar::g_nMsgPrepareSystemMenu )
- {
- CExtPopupMenuWnd * pPopup = (CExtPopupMenuWnd *)wParam;
- ASSERT_VALID( pPopup );
- ASSERT_KINDOF( CExtPopupMenuWnd, pPopup );
- CFrameWnd * pFrame = (CFrameWnd*)lParam;
- ASSERT_VALID( pFrame );
- ASSERT_KINDOF( CFrameWnd, pFrame );
- CExtDynamicMDIChildWnd * pDynamicMDIChildWnd =
- DYNAMIC_DOWNCAST(
- CExtDynamicMDIChildWnd,
- pFrame
- );
- if( pDynamicMDIChildWnd == NULL )
- return false;
- CExtDynamicControlBar * pBar =
- pDynamicMDIChildWnd->GetBar();
- ASSERT_VALID( pBar );
- pBar->OnInitDbsMenu(
- pPopup,
- pBar->m_hWnd,
- pDynamicMDIChildWnd
- );
- return false;
- } // if( nMessage == CExtMenuControlBar::g_nMsgPrepareSystemMenu )
- if( nMessage == CExtControlBar::g_nMsgConstructPopupMenu )
- {
- CExtControlBar::POPUP_MENU_EVENT_DATA * p_pmed =
- CExtControlBar::POPUP_MENU_EVENT_DATA::FromWParam( wParam );
- ASSERT( p_pmed != NULL );
- ASSERT_VALID( p_pmed->m_pPopupMenuWnd );
- ASSERT_VALID( p_pmed->m_pWndEventSrc );
- ASSERT( p_pmed->m_pWndEventSrc->GetSafeHwnd() != NULL );
- ASSERT( ::IsWindow(p_pmed->m_pWndEventSrc->GetSafeHwnd()) );
- if( p_pmed->m_bPostNotification )
- return false;
- #if ( (!defined __EXT_MFC_NO_TABMDI_CTRL) || (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL) )
- if(
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MDITABS_CTX
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- #if ( (!defined __EXT_MFC_NO_TABMDI_CTRL) && (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL) )
- ||
- #endif // ( (!defined __EXT_MFC_NO_TABMDI_CTRL) && (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL) )
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_TAB_PAGE_CONTAINER_TABS_CTX
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- )
- {
- CExtTabWnd * pWndTab =
- STATIC_DOWNCAST(
- CExtTabWnd,
- p_pmed->m_pWndEventSrc
- );
- CPoint point = p_pmed->m_ptScreen;
- pWndTab->ScreenToClient( &point );
- LONG nItemIdx =
- pWndTab->ItemHitTest( point );
- if( nItemIdx < 0 )
- return false;
- HWND hWnd = (HWND)
- pWndTab->ItemGet( nItemIdx )->LParamGet();
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return false;
- CExtDynamicControlBar * pBar = NULL;
- CObject * pObjHelperSrc = NULL;
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- if( p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MDITABS_CTX )
- {
- CWnd * pWnd =
- CWnd::FromHandlePermanent( hWnd );
- if( pWnd == NULL )
- return false;
- CExtDynamicMDIChildWnd * pDynamicMDIChildWnd =
- DYNAMIC_DOWNCAST(
- CExtDynamicMDIChildWnd,
- pWnd
- );
- if( pDynamicMDIChildWnd == NULL )
- return false;
- pObjHelperSrc = pDynamicMDIChildWnd;
- pBar =
- pDynamicMDIChildWnd->GetBar();
- ASSERT_VALID( pBar );
- } // if( p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MDITABS_CTX )
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_TAB_PAGE_CONTAINER_TABS_CTX )
- {
- CWnd * pWnd = CWnd::FromHandle( hWnd );
- pObjHelperSrc = pWnd;
- pBar =
- pDBS->BarFindByChildHWND( hWnd );
- if( pBar == NULL )
- return false;
- ASSERT_VALID( pBar );
- } // if( p_pmed->m_nHelperNotificationType == CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_TAB_PAGE_CONTAINER_TABS_CTX );
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- pBar->OnInitDbsMenu(
- p_pmed->m_pPopupMenuWnd,
- pBar->m_hWnd,
- pObjHelperSrc
- );
- CExtPaintManager::stat_PassPaintMessages();
- lResult = 1L;
- return true;
- } // if( ...
- #endif // ( (!defined __EXT_MFC_NO_TABMDI_CTRL) || (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL) )
- if( p_pmed->m_nHelperNotificationType ==
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_NC_CTX
- || p_pmed->m_nHelperNotificationType ==
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_CONTROLBAR_CTX
- || p_pmed->m_nHelperNotificationType ==
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_MINIFRAME_NC_CTX
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- || p_pmed->m_nHelperNotificationType ==
- CExtControlBar::POPUP_MENU_EVENT_DATA::__PMED_AUTOHIDESLIDER_CTX
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- )
- {
- CExtDynamicControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- p_pmed->m_pWndEventSrc
- );
- if( pBar == NULL )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynamicTabbedControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicTabbedControlBar,
- p_pmed->m_pWndEventSrc
- );
- if( pTabbedBar == NULL )
- return false;
- LONG nSel = pTabbedBar->GetSwitcherSelection();
- if( nSel < 0 )
- return false;
- CExtControlBar * pExtBar =
- pTabbedBar->GetBarAt( nSel, true );
- if( pExtBar == NULL )
- return false;
- pBar =
- DYNAMIC_DOWNCAST(
- CExtDynamicControlBar,
- pExtBar
- );
- if( pBar == NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- return false;
- } // if( pBar == NULL )
- ASSERT_VALID( pBar );
- p_pmed->m_pPopupMenuWnd->ItemRemove();
- pBar->OnInitDbsMenu(
- p_pmed->m_pPopupMenuWnd,
- pBar->m_hWnd,
- pBar
- );
- lResult = 1L;
- return true;
- } // if( ...
- return false;
- } // if( nMessage == CExtControlBar::g_nMsgConstructPopupMenu )
- break; // default
- } // switch( nMessage )
- }
- return
- CExtHookSink::OnHookWndMsg(
- lResult,
- hWndHooked,
- nMessage,
- wParam,
- lParam
- );
- }
- bool CExtDynamicBarHookSink::OnPreparePopupMenu( CExtPopupMenuWnd * pPopup )
- {
- ASSERT( this != NULL );
- ASSERT_VALID( pPopup );
- CExtDynamicBarSite * pDBS = GetBarSite();
- if( pDBS == NULL )
- return false;
- CFrameWnd * pDockSite = pDBS->DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return false;
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite * pSite =
- CExtCustomizeSite::GetCustomizeSite( pDockSite->GetSafeHwnd() );
- if( pSite != NULL
- && pSite->IsCustomizeMode()
- )
- return false;
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- if( CExtControlBar::FindHelpMode( pDockSite ) )
- return false;
- return pDBS->OnPreparePopupMenu( pPopup );
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtDynamicBarSite
- const UINT CExtDynamicBarSite::g_nMsgFindDynamicBarSite =
- ::RegisterWindowMessage(
- _T("CExtDynamicBarSite::g_nMsgFindDynamicBarSite")
- );
- CExtDynamicBarSite::CExtDynamicBarSite()
- : m_pDockSite( NULL )
- , m_eDUIT( CExtDynamicBarSite::__EDUIT_NOT_DETECTED_YET )
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- , m_pWndTabPageContainer( NULL )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- , m_pWndMdiTabs( NULL )
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- , m_hWndMdiClient( NULL )
- , m_nBarListInMenusCmdID( 0 )
- {
- m_DbsHookSink.m_pDBS = this;
- }
- CExtDynamicBarSite::~CExtDynamicBarSite()
- {
- }
- CExtDynamicBarSite::eDetectedUiType_t CExtDynamicBarSite::GetDetectedUiType() const
- {
- ASSERT( this != NULL );
- if( m_eDUIT != __EDUIT_NOT_DETECTED_YET )
- {
- ASSERT(
- __EDUIT_VALID_VALUE_MIN <= m_eDUIT
- && m_eDUIT <= __EDUIT_VALID_VALUE_MAX
- );
- return m_eDUIT;
- }
- const CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return __EDUIT_UNSUPPORTED_ENVIRONMENT;
- ASSERT_VALID( pDockSite );
- m_hWndMdiClient =
- CExtControlBar::stat_FindMdiClientHWND(
- pDockSite->m_hWnd
- );
- if( pDockSite->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) )
- || m_hWndMdiClient != NULL
- )
- {
- m_eDUIT = __EDUIT_MDI_ORDINARY;
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- HWND hWnd = ::GetWindow( pDockSite->m_hWnd, GW_CHILD );
- for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
- {
- if( hWnd == m_hWndMdiClient )
- continue;
- CWnd * pWnd =
- CWnd::FromHandlePermanent( hWnd );
- if( pWnd == NULL )
- continue;
- CExtTabWnd * pWndTab =
- DYNAMIC_DOWNCAST(
- CExtTabWnd,
- pWnd
- );
- if( pWndTab == NULL
- || (! pWndTab->_IsMdiTabCtrl() )
- )
- continue;
- m_pWndMdiTabs = pWndTab;
- m_eDUIT = __EDUIT_MDI_WITH_TABS;
- break;
- } // for( ; hWnd != NULL; hWnd = ::GetWindow( hWnd, GW_HWNDNEXT ) )
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- } // if( pDockSite->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) ...
- else
- {
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- HWND hWndCenter =
- ::GetDlgItem(
- pDockSite->m_hWnd,
- AFX_IDW_PANE_FIRST
- );
- if( hWndCenter == NULL )
- return __EDUIT_UNSUPPORTED_ENVIRONMENT;
- CWnd * pWndCenter =
- CWnd::FromHandlePermanent( hWndCenter );
- if( pWndCenter == NULL )
- return __EDUIT_UNSUPPORTED_ENVIRONMENT;
- m_pWndTabPageContainer =
- DYNAMIC_DOWNCAST(
- CExtTabPageContainerWnd,
- pWndCenter
- );
- if( m_pWndTabPageContainer == NULL )
- return __EDUIT_UNSUPPORTED_ENVIRONMENT;
- m_eDUIT = __EDUIT_SDI_TAB_PAGE_CONTAINER;
- #else
- m_eDUIT = __EDUIT_UNSUPPORTED_ENVIRONMENT;
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- } // else from if( pDockSite->IsKindOf( RUNTIME_CLASS(CMDIFrameWnd) ) ...
- return m_eDUIT;
- }
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- CExtTabPageContainerWnd * CExtDynamicBarSite::GetTabPageContainer()
- {
- ASSERT( this != NULL );
- if( m_eDUIT == __EDUIT_NOT_DETECTED_YET )
- GetDetectedUiType();
- return m_pWndTabPageContainer;
- }
- const CExtTabPageContainerWnd * CExtDynamicBarSite::GetTabPageContainer() const
- {
- ASSERT( this != NULL );
- if( m_eDUIT == __EDUIT_NOT_DETECTED_YET )
- GetDetectedUiType();
- return m_pWndTabPageContainer;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- CExtTabWnd * CExtDynamicBarSite::GetMdiTabs()
- {
- ASSERT( this != NULL );
- if( m_eDUIT == __EDUIT_NOT_DETECTED_YET )
- GetDetectedUiType();
- return m_pWndMdiTabs;
- }
- const CExtTabWnd * CExtDynamicBarSite::GetMdiTabs() const
- {
- ASSERT( this != NULL );
- if( m_eDUIT == __EDUIT_NOT_DETECTED_YET )
- GetDetectedUiType();
- return m_pWndMdiTabs;
- }
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- HWND CExtDynamicBarSite::GetMdiClient() const
- {
- ASSERT( this != NULL );
- if( m_eDUIT == __EDUIT_NOT_DETECTED_YET )
- GetDetectedUiType();
- return m_hWndMdiClient;
- }
- CExtDynamicBarSite * CExtDynamicBarSite::FindBarSite(
- HWND hWnd
- )
- {
- if( hWnd == NULL || (! ::IsWindow(hWnd) ) )
- return NULL;
- CWnd * pWnd = CWnd::FromHandlePermanent( hWnd );
- if( pWnd != NULL )
- {
- CFrameWnd * pFrame = NULL;
- pFrame = DYNAMIC_DOWNCAST( CFrameWnd, pWnd );
- if( pFrame == NULL )
- {
- CExtDynamicControlBar * pBar =
- DYNAMIC_DOWNCAST( CExtDynamicControlBar, pWnd );
- if( pBar != NULL )
- pFrame = pBar->m_pDockSite;
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- else
- {
- CExtDynamicTabbedControlBar * pTabbedBar =
- DYNAMIC_DOWNCAST( CExtDynamicTabbedControlBar, pWnd );
- if( pTabbedBar != NULL )
- pFrame = pTabbedBar->m_pDockSite;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- } // if( pFrame == NULL )
- if( pFrame == NULL )
- pFrame = pWnd->GetParentFrame();
- if( pFrame != NULL )
- {
- if( pFrame->IsKindOf( RUNTIME_CLASS(CExtMiniDockFrameWnd) ) )
- pFrame = pFrame->GetParentFrame();
- if( pFrame != NULL )
- {
- CExtDynamicBarSite * pDBS = NULL;
- pFrame->SendMessage( g_nMsgFindDynamicBarSite, WPARAM(&pDBS) );
- if( pDBS != NULL )
- return pDBS;
- } // if( pFrame != NULL )
- } // if( pFrame != NULL )
- }
- for( ; hWnd != NULL; hWnd = ::GetParent( hWnd ) )
- {
- CExtDynamicBarSite * pDBS = NULL;
- ::SendMessage( hWnd, g_nMsgFindDynamicBarSite, WPARAM(&pDBS), 0L );
- if( pDBS != NULL )
- return pDBS;
- } // for( ; hWnd != NULL; hWnd = ::GetParent( hWnd ) )
- return NULL;
- }
- CExtDynamicBarSite * CExtDynamicBarSite::FindBarSite(
- CWnd * pWnd
- )
- {
- HWND hWnd = pWnd->GetSafeHwnd();
- if( hWnd == NULL )
- return NULL;
- return FindBarSite( hWnd );
- }
- CFrameWnd * CExtDynamicBarSite::DockSiteGet()
- {
- ASSERT( this != NULL );
- return m_pDockSite;
- }
- HWND CExtDynamicBarSite::GetActiveMdiChildFrameHWND(
- bool * p_bMaximized, // = NULL
- CMDIChildWnd ** ppMDIChildWnd // = NULL
- )
- {
- ASSERT( this != NULL );
- if( p_bMaximized != NULL)
- (*p_bMaximized) = false;
- if( ppMDIChildWnd != NULL)
- (*ppMDIChildWnd) = NULL;
- HWND hWndMDIClient = GetMdiClient();
- if( hWndMDIClient == NULL )
- return NULL;
- BOOL bMaximized = FALSE;
- HWND hWndActiveMdiChildFrame = (HWND)
- ::SendMessage(
- hWndMDIClient,
- WM_MDIGETACTIVE,
- 0,
- (LPARAM)&bMaximized
- );
- if( p_bMaximized != NULL)
- (*p_bMaximized) = bMaximized ? true : false;
- if( hWndActiveMdiChildFrame == NULL )
- return NULL;
- CWnd * pWndPermanent =
- CWnd::FromHandlePermanent( hWndActiveMdiChildFrame );
- if( pWndPermanent == NULL )
- return hWndActiveMdiChildFrame;
- CMDIChildWnd * pMDIChildWnd =
- DYNAMIC_DOWNCAST(
- CMDIChildWnd,
- pWndPermanent
- );
- if( pMDIChildWnd == NULL )
- return hWndActiveMdiChildFrame;
- if( pMDIChildWnd->m_bPseudoInactive
- && (pMDIChildWnd->GetStyle() & WS_VISIBLE) == 0
- )
- {
- if( p_bMaximized != NULL)
- (*p_bMaximized) = false;
- }
- else if( ppMDIChildWnd != NULL )
- (*ppMDIChildWnd) = pMDIChildWnd;
- return hWndActiveMdiChildFrame;
- }
- const CFrameWnd * CExtDynamicBarSite::DockSiteGet() const
- {
- ASSERT( this != NULL );
- return m_pDockSite;
- }
- void CExtDynamicBarSite::Install( CFrameWnd * pDockSite )
- {
- ASSERT( this != NULL );
- ASSERT( m_pDockSite == NULL );
- m_pDockSite = pDockSite;
- ASSERT_VALID( m_pDockSite );
- ASSERT(
- m_pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( m_pDockSite->GetSafeHwnd() )
- );
- m_DbsHookSink.SetupHookWndSink( m_pDockSite->GetSafeHwnd() );
- }
- BOOL CExtDynamicBarSite::OnCmdMsg(
- UINT nID,
- int nCode,
- void * pExtra,
- AFX_CMDHANDLERINFO * pHandlerInfo
- )
- {
- ASSERT( this != NULL );
- pHandlerInfo;
- if( nCode == CN_COMMAND || nCode == CN_UPDATE_COMMAND_UI )
- {
- POSITION pos = BarEnumGetStartPosition();
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- if( UINT(pBar->GetDlgCtrlID()) == nID )
- return
- OnCmdMsgOneBar(
- pBar,
- nCode,
- pExtra,
- pHandlerInfo
- );
- } // for( ; pos != NULL; )
- } // if( nCode == CN_COMMAND || nCode == CN_UPDATE_COMMAND_UI )
- return FALSE;
- }
- BOOL CExtDynamicBarSite::OnCmdMsgOneBar(
- CExtDynamicControlBar * pBar,
- int nCode,
- void * pExtra,
- AFX_CMDHANDLERINFO * pHandlerInfo
- )
- {
- ASSERT_VALID( pBar );
- pHandlerInfo;
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return FALSE;
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- if( nCode == CN_COMMAND )
- {
- CExtDynamicControlBar::eDynamicBarState_t eDBS =
- pBar->BarStateGet();
- if( eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT )
- {
- pBar->BarStateSet( eDBS, true );
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( GetDetectedUiType() == __EDUIT_SDI_TAB_PAGE_CONTAINER )
- {
- HWND hWndChild = pBar->OnQueryChildHWND();
- CExtTabPageContainerWnd * pWndTabPageContainer =
- GetTabPageContainer();
- if( pWndTabPageContainer != NULL
- && hWndChild != NULL
- && ::IsWindow( hWndChild )
- )
- {
- int nPageCount =
- pWndTabPageContainer->PageGetCount();
- for( int nPageIdx = 0; nPageIdx < nPageCount; nPageIdx++ )
- {
- HWND hWnd =
- pWndTabPageContainer->PageHwndGetSafe(
- nPageIdx
- );
- if( hWnd == hWndChild )
- {
- int nSelIdx =
- pWndTabPageContainer->PageSelectionGet();
- if( nSelIdx != nPageIdx )
- pWndTabPageContainer->PageSelectionSet( nPageIdx );
- break;
- } // if( hWnd == hWndChild )
- } // for( int nPageIdx = 0; nPageIdx < nPageCount; nPageIdx++ )
- }
- } // if( GetDetectedUiType() == __EDUIT_SDI_TAB_PAGE_CONTAINER )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- } // if( eDBS == CExtDynamicControlBar::__EDBS_DOCUMENT )
- else
- CExtControlBar::DoFrameBarCheckCmd(
- pDockSite,
- UINT( pBar->GetDlgCtrlID() ),
- OnDbsQueryUseCheckMarkCommand( pBar )
- );
- } // if( nCode == CN_COMMAND )
- else
- CExtControlBar::DoFrameBarCheckUpdate(
- pDockSite,
- (CCmdUI*)pExtra,
- OnDbsQueryUseCheckMarkCommand( pBar )
- );
- return TRUE;
- }
- CExtDynamicMDIChildWnd * CExtDynamicBarSite::OnDbsCreateDynamicMDIChildWndInstance(
- CExtDynamicControlBar * pBar
- )
- {
- ASSERT_VALID( pBar );
- CExtDynamicMDIChildWnd * pWndMdiChild = new CExtNCW < CExtDynamicMDIChildWnd >;
- pWndMdiChild->AttachBar( pBar );
- return pWndMdiChild;
- }
- bool CExtDynamicBarSite::OnDbsQueryUseCheckMarkCommand(
- CExtDynamicControlBar * pBar
- )
- {
- ASSERT_VALID( pBar );
- return pBar->OnQueryUseCheckMarkCommand();
- }
- bool CExtDynamicBarSite::StateSerialize(
- CArchive & ar,
- bool bEnableThrowExceptions // = false
- )
- {
- ASSERT( this != NULL );
- DWORD dwGeneralFlags = 0;
- DWORD dwReserved = 0L;
- try
- {
- if( ar.IsStoring() )
- {
- ar << dwGeneralFlags;
- ar << dwReserved;
- ar << dwReserved;
- ar << dwReserved;
- ar << dwReserved;
- DWORD dwCount = (DWORD)BarEnumGetCount();
- ar << dwCount;
- POSITION pos = BarEnumGetStartPosition();
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- bool bVisibleState = false;
- if( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT )
- {
- if( bVisibleState )
- {
- ASSERT( m_listBarsInDocMode.Find( pBar ) != NULL );
- continue;
- }
- }
- ASSERT( m_listBarsInDocMode.Find( pBar ) == NULL );
- UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
- ar << DWORD(nCmdID);
- bool bPersistentBar = pBar->IsPersistentBar();
- DWORD dwSerializeFlags = 0;
- if( bPersistentBar )
- dwSerializeFlags |= 0x01;
- ar << dwSerializeFlags;
- if( ! bPersistentBar )
- {
- CRuntimeClass * pRTC = pBar->GetRuntimeClass();
- ASSERT( pRTC != NULL );
- ar.WriteClass( pRTC );
- } // if( ! bPersistentBar )
- ar << pBar->m_strCaptionText;
- pBar->m_icon.Serialize( ar );
- pBar->OnSerializeDynamicProps( ar );
- } // for( ; pos != NULL; )
- CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listSerialize;
- bool bUseDefaultOrder = true;
- CExtDynamicBarSite::eDetectedUiType_t eDUIT = GetDetectedUiType();
- eDUIT;
- #if (!defined __EXT_MFC_NO_TABMDI_CTRL)
- if( eDUIT == __EDUIT_MDI_WITH_TABS )
- { // detect MDI order using tabs
- CExtTabWnd * pTabs = GetMdiTabs();
- if( pTabs != NULL )
- {
- LONG nIndex, nCount = pTabs->ItemGetCount();
- for( nIndex = 0L; nIndex < nCount; nIndex ++ )
- {
- HWND hWnd = (HWND)pTabs->ItemGet( nIndex )->LParamGet();
- CWnd * pWndPremanent = CWnd::FromHandlePermanent( hWnd );
- if( pWndPremanent == NULL )
- continue;
- CExtDynamicMDIChildWnd * pWndMdiChild = DYNAMIC_DOWNCAST( CExtDynamicMDIChildWnd, pWndPremanent );
- if( pWndMdiChild == NULL )
- continue;
- if( pWndMdiChild->GetBarSite() != this )
- continue;
- CExtDynamicControlBar * pBar = pWndMdiChild->GetBar();
- if( pBar == NULL )
- continue;
- if( m_listBarsInDocMode.Find( pBar ) == NULL )
- continue;
- _listSerialize.AddTail( pBar );
- } // for( nIndex = 0L; nIndex < nCount; nIndex ++ )
- if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
- bUseDefaultOrder = false;
- else
- _listSerialize.RemoveAll();
- } // if( pTabs != NULL )
- } // detect MDI order using tabs
- #endif // (!defined __EXT_MFC_NO_TABMDI_CTRL)
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( eDUIT == __EDUIT_SDI_TAB_PAGE_CONTAINER )
- { // detect document mode order using SDI tab page container
- CExtTabPageContainerWnd * pWndTabPageContainer = GetTabPageContainer();
- if( pWndTabPageContainer->GetSafeHwnd() != NULL )
- {
- ASSERT_VALID( pWndTabPageContainer );
- CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listFound;
- INT nIndex = 0, nCount = pWndTabPageContainer->PageGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- HWND hWndPage = pWndTabPageContainer->PageHwndGetSafe( nIndex );
- if( hWndPage == NULL )
- continue;
- CExtDynamicControlBar * pBar = BarFindByChildHWND( hWndPage );
- if( pBar == NULL )
- continue;
- ASSERT_VALID( pBar );
- #ifdef _DEBUG
- bool bVisibleState = false;
- ASSERT( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT );
- ASSERT( bVisibleState );
- #endif // _DEBUG
- if( m_listBarsInDocMode.Find( pBar ) == NULL )
- continue;
- _listSerialize.AddTail( pBar );
- }
- if( _listSerialize.GetCount() == m_listBarsInDocMode.GetCount() )
- bUseDefaultOrder = false;
- else
- _listSerialize.RemoveAll();
- }
- } // detect document mode order using SDI tab page container
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( bUseDefaultOrder )
- _listSerialize.AddTail( &m_listBarsInDocMode );
- //pos = m_listBarsInDocMode.GetTailPosition();
- pos = _listSerialize.GetTailPosition();
- for( ; pos != NULL; )
- {
- //CExtDynamicControlBar * pBar = m_listBarsInDocMode.GetPrev( pos );
- CExtDynamicControlBar * pBar = _listSerialize.GetPrev( pos );
- ASSERT_VALID( pBar );
- ASSERT( pBar->BarStateGet() == CExtDynamicControlBar::__EDBS_DOCUMENT );
- UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
- ar << DWORD(nCmdID);
- bool bPersistentBar = pBar->IsPersistentBar();
- DWORD dwSerializeFlags = 0;
- if( bPersistentBar )
- dwSerializeFlags |= 0x01;
- ar << dwSerializeFlags;
- if( ! bPersistentBar )
- {
- CRuntimeClass * pRTC = pBar->GetRuntimeClass();
- ASSERT( pRTC != NULL );
- ar.WriteClass( pRTC );
- } // if( ! bPersistentBar )
- ar << pBar->m_strCaptionText;
- pBar->m_icon.Serialize( ar );
- pBar->OnSerializeDynamicProps( ar );
- } // for( ; pos != NULL; )
- } // if( ar.IsStoring() )
- else
- {
- ar >> dwGeneralFlags;
- ar >> dwReserved;
- ar >> dwReserved;
- ar >> dwReserved;
- ar >> dwReserved;
- BarFreeAll( false, true );
- m_listBarsInDocMode.RemoveAll();
- ASSERT( BarEnumGetCount( false, true ) == 0 );
- DWORD dwCount;
- ar >> dwCount;
- for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
- {
- UINT nCmdID;
- DWORD dwTmp;
- ar >> dwTmp;
- nCmdID = UINT(dwTmp);
- DWORD dwSerializeFlags;
- ar >> dwSerializeFlags;
- CExtDynamicControlBar * pBar = NULL;
- if( (dwSerializeFlags & 0x01) != 0 )
- { // if serializing persistent bar
- pBar = BarGetByCmdID( nCmdID );
- if( pBar == NULL )
- {
- ASSERT( FALSE );
- BarFreeAll( false, true );
- #if _MFC_VER >= 0x0800
- ::AfxThrowArchiveException( CArchiveException::genericException );
- #else
- ::AfxThrowArchiveException( CArchiveException::generic );
- #endif
- } // if( pBar == NULL )
- ASSERT_VALID( pBar );
- ar >> pBar->m_strCaptionText;
- pBar->m_icon.Serialize( ar );
- } // if serializing persistent bar
- else
- { // if serializing dynamic bar
- CRuntimeClass * pRTC = ar.ReadClass();
- ASSERT( pRTC != NULL );
- CExtSafeString strCaptionText;
- ar >> strCaptionText;
- CExtCmdIcon icon;
- icon.Serialize( ar );
- pBar =
- BarAlloc(
- strCaptionText,
- icon,
- nCmdID,
- pRTC
- );
- if( pBar == NULL )
- {
- ASSERT( FALSE );
- BarFreeAll( false, true );
- #if _MFC_VER >= 0x0800
- ::AfxThrowArchiveException( CArchiveException::genericException );
- #else
- ::AfxThrowArchiveException( CArchiveException::generic );
- #endif
- } // if( pBar == NULL )
- } // if serializing dynamic bar
- ASSERT_VALID( pBar );
- pBar->OnSerializeDynamicProps( ar );
- } // for( DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++ )
- ASSERT( ((DWORD)BarEnumGetCount()) == dwCount );
- } // else from if( ar.IsStoring() )
- return true;
- } // try
- catch( CException * pException )
- {
- if( bEnableThrowExceptions )
- throw;
- pException->Delete();
- } // catch( CException * pException )
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- } // catch( ... )
- dwGeneralFlags;
- dwReserved;
- return false;
- }
- bool CExtDynamicBarSite::StateLoad(
- __EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USERSoftware
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%%sSectionNameProfile%
- HKEY hKeyRoot, // = HKEY_CURRENT_USER
- bool bEnableThrowExceptions // = false
- )
- {
- ASSERT( this != NULL );
- ASSERT( sSectionNameCompany != NULL );
- ASSERT( sSectionNameProduct != NULL );
- ASSERT( sSectionNameProfile != NULL );
- const CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- {
- if( bEnableThrowExceptions )
- ::AfxThrowUserException();
- return false;
- }
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- CExtSafeString sRegKeyPath =
- CExtCmdManager::GetSubSystemRegKeyPath(
- __PROF_UIS_REG_DBS,
- sSectionNameProfile,
- sSectionNameCompany,
- sSectionNameProduct
- );
- try
- {
- CMemFile _file;
- if( ! CExtCmdManager::FileObjFromRegistry(
- _file,
- sRegKeyPath,
- hKeyRoot,
- bEnableThrowExceptions
- )
- )
- return false;
- CArchive ar(
- &_file,
- CArchive::load
- );
- if( ! StateSerialize( ar ) )
- return false;
- return true;
- } // try
- catch( CException * pXept )
- {
- if( bEnableThrowExceptions )
- throw;
- pXept->Delete();
- //ASSERT( FALSE );
- } // catch( CException * pXept )
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- //ASSERT( FALSE );
- } // catch( ... )
- return false;
- }
- bool CExtDynamicBarSite::StateSave(
- __EXT_MFC_SAFE_LPCTSTR sSectionNameCompany, // under HKEY_CURRENT_USERSoftware
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProduct, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%
- __EXT_MFC_SAFE_LPCTSTR sSectionNameProfile, // under HKEY_CURRENT_USERSoftware%sSectionNameCompany%%sSectionNameProfile%
- HKEY hKeyRoot, // = HKEY_CURRENT_USER
- bool bEnableThrowExceptions // = false
- )
- {
- ASSERT( this != NULL );
- ASSERT( sSectionNameCompany != NULL );
- ASSERT( sSectionNameProduct != NULL );
- ASSERT( sSectionNameProfile != NULL );
- const CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- {
- if( bEnableThrowExceptions )
- ::AfxThrowUserException();
- return false;
- }
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- CExtSafeString sRegKeyPath =
- CExtCmdManager::GetSubSystemRegKeyPath(
- __PROF_UIS_REG_DBS,
- sSectionNameProfile,
- sSectionNameCompany,
- sSectionNameProduct
- );
- try
- {
- CMemFile _file;
- CArchive ar(
- &_file,
- CArchive::store
- );
- if( ! StateSerialize( ar ) )
- return false;
- ar.Flush();
- ar.Close();
- if( ! CExtCmdManager::FileObjToRegistry(
- _file,
- sRegKeyPath,
- hKeyRoot,
- bEnableThrowExceptions
- )
- )
- return false;
- return true;
- } // try
- catch( CException * pXept )
- {
- if( bEnableThrowExceptions )
- throw;
- pXept->Delete();
- //ASSERT( FALSE );
- } // catch( CException * pXept )
- catch( ... )
- {
- if( bEnableThrowExceptions )
- throw;
- //ASSERT( FALSE );
- } // catch( ... )
- return false;
- }
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- bool CExtDynamicBarSite::OnTabPageContainerClickedButton(
- LONG nHitTest,
- bool bButtonPressed,
- INT nMouseButton, // MK_... values
- UINT nMouseEventFlags
- )
- {
- ASSERT( this != NULL );
- ASSERT( GetDetectedUiType() == __EDUIT_SDI_TAB_PAGE_CONTAINER );
- CExtTabPageContainerWnd * pWndTabPageContainer = GetTabPageContainer();
- ASSERT_VALID( pWndTabPageContainer );
- nMouseButton;
- nMouseEventFlags;
- nHitTest;
- if( bButtonPressed
- || nMouseButton != MK_LBUTTON
- || nHitTest != __ETWH_BUTTON_CLOSE
- || pWndTabPageContainer->PageGetCount() == 0
- )
- return true;
- int nSel = pWndTabPageContainer->PageSelectionGet();
- if( nSel < 0 )
- return true;
- HWND hWndChild =
- pWndTabPageContainer->PageHwndGetSafe( nSel );
- if( hWndChild == NULL )
- return true;
- ASSERT( ::IsWindow( hWndChild ) );
- CExtDynamicControlBar * pBar =
- BarFindByChildHWND( hWndChild );
- if( pBar == NULL )
- return true;
- if( ! pBar->_ClosingIsEnabled( pBar ) )
- return true;
- pBar->BarStateSet(
- CExtDynamicControlBar::__EDBS_DOCUMENT,
- false
- );
- return true;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- bool CExtDynamicBarSite::OnPreparePopupMenu( CExtPopupMenuWnd * pPopup )
- {
- ASSERT( this != NULL );
- ASSERT_VALID( pPopup );
- if( m_nBarListInMenusCmdID == 0 )
- return false;
- bool bRetVal = false;
- INT nItemCount = pPopup->ItemGetCount();
- for( INT nItemIndex = 0; nItemIndex < nItemCount; )
- {
- CExtPopupMenuWnd::MENUITEMDATA & _mii =
- pPopup->ItemGetInfo( nItemIndex );
- if( _mii.IsSeparator() )
- {
- nItemIndex ++;
- continue;
- }
- if( _mii.IsPopup() )
- {
- CExtPopupMenuWnd * pSubPopup =
- _mii.GetPopup();
- ASSERT_VALID( pSubPopup );
- if( OnPreparePopupMenu( pSubPopup ) )
- bRetVal = true;
- nItemIndex ++;
- continue;
- }
- UINT nCmdID = _mii.GetCmdID();
- if( nCmdID != m_nBarListInMenusCmdID )
- {
- nItemIndex ++;
- continue;
- }
- pPopup->ItemRemove( nItemIndex );
- nItemCount--;
- if( nItemIndex > 0
- && pPopup->ItemGetInfo(nItemIndex-1).IsSeparator()
- )
- {
- nItemIndex--;
- nItemCount--;
- pPopup->ItemRemove( nItemIndex );
- }
- INT nInsertedCount =
- OnPrepareBarsListInMenu(
- pPopup,
- nItemIndex
- );
- if( nInsertedCount == 0 )
- continue;
- bRetVal = true;
- if( nItemIndex > 0
- && (! pPopup->ItemGetInfo(nItemIndex-1).IsSeparator() )
- )
- {
- pPopup->ItemInsert( ID_SEPARATOR, nItemIndex );
- nItemIndex++;
- nItemCount++;
- }
- nItemIndex += nInsertedCount;
- nItemCount += nInsertedCount;
- } // for( INT nItemIndex = 0; nItemIndex < nItemCount; )
- return bRetVal;
- }
- INT CExtDynamicBarSite::OnPrepareBarsListInMenu(
- CExtPopupMenuWnd * pPopup,
- INT nInsertPos
- )
- {
- ASSERT( this != NULL );
- ASSERT_VALID( pPopup );
- ASSERT( 0 <= nInsertPos && nInsertPos <= pPopup->ItemGetCount() );
- POSITION pos = BarEnumGetStartPosition();
- INT nInsertedCount = 0;
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- ASSERT( pBar->GetSafeHwnd() != NULL );
- ASSERT_VALID( pBar->m_pDockBar );
- ASSERT( pBar->m_pDockSite == DockSiteGet() );
- if( pBar->OnInsertDynamicBarCommandIntoPopupMenu(
- pPopup,
- nInsertPos + nInsertedCount
- )
- )
- nInsertedCount++;
- } // for( ; pos != NULL; )
- return nInsertedCount;
- }
- UINT CExtDynamicBarSite::OnDbsAllocNewBarCommandID(
- __EXT_MFC_SAFE_LPCTSTR strCaptionText,
- const CExtCmdIcon & icon,
- UINT nDesiredCmdID // = 0
- ) const
- {
- ASSERT( this != NULL );
- const CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return 0;
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd(
- pDockSite->GetSafeHwnd()
- );
- if( strProfileName == NULL )
- return 0;
- CExtCmdItem * pCmdItem =
- g_CmdManager->CmdAllocPtr(
- strProfileName,
- nDesiredCmdID
- );
- if( pCmdItem == NULL )
- return 0;
- if( strCaptionText != NULL )
- {
- pCmdItem->m_sMenuText = strCaptionText;
- pCmdItem->m_sToolbarText = strCaptionText;
- } // if( strCaptionText != NULL )
- if( ! icon.IsEmpty() )
- g_CmdManager->CmdSetIcon(
- strProfileName,
- pCmdItem->m_nCmdID,
- icon
- );
- return pCmdItem->m_nCmdID;
- }
- void CExtDynamicBarSite::OnDbsFreeBarCommandID( UINT nCmdID ) const
- {
- ASSERT( this != NULL );
- const CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- LPCTSTR strProfileName =
- g_CmdManager->ProfileNameFromWnd(
- pDockSite->GetSafeHwnd()
- );
- if( strProfileName == NULL )
- return;
- g_CmdManager->CmdSetIcon( strProfileName, nCmdID, (HICON)NULL );
- g_CmdManager->CmdRemove( strProfileName, nCmdID );
- }
- void CExtDynamicBarSite::OnDbsResetPageSequence()
- {
- ASSERT( this != NULL );
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- if( GetDetectedUiType() == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- {
- CExtTabPageContainerWnd * pWndTabPageContainer = GetTabPageContainer();
- if( pWndTabPageContainer->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( pWndTabPageContainer );
- CTypedPtrList < CPtrList, CExtDynamicControlBar * > _listFound;
- INT nIndex = 0, nCount = pWndTabPageContainer->PageGetCount();
- for( nIndex = 0; nIndex < nCount; nIndex ++ )
- {
- HWND hWndPage = pWndTabPageContainer->PageHwndGetSafe( nIndex );
- if( hWndPage == NULL )
- continue;
- CExtDynamicControlBar * pBar = BarFindByChildHWND( hWndPage );
- if( pBar == NULL )
- continue;
- ASSERT_VALID( pBar );
- #ifdef _DEBUG
- bool bVisibleState = false;
- ASSERT( pBar->BarStateGet( &bVisibleState ) == CExtDynamicControlBar::__EDBS_DOCUMENT );
- ASSERT( bVisibleState );
- #endif // _DEBUG
- ASSERT( m_listBarsInDocMode.Find( pBar ) != NULL );
- _listFound.AddTail( pBar );
- }
- if( _listFound.GetCount() == m_listBarsInDocMode.GetCount() )
- {
- m_listBarsInDocMode.RemoveAll();
- m_listBarsInDocMode.AddTail( &_listFound );
- ASSERT( _listFound.GetCount() == m_listBarsInDocMode.GetCount() );
- }
- return;
- } // if( GetDetectedUiType() == CExtDynamicBarSite::__EDUIT_SDI_TAB_PAGE_CONTAINER )
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- }
- CExtDynamicControlBar * CExtDynamicBarSite::OnDbsCreateNewBarInstance() const
- {
- ASSERT( this != NULL );
- return new CExtDynamicControlBar;
- }
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- CExtDynamicTabbedControlBar * CExtDynamicBarSite::OnDbsCreateTabbedBarInstance() const
- {
- ASSERT( this != NULL );
- CExtDynamicTabbedControlBar * pBar = new CExtDynamicTabbedControlBar;
- return pBar;
- }
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- //CExtDynamicControlBar * CExtDynamicBarSite::BarFindAnyVisible()
- //{
- // ASSERT( this != NULL );
- //CFrameWnd * pDockSite = DockSiteGet();
- // if( pDockSite->GetSafeHwnd() == NULL )
- // return NULL;
- // ASSERT_VALID( pDockSite );
- // ASSERT(
- // pDockSite->GetSafeHwnd() != NULL
- // && ::IsWindow( pDockSite->GetSafeHwnd() )
- // );
- //POSITION pos = BarEnumGetStartPosition();
- // for( ; pos != NULL; )
- // {
- // ASSERT( pos != NULL );
- // CExtDynamicControlBar * pBar =
- // BarEnumGetNext( pos );
- // ASSERT_VALID( pBar );
- // ASSERT( pBar->GetSafeHwnd() != NULL );
- // ASSERT_VALID( pBar->m_pDockBar );
- // ASSERT( pBar->m_pDockSite == pDockSite );
- // if( pBar->AutoHideModeGet() )
- // continue;
- // if( ! pBar->IsVisible() )
- // continue;
- // return pBar;
- // } // for( ; pos != NULL; )
- // return NULL;
- //}
- CExtDynamicControlBar * CExtDynamicBarSite::BarFindByChildHWND( HWND hWndChildToFind )
- {
- ASSERT( this != NULL );
- ASSERT( hWndChildToFind != NULL && ::IsWindow( hWndChildToFind ) );
- POSITION pos = BarEnumGetStartPosition();
- for( ; pos != NULL; )
- {
- ASSERT( pos != NULL );
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- ASSERT( pBar->GetSafeHwnd() != NULL );
- ASSERT_VALID( pBar->m_pDockBar );
- HWND hWnd = pBar->OnQueryChildHWND();
- if( hWnd == NULL )
- continue;
- if( hWndChildToFind == hWnd )
- return pBar;
- } // for( ; pos != NULL; )
- return NULL;
- }
- CExtDynamicControlBar * CExtDynamicBarSite::BarAlloc(
- __EXT_MFC_SAFE_LPCTSTR strCaptionText,
- const CExtCmdIcon & icon,
- UINT nDesiredCmdID, // = 0
- CRuntimeClass * pDesiredRTC, // = NULL
- bool bPersistentBar // = false
- )
- {
- ASSERT( this != NULL );
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return NULL;
- ASSERT_VALID( pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- UINT nCmdID =
- OnDbsAllocNewBarCommandID(
- strCaptionText,
- icon,
- nDesiredCmdID
- );
- if( nCmdID == 0 )
- return NULL;
- CExtDynamicControlBar * pBar =
- ( pDesiredRTC != NULL )
- ? ( (CExtDynamicControlBar *) pDesiredRTC->CreateObject() )
- : OnDbsCreateNewBarInstance()
- ;
- if( pBar == NULL )
- {
- OnDbsFreeBarCommandID( nCmdID );
- return NULL;
- }
- ASSERT_VALID( pBar );
- ASSERT_KINDOF( CExtDynamicControlBar, pBar );
- pBar->m_bPersistentBar = bPersistentBar;
- if( ! pBar->Create(
- ( strCaptionText == NULL )
- ? _T("") : strCaptionText,
- pDockSite,
- nCmdID,
- WS_CHILD //|WS_VISIBLE
- |WS_CLIPCHILDREN|WS_CLIPSIBLINGS
- |CBRS_TOP|CBRS_GRIPPER|CBRS_TOOLTIPS
- |CBRS_FLYBY|CBRS_SIZE_DYNAMIC
- |CBRS_HIDE_INPLACE
- )
- )
- {
- OnDbsFreeBarCommandID( nCmdID );
- delete pBar;
- return NULL;
- }
- pBar->m_strCaptionText =
- ( strCaptionText == NULL )
- ? _T("") : strCaptionText;
- pBar->m_icon = icon;
- //CExtDynamicControlBar * pOtherBar = BarFindAnyVisible();
- m_mapBars.SetAt( pBar, NULL );
- m_listBars.AddTail( pBar );
- pBar->EnableDocking( CBRS_ALIGN_ANY );
- // if( pOtherBar != NULL )
- // {
- // ASSERT_VALID( pOtherBar );
- // VERIFY(
- // pOtherBar->DockControlBarIntoTabbedContainer(
- // pBar,
- // -1,
- // pDockSite,
- // false
- // )
- // );
- // } // if( pOtherBar != NULL )
- // else
- {
- VERIFY(
- pBar->DockControlBarInnerOuter(
- AFX_IDW_DOCKBAR_LEFT,
- true,
- pDockSite,
- false
- )
- );
- pDockSite->ShowControlBar( pBar, FALSE, TRUE );
- } // else from if( pOtherBar != NULL )
- return pBar;
- }
- void CExtDynamicBarSite::BarFree( CExtDynamicControlBar * pBar )
- {
- ASSERT( this != NULL );
- _BarFreeImpl(
- pBar,
- false,
- false
- );
- }
- void CExtDynamicBarSite::_BarFreeImpl(
- CExtDynamicControlBar * pBar,
- bool bForceFloatMode,
- bool bForceNoOptimizeMode
- )
- {
- ASSERT( this != NULL );
- ASSERT_VALID( pBar );
- UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
- bool bPersistentBar = pBar->IsPersistentBar();
- if( pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL )
- {
- ASSERT_VALID( pBar->m_pDockSite );
- ASSERT_VALID( pBar->m_pDockBar );
- HWND hWndChild = pBar->OnQueryChildHWND();
- if( hWndChild != NULL && ::IsWindow( hWndChild ) )
- {
- //pBar->BarStateSet( CExtDynamicControlBar::__EDBS_DOCKED, false );
- HWND hWndContainer = ::GetParent( hWndChild );
- if( hWndContainer != pBar->m_hWnd )
- {
- CWnd * pWndPermanent =
- CWnd::FromHandlePermanent( hWndContainer );
- if( pWndPermanent != NULL )
- {
- CExtDynamicBarSite::eDetectedUiType_t eDUIT =
- GetDetectedUiType();
- if( eDUIT == __EDUIT_MDI_ORDINARY
- || eDUIT == __EDUIT_MDI_WITH_TABS
- )
- { // if MDI environment
- CExtDynamicMDIChildWnd * pWndMdiChild =
- DYNAMIC_DOWNCAST(
- CExtDynamicMDIChildWnd,
- pWndPermanent
- );
- if( pWndMdiChild != NULL )
- {
- pWndMdiChild->DestroyWindow();
- } // if( pWndMdiChild != NULL )
- } // if MDI environment
- #if (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- else if( eDUIT == __EDUIT_SDI_TAB_PAGE_CONTAINER )
- { // if SDI tab page container environment
- CExtTabPageContainerWnd * pWndTabPageContainer =
- DYNAMIC_DOWNCAST(
- CExtTabPageContainerWnd,
- pWndPermanent
- );
- if( pWndTabPageContainer != NULL )
- {
- int nPageCount =
- pWndTabPageContainer->PageGetCount();
- for( int nPageIdx = 0; nPageIdx < nPageCount; nPageIdx++ )
- {
- HWND hWnd =
- pWndTabPageContainer->PageHwndGetSafe(
- nPageIdx
- );
- if( hWnd == hWndChild )
- {
- pWndTabPageContainer->
- PageRemove( nPageIdx, 1, true );
- break;
- } // if( hWnd == hWndChild )
- } // for( int nPageIdx = 0; nPageIdx < nPageCount; nPageIdx++ )
- } // if( pWndTabPageContainer != NULL )
- } // if SDI tab page container environment
- #endif // (!defined __EXT_MFC_NO_TAB_PAGECONTAINER_CTRL)
- } // if( pWndPermanent != NULL )
- } // if( hWndContainer != pBar->m_hWnd )
- } // if( hWndChild != NULL && ::IsWindow( hWndChild ) )
- } // if( pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL )
- if( pBar->m_pDockBar == NULL
- || bForceFloatMode
- )
- {
- CWnd * pWnd = NULL;
- if( ! m_mapBars.Lookup( pBar, pWnd ) )
- return;
- m_mapBars.RemoveKey( pBar );
- POSITION posInList = m_listBars.Find( pBar );
- if( posInList != NULL )
- m_listBars.RemoveAt( posInList );
- posInList = m_listBarsInDocMode.Find( pBar );
- if( posInList != NULL )
- m_listBarsInDocMode.RemoveAt( posInList );
- if( pBar->m_pDockBar != NULL )
- {
- CMiniDockFrameWnd * pMiniFrame = NULL;
- CWnd * pWnd = pBar->GetParentFrame();
- if( pWnd != NULL )
- {
- pMiniFrame =
- DYNAMIC_DOWNCAST(
- CMiniDockFrameWnd,
- pBar->GetDockingFrame()
- );
- }
- int nPos = pBar->m_pDockBar->FindBar( pBar );
- if( nPos > 0 )
- {
- // VERIFY( pBar->m_pDockBar->RemoveControlBar(pBar) );
- pBar->m_pDockBar->m_arrBars.RemoveAt( nPos );
- }
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() != NULL )
- pDockSite->RemoveControlBar( pBar );
- pBar->m_pDockSite = NULL;
- pBar->m_pDockBar = NULL;
- if( pMiniFrame != NULL )
- pMiniFrame->DestroyWindow();
- else
- pBar->DestroyWindow();
- } // if( pBar->m_pDockBar != NULL )
- return;
- }
- ASSERT_VALID( pBar->m_pDockBar );
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- return;
- ASSERT_VALID( pDockSite );
- ASSERT( pBar->m_pDockSite == pDockSite );
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- CWnd * pWnd = NULL;
- if( ! m_mapBars.Lookup( pBar, pWnd ) )
- return;
- CMiniDockFrameWnd * pMiniFrame = NULL;
- if( pBar->IsFloating() )
- {
- pMiniFrame =
- DYNAMIC_DOWNCAST(
- CMiniDockFrameWnd,
- pBar->GetDockingFrame()
- );
- ASSERT_VALID( pMiniFrame );
- } // if( pBar->IsFloating() )
- else
- {
- ASSERT( ! pBar->m_pDockBar->m_bFloating );
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pBar->AutoHideModeGet() )
- {
- ASSERT_KINDOF( CExtDockBar, pBar->m_pDockBar );
- CExtDynAutoHideArea * pWndAutoHideArea =
- ((CExtDockBar*)pBar->m_pDockBar)->_GetAutoHideArea();
- ASSERT_VALID( pWndAutoHideArea );
- CExtDynAutoHideSlider * pWndSlider =
- pWndAutoHideArea->GetAutoHideSlider();
- ASSERT_VALID( pWndSlider );
- if( (pWndSlider->GetStyle()&WS_VISIBLE) != 0 )
- pWndSlider->SendMessage( WM_CANCELMODE );
- pWndAutoHideArea->RemoveControlBar( pBar, true );
- } // if( pBar->AutoHideModeGet() )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockBar)) )
- {
- #if (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- if( pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynTabBar)) )
- {
- CExtDynTabControlBar * pTabbedBar =
- STATIC_DOWNCAST(
- CExtDynTabControlBar,
- pBar->m_pDockBar->GetParent()
- );
- LONG nIdx = pTabbedBar->FindControlBar( pBar );
- if( nIdx >= 0 )
- {
- LONG nSel = pTabbedBar->GetSwitcherSelection();
- if( nIdx != nSel )
- pTabbedBar->SetSwitcherSelection( nIdx );
- pTabbedBar->RemoveSelFromSwitcher();
- } // if( nIdx >= 0 )
- } // if( pBar->m_pDockBar->IsKindOf(RUNTIME_CLASS(CExtDockDynTabBar)) )
- #endif // (!defined __EXT_MFC_NO_TAB_CONTROLBARS)
- VERIFY(
- ((CExtDockBar *)pBar->m_pDockBar)->
- RemoveControlBar( pBar, -1, 0, false )
- );
- }
- else
- {
- VERIFY( pBar->m_pDockBar->RemoveControlBar(pBar) );
- }
- } // else from if( pBar->IsFloating() )
- pDockSite->RemoveControlBar( pBar );
- pBar->m_pDockSite = NULL;
- INT nPosInDockBar = pBar->m_pDockBar->FindBar( pBar );
- if( nPosInDockBar >= 0 )
- {
- pBar->m_pDockBar->m_arrBars.RemoveAt( nPosInDockBar );
- if( nPosInDockBar > 1
- && pBar->m_pDockBar->m_arrBars[ nPosInDockBar - 1 ] == m_pDockSite
- )
- pBar->m_pDockBar->m_arrBars.RemoveAt( nPosInDockBar - 1 );
- }
- pBar->m_pDockBar = NULL;
- m_mapBars.RemoveKey( pBar );
- POSITION posInList = m_listBars.Find( pBar );
- if( posInList != NULL )
- m_listBars.RemoveAt( posInList );
- posInList = m_listBarsInDocMode.Find( pBar );
- if( posInList != NULL )
- m_listBarsInDocMode.RemoveAt( posInList );
- if( ! bPersistentBar )
- OnDbsFreeBarCommandID( nCmdID );
- if( pMiniFrame != NULL )
- pMiniFrame->DestroyWindow();
- else
- pBar->DestroyWindow();
- if( ! bForceNoOptimizeMode )
- CExtDockBar::_OptimizeCircles( pDockSite );
- }
- void CExtDynamicBarSite::BarFreeAll(
- bool bFreePersistentBars, // = true
- bool bFreeDynamicBars // = true
- )
- {
- ASSERT( this != NULL );
- _BarFreeAllImpl(
- false,
- bFreePersistentBars,
- bFreeDynamicBars
- );
- }
- void CExtDynamicBarSite::_BarFreeAllImpl(
- bool bForceNoOptimizeMode,
- bool bFreePersistentBars, // = true
- bool bFreeDynamicBars // = true
- )
- {
- ASSERT( this != NULL );
- CFrameWnd * pDockSite = DockSiteGet();
- if( pDockSite->GetSafeHwnd() == NULL )
- {
- ASSERT( BarEnumGetCount() == 0 );
- return;
- }
- ASSERT(
- pDockSite->GetSafeHwnd() != NULL
- && ::IsWindow( pDockSite->GetSafeHwnd() )
- );
- for( ; BarEnumGetCount(bFreePersistentBars,bFreeDynamicBars) > 0; )
- {
- POSITION pos = BarEnumGetStartPosition();
- ASSERT( pos != NULL );
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos, bFreePersistentBars, bFreeDynamicBars );
- ASSERT_VALID( pBar );
- _BarFreeImpl( pBar, false, bForceNoOptimizeMode );
- } // for( ; BarEnumGetCount(bFreePersistentBars,bFreeDynamicBars) > 0; )
- }
- CExtDynamicControlBar * CExtDynamicBarSite::BarGetByCmdID( UINT nLookupCmdID )
- {
- ASSERT( this != NULL );
- POSITION pos = BarEnumGetStartPosition();
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- UINT nCmdID = (UINT)pBar->GetDlgCtrlID();
- if( nCmdID == nLookupCmdID )
- return pBar;
- } // for( ; pos != NULL; )
- return NULL;
- }
- void CExtDynamicBarSite::BarEnumGetArray(
- CTypedPtrArray < CPtrArray, CExtDynamicControlBar * > & arrAllDynamicBars,
- bool bIncludePersistentBars, // = true
- bool bIncludeDynamicBars // = true
- )
- {
- ASSERT( this != NULL );
- arrAllDynamicBars.RemoveAll();
- if( (!bIncludePersistentBars) && (!bIncludeDynamicBars) )
- return;
- POSITION pos = BarEnumGetStartPosition();
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- bool bPersistentBar = pBar->IsPersistentBar();
- if( ( bIncludePersistentBars && bPersistentBar )
- || ( bIncludeDynamicBars && (!bPersistentBar) )
- )
- arrAllDynamicBars.Add( pBar );
- } // for( ; pos != NULL; )
- }
- INT CExtDynamicBarSite::BarEnumGetCount(
- bool bIncludePersistentBars, // = true
- bool bIncludeDynamicBars // = true
- ) const
- {
- ASSERT( this != NULL );
- ASSERT( INT( m_mapBars.GetCount() ) == INT( m_listBars.GetCount() ) );
- if( bIncludePersistentBars && bIncludeDynamicBars )
- return INT( m_listBars.GetCount() );
- POSITION pos = BarEnumGetStartPosition();
- INT nCount = 0;
- for( ; pos != NULL; )
- {
- const CExtDynamicControlBar * pBar =
- BarEnumGetNext( pos );
- ASSERT_VALID( pBar );
- bool bPersistentBar = pBar->IsPersistentBar();
- if( bIncludePersistentBars && bPersistentBar )
- nCount ++;
- if( bIncludeDynamicBars && (!bPersistentBar) )
- nCount ++;
- } // for( ; pos != NULL; )
- return nCount;
- }
- POSITION CExtDynamicBarSite::BarEnumGetStartPosition() const
- {
- ASSERT( this != NULL );
- return m_listBars.GetHeadPosition();
- }
- CExtDynamicControlBar * CExtDynamicBarSite::BarEnumGetNext(
- POSITION & pos,
- bool bIncludePersistentBars, // = true
- bool bIncludeDynamicBars // = true
- )
- {
- ASSERT( this != NULL );
- for( ; pos != NULL; )
- {
- CExtDynamicControlBar * pBar = m_listBars.GetNext( pos );
- ASSERT_VALID( pBar );
- bool bPersistentBar = pBar->IsPersistentBar();
- if( bIncludePersistentBars && bPersistentBar )
- return pBar;
- if( bIncludeDynamicBars && (!bPersistentBar) )
- return pBar;
- } // for( ; pos != NULL; )
- return NULL;
- }
- const CExtDynamicControlBar * CExtDynamicBarSite::BarEnumGetNext(
- POSITION & pos,
- bool bIncludePersistentBars, // = true
- bool bIncludeDynamicBars // = true
- ) const
- {
- ASSERT( this != NULL );
- return
- ( const_cast < CExtDynamicBarSite * > ( this ) ) ->
- BarEnumGetNext(
- pos,
- bIncludePersistentBars,
- bIncludeDynamicBars
- );
- }
- #endif // (!defined __EXT_MFC_NO_DYNAMIC_BAR_SITE)