ExtMenuControlBar.cpp
上传用户:sesekoo
上传日期:2020-07-18
资源大小:21543k
文件大小:129k
- return rc;
- }
- CRect CExtMenuControlBar::_GetMainFrameSysIconRect()
- {
- CRect rc;
- CRect rcWnd,rcClient,rcHelper;
- CFrameWnd * pFrame =
- _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- pFrame->GetWindowRect( &rcWnd );
- pFrame->GetClientRect( &rcClient );
- rcHelper = rcWnd;
- pFrame->ScreenToClient( &rcHelper );
- ASSERT( rcHelper.top <= rcClient.top );
- int yDiff = rcClient.top - rcHelper.top;
- rc.SetRect(
- rcWnd.left + GetSystemMetrics(SM_CYFRAME),
- rcWnd.top + GetSystemMetrics(SM_CXFRAME),
- rcWnd.left + yDiff,
- rcWnd.top + yDiff
- );
- return rc;
- }
- BOOL CExtMenuControlBar::_TrackFrameSystemMenu(
- CWnd * pFrame,
- CPoint * pPoint, // = NULL, // NULL means calc menu track area automatically
- BOOL bSelectAny, // = FALSE
- LPCRECT rcExcludeArea, // = NULL
- UINT nTrackFlags, // = (UINT)(-1)
- BOOL bCombinedMode // = FALSE
- )
- {
- _CancelFlatTracking();
- /// if( nTrackFlags == (UINT)(-1) )
- /// nTrackFlags = TPMX_BOTTOMALIGN;
- ASSERT_VALID( pFrame );
- bool bPrevTBMT = CExtToolControlBar::g_bMenuTracking;
- int nTrackingIdxOld = m_nBtnIdxMenuTracking;
- // if( g_bMenuTracking )
- CExtToolControlBar::_CloseTrackingMenus();
- // if( CExtPopupMenuWnd::IsMenuTracking() )
- // CExtPopupMenuWnd::CancelMenuTracking();
- CMenu * pSysMenu = pFrame->GetSystemMenu( FALSE );
- if( pSysMenu == NULL )
- return FALSE;
- ASSERT( ::IsMenu(pSysMenu->GetSafeHmenu()) );
- CExtPopupMenuWnd * pPopup =
- CExtPopupMenuWnd::InstantiatePopupMenu(
- GetSafeHwnd(),
- RUNTIME_CLASS(CExtPopupMenuWnd),
- this
- );
- if( ! pPopup->CreatePopupMenu(
- pFrame->GetSafeHwnd()
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- if( ! pPopup->UpdateFromMenu(
- pFrame->GetSafeHwnd(),
- pSysMenu,
- false,
- true,
- true
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- __EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( pFrame->GetSafeHwnd(), GWL_EXSTYLE );
- bool bRTL = ( (dwExStyle & WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- CPoint point;
- if( pPoint != NULL)
- point = *pPoint;
- else
- {
- CRect rcWnd,rcClient,rcHelper;
- pFrame->GetWindowRect( &rcWnd );
- pFrame->GetClientRect( &rcClient );
- rcHelper = rcWnd;
- pFrame->ScreenToClient( &rcHelper );
- //ASSERT( rcHelper.top <= rcClient.top );
- int yDiff = rcClient.top - rcHelper.top;
- int n = 0;
- WINDOWPLACEMENT _wp;
- ::memset( &_wp, 0, sizeof(WINDOWPLACEMENT) );
- _wp.length = sizeof(WINDOWPLACEMENT);
- VERIFY(
- ::GetWindowPlacement(
- GetSafeHwnd(),
- &_wp
- )
- );
- if( _wp.showCmd != SW_SHOWMAXIMIZED )
- n = ::GetSystemMetrics( SM_CXFRAME );
- point = rcWnd.TopLeft();
- if( bRTL )
- {
- point = CPoint( rcWnd.right, rcWnd.top );
- n = -n;
- }
- point.x += n;
- point.y += yDiff;
- }
- if( nTrackFlags == (UINT)(-1) )
- nTrackFlags = 0;
- if( (nTrackFlags & TPMX_ALIGN_MASK ) == 0 )
- nTrackFlags = bRTL ? TPMX_RIGHTALIGN : TPMX_TOPALIGN;
- if( bSelectAny )
- nTrackFlags |= TPMX_SELECT_ANY;
- if( bPrevTBMT )
- nTrackFlags |= TPMX_NO_HIDE_RARELY;
- pFrame->SetFocus();
- CExtToolControlBar::g_bMenuTracking =
- bSelectAny ? bPrevTBMT : false; // (+ v.2.23)
- if( nTrackingIdxOld >= 0 )
- _SwitchMenuTrackingIndex( nTrackingIdxOld );
- CWnd * pWndNotify = m_pDockSite;
- if( pWndNotify == NULL )
- pWndNotify = GetParent();
- if( pWndNotify != NULL )
- pWndNotify->SendMessage(
- g_nMsgPrepareSystemMenu,
- WPARAM(pPopup),
- LPARAM(pFrame)
- );
- if( bRTL && !bCombinedMode )
- point.x += pPopup->OnQueryMenuShadowSize();
- CRect rcExclude( rcExcludeArea );
- if( rcExcludeArea == NULL )
- rcExclude.SetRect( point, point );
- pPopup->m_hWndNotifyMenuClosed = GetSafeHwnd();
- if( ! pPopup->TrackPopupMenu(
- nTrackFlags
- | ( bCombinedMode ? TPMX_COMBINE_DEFAULT : 0)
- | TPMX_OWNERDRAW_FIXED
- | TPMX_SYSMENU,
- point.x,point.y,
- rcExclude,
- bCombinedMode ?
- this : NULL,
- bCombinedMode ?
- CExtToolControlBar::_CbPaintCombinedContent : NULL,
- NULL,
- bCombinedMode ? true : false
- )
- )
- {
- //delete pPopup;
- CExtToolControlBar::_CloseTrackingMenus();
- return FALSE;
- }
- g_bMenuTracking = true;
- return TRUE;
- }
- BOOL CExtMenuControlBar::TrackChildFrameSystemMenu(
- CPoint * pPoint, // = NULL, // NULL means calc any track area automatically
- BOOL bSelectAny // = FALSE
- )
- {
- if( ! m_bAllowProfChildFrameSysmenu )
- return FALSE;
- if( ! _IsMdiApp() )
- {
- ASSERT( FALSE );
- return FALSE;
- } // if( ! _IsMdiApp() )
- if( GetButtonsCount() > 0 )
- {
- CExtBarButton * pTBB = _GetButtonPtr( 0 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton)) )
- {
- if( ! CExtPopupMenuWnd::IsMenuTracking() )
- {
- HWND hWndFocus = ::GetFocus();
- if( hWndFocus != NULL )
- ::SendMessage( hWndFocus, WM_CANCELMODE, 0L, 0L );
- } // if( ! CExtPopupMenuWnd::IsMenuTracking() )
- if( ! TrackButtonMenu( 0 ) )
- {
- ASSERT( FALSE );
- return FALSE;
- } // if( ! TrackButtonMenu( 0 ) )
- return TRUE;
- } // if( pTBB->IsKindOf(RUNTIME_CLASS(CExtBarMdiDocButton)) )
- } // if( GetButtonsCount() > 0 )
- BOOL bMax = FALSE;
- HWND hWndActiveChild = _GetActiveMdiChildWnd( bMax );
- if( hWndActiveChild == NULL )
- return FALSE;
- ASSERT( ::IsWindow(hWndActiveChild) );
- CWnd * pWnd = CWnd::FromHandlePermanent(hWndActiveChild);
- if( pWnd == NULL )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- ASSERT_VALID( pWnd );
- // FrameFeatures does not use CMDIChildWnd
- // ASSERT( pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) );
- //CFrameWnd * pFrame =
- // DYNAMIC_DOWNCAST(
- // CFrameWnd,
- // pWnd
- // );
- // ASSERT( pFrame != NULL );
- // if( pFrame == NULL )
- // {
- // ASSERT( FALSE );
- // return FALSE;
- // }
- // ASSERT_VALID( pFrame );
- g_bMenuTracking = true;
- _SwitchMenuTrackingIndex();
- m_bSysMenuTracking =
- _TrackFrameSystemMenu(
- pWnd,
- pPoint,
- bSelectAny
- ) ? true : false;
- return m_bSysMenuTracking ? TRUE : FALSE;
- }
- BOOL CExtMenuControlBar::TrackMainFrameSystemMenu(
- CPoint * pPoint, // = NULL // NULL means calc menu track area automatically
- BOOL bSelectAny // = FALSE
- )
- {
- if( ! m_bAllowProfMainFrameSysmenu )
- return FALSE;
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- CWnd * pWndForPlacement = stat_GetWndForPlacement( pFrame );
- // if( pWndForPlacement->m_hWnd != pFrame->m_hWnd )
- // return FALSE;
- g_bMenuTracking = true;
- _SwitchMenuTrackingIndex();
- m_bSysMenuTracking =
- _TrackFrameSystemMenu(
- pWndForPlacement, // pFrame
- pPoint,
- bSelectAny
- ) ? true : false;
- return m_bSysMenuTracking ? TRUE : FALSE;
- }
- BOOL CExtMenuControlBar::TrackButtonMenu(
- int nIndex,
- BOOL bSelectAny, // = FALSE
- BOOL bDelayedTracking, // = FALSE
- BOOL bNoAnimation // = FALSE
- )
- {
- bSelectAny;
- bDelayedTracking;
- if( g_bMenuTracking
- && m_nBtnIdxMenuTracking == nIndex
- )
- return TRUE;
- if( ! SafeDisplayBar() )
- return FALSE;
- _CancelFlatTracking();
- if( m_bMenuBarUsesDelayedButtonMenuTracking )
- PostMessage(
- g_nMsgTrackButtonMenu,
- (WPARAM)nIndex,
- (LPARAM)bNoAnimation
- );
- else
- SendMessage(
- g_nMsgTrackButtonMenu,
- (WPARAM)nIndex,
- (LPARAM)bNoAnimation
- );
- return TRUE;
- }
- LRESULT CExtMenuControlBar::OnTrackButtonMenu(WPARAM wParam,LPARAM lParam)
- {
- if( !( ::IsWindowEnabled(
- m_bPresubclassDialogMode
- ? GetOwner()->GetSafeHwnd()
- : _GetDockingFrameImpl()->GetSafeHwnd()
- )
- )
- )
- return 0;
- int nCountOfButtons = GetButtonsCount();
- ASSERT( nCountOfButtons >= 0 );
- if( nCountOfButtons == 0 )
- return 0;
- int nIndex = int(wParam);
- if( nIndex < 0 || nIndex>=nCountOfButtons )
- {
- _CancelFlatTracking();
- _CloseTrackingMenus();
- return 0;
- }
- CExtBarButton * pTBB = _GetButtonPtr(nIndex);
- ASSERT_VALID( pTBB );
- BOOL bDroppedMode =
- CExtPopupMenuWnd::IsMenuTracking();
- if( !pTBB->IsAbleToTrackMenu() )
- bDroppedMode = FALSE;
- if( bDroppedMode )
- {
- CExtToolControlBar::TrackButtonMenu(
- nIndex,
- true,
- false,
- (lParam != 0) ? true : false
- );
- return 0;
- }
- _CloseTrackingMenus();
- if( CExtMouseCaptureSink::GetCapture() == GetSafeHwnd() )
- CExtMouseCaptureSink::ReleaseCapture();
- if( ! m_bFlatTracking )
- {
- HWND hWndFocus = ::GetFocus();
- if( hWndFocus != NULL )
- ::SendMessage( hWndFocus, WM_CANCELMODE, 0L, 0L );
- } // if( ! m_bFlatTracking )
- m_nFlatTrackingIndex = nIndex;
- if( ! m_bFlatTracking )
- {
- m_bFlatTracking = true;
- HDWP hPassiveModeDWP = NULL;
- OnFlatTrackingStart( hPassiveModeDWP );
- } // if( ! m_bFlatTracking )
- _UpdateFlatTracking();
- return 0;
- }
- int CExtMenuControlBar::_FlatTrackingGet() const
- {
- ASSERT_VALID( this );
- return m_bFlatTracking;
- }
- void CExtMenuControlBar::_FlatTrackingSet( bool bFlatTracking )
- {
- ASSERT_VALID( this );
- m_bFlatTracking = bFlatTracking;
- }
- int CExtMenuControlBar::_FlatTrackingIndexGet() const
- {
- ASSERT_VALID( this );
- return m_nFlatTrackingIndex;
- }
- void CExtMenuControlBar::_FlatTrackingIndexSet( int nFlatTrackingIndex )
- {
- ASSERT_VALID( this );
- m_nFlatTrackingIndex = nFlatTrackingIndex;
- }
- void CExtMenuControlBar::_CancelFlatTracking(
- BOOL bRepaint // = TRUE
- )
- {
- ASSERT_VALID( this );
- if( ! m_bFlatTracking )
- return;
- m_bFlatTracking = false;
- OnFlatTrackingStop();
- _UpdateFlatTracking( bRepaint );
- }
- void CExtMenuControlBar::OnFlatTrackingStart(
- HDWP & hPassiveModeDWP
- )
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnFlatTrackingStart( hPassiveModeDWP );
- }
- void CExtMenuControlBar::OnFlatTrackingStop()
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnFlatTrackingStop();
- }
- void CExtMenuControlBar::_UpdateFlatTracking(
- BOOL bRepaint // = TRUE
- )
- {
- ASSERT_VALID( this );
- if( m_nFlatTrackingIndex < 0
- && m_nOldTrackingIndex < 0
- )
- {
- if( m_bFlatTracking )
- {
- m_bFlatTracking = false;
- OnFlatTrackingStop();
- } // if( m_bFlatTracking )
- return;
- }
- HWND hWndCurrentFocus = ::GetFocus();
- if( hWndCurrentFocus != NULL )
- {
- CWnd * pWndTest = CWnd::FromHandlePermanent( hWndCurrentFocus );
- if( pWndTest == NULL )
- {
- HWND hWnd = ::GetParent( hWndCurrentFocus );
- if( hWnd != NULL )
- pWndTest = CWnd::FromHandlePermanent( hWnd );
- } // if( pWndTest == NULL )
- if( pWndTest != NULL )
- {
- CComboBox * pComboTest =
- DYNAMIC_DOWNCAST(
- CComboBox,
- pWndTest
- );
- if( pComboTest == NULL )
- {
- pWndTest = pWndTest->GetParent();
- if( pWndTest != NULL )
- {
- pComboTest =
- DYNAMIC_DOWNCAST(
- CComboBox,
- pWndTest
- );
- }
- } // if( pComboTest == NULL )
- if( pComboTest != NULL
- && (pComboTest->GetStyle() & (CBS_DROPDOWN|CBS_DROPDOWNLIST)) != 0
- && pComboTest->GetDroppedState()
- )
- pComboTest->ShowDropDown( FALSE );
- } // if( pWndTest != NULL )
- } // if( hWndCurrentFocus != NULL )
- int nCountOfButtons = GetButtonsCount();
- if( !m_bFlatTracking )
- {
- if( m_nFlatTrackingIndex >= 0 )
- {
- ASSERT( m_nFlatTrackingIndex < nCountOfButtons );
- CExtBarButton * pTBB =
- _GetButtonPtr(m_nFlatTrackingIndex);
- ASSERT_VALID( pTBB );
- pTBB->ModifyStyle(0,TBBS_PRESSED);
- INT nIndexRepaint = m_nFlatTrackingIndex;
- m_nFlatTrackingIndex = m_nOldTrackingIndex = -1;
- if( bRepaint )
- {
- _InvalidateButton( nIndexRepaint );
- ///UpdateWindow();
- }
- }
- // if( g_bMenuTracking )
- // _CloseTrackingMenus();
- return;
- } // if( !m_bFlatTracking )
- if( m_nFlatTrackingIndex != m_nOldTrackingIndex )
- {
- if( m_nOldTrackingIndex >= 0 && m_nOldTrackingIndex < nCountOfButtons )
- {
- CExtBarButton * pTBB =
- _GetButtonPtr(m_nOldTrackingIndex);
- ASSERT_VALID( pTBB );
- pTBB->ModifyStyle(0,TBBS_PRESSED|TBBS_CHECKED);
- if( bRepaint )
- _InvalidateButton(m_nOldTrackingIndex);
- } // if( m_nOldTrackingIndex >= 0 && m_nOldTrackingIndex < nCountOfButtons )
- if( m_nFlatTrackingIndex >= 0 )
- {
- ASSERT( m_nFlatTrackingIndex < nCountOfButtons );
- CExtBarButton * pTBB =
- _GetButtonPtr(m_nFlatTrackingIndex);
- ASSERT_VALID( pTBB );
- pTBB->ModifyStyle(TBBS_PRESSED);
- if( bRepaint )
- _InvalidateButton(m_nFlatTrackingIndex);
- }
- m_nOldTrackingIndex = m_nFlatTrackingIndex;
- AnimationSite_PassAnimationEvents();
- ///UpdateWindow();
- } // if( m_nFlatTrackingIndex != m_nOldTrackingIndex )
- }
- void CExtMenuControlBar::_DelaySyncActiveMdiChild()
- {
- ASSERT_VALID( this );
- if( m_bDelayedSyncActiveMdiChild
- || m_bDelayedUpdateMenuBar
- || m_hWnd == NULL
- || (! ::IsWindow(m_hWnd) )
- )
- return;
- m_bDelayedSyncActiveMdiChild = true;
- PostMessage( WM_TIMER, 13, 0 );
- }
- void CExtMenuControlBar::_DelayUpdateMenuBar()
- {
- ASSERT_VALID( this );
- if( m_bDelayedUpdateMenuBar
- || m_hWnd == NULL
- || (! ::IsWindow(m_hWnd) )
- )
- return;
- m_bDelayedSyncActiveMdiChild = false;
- m_bDelayedUpdateMenuBar = true;
- PostMessage( WM_TIMER, 14, 0 );
- }
- void CExtMenuControlBar::OnTimer(__EXT_MFC_UINT_PTR nIDEvent)
- {
- __PROF_UIS_MANAGE_STATE;
- if( nIDEvent == 13 )
- {
- KillTimer( nIDEvent );
- if( m_bDelayedSyncActiveMdiChild )
- {
- m_bDelayedSyncActiveMdiChild = false;
- _SyncActiveMdiChild();
- }
- return;
- } // if( nIDEvent == 13 )
- if( nIDEvent == 14 )
- {
- KillTimer( nIDEvent );
- if( m_bDelayedUpdateMenuBar )
- {
- m_bDelayedUpdateMenuBar = false;
- VERIFY( UpdateMenuBar( TRUE ) );
- } // if( m_bDelayedUpdateMenuBar )
- return;
- } // if( nIDEvent == 14 )
- if( nIDEvent == 15 )
- {
- KillTimer( nIDEvent );
- ASSERT( m_bMdiApp );
- HWND hWndMdiClient = _GetHwndMdiArea();
- if( hWndMdiClient != NULL )
- {
- KillTimer( nIDEvent );
- VERIFY( _InitMdiChildHook( hWndMdiClient ) );
- } // if( hWndMdiClient != NULL )
- return;
- } // if( nIDEvent == 15 )
- if( nIDEvent == 16 )
- {
- KillTimer( nIDEvent );
- _KillFrameMenu();
- return;
- } // if( nIDEvent == 16 )
- CExtToolControlBar::OnTimer(nIDEvent);
- }
- bool CExtMenuControlBar::_InitMdiChildHook( HWND hWndMdiClient )
- {
- ASSERT( m_bMdiApp );
- ASSERT( ::IsWindow(hWndMdiClient) );
- if( ! SetupHookWndSink( hWndMdiClient ) )
- {
- ASSERT( FALSE );
- return false;
- } // if( ! SetupHookWndSink( hWndMdiClient ) )
- ::SetWindowPos(
- hWndMdiClient, NULL, 0, 0, 0, 0,
- SWP_FRAMECHANGED
- |SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_NOCOPYBITS
- |SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE
- );
- VERIFY( _SyncActiveMdiChild() );
- return true;
- }
- bool CExtMenuControlBar::_IsSimplifiedDropDownButtons() const
- {
- ASSERT_VALID( this );
- return true;
- }
- bool CExtMenuControlBar::_OnMouseMoveMsg(UINT nFlags, CPoint point)
- {
- if( ! m_bFlatTracking )
- return CExtToolControlBar::_OnMouseMoveMsg(nFlags, point);
- int nIndex = HitTest( point );
- if( nIndex == m_nFlatTrackingIndex
- || nIndex < 0
- )
- return true;
- TrackButtonMenu( nIndex );
- return true;
- }
- void CExtMenuControlBar::OnLButtonDown(UINT nFlags, CPoint point)
- {
- if( !m_bFlatTracking )
- {
- int nIndex = HitTest(point);
- if( nIndex >= 0 )
- {
- int nMenuIndex = GetMenuTrackingButton();
- if( nIndex == nMenuIndex )
- return;
- }
- }
- CExtToolControlBar::OnLButtonDown(nFlags, point);
- }
- void CExtMenuControlBar::OnLButtonUp(UINT nFlags, CPoint point)
- {
- BOOL bRepaint = FALSE;
- if( m_bFlatTracking )
- {
- m_bFlatTracking = false;
- OnFlatTrackingStop();
- _UpdateFlatTracking( FALSE );
- bRepaint = TRUE;
- }
- CExtToolControlBar::OnLButtonUp(nFlags, point);
- if( bRepaint )
- Invalidate();
- }
- void CExtMenuControlBar::_RecalcLayoutImpl()
- {
- CExtToolControlBar::_RecalcLayoutImpl();
- if( m_pDockSite != NULL
- && IsFloating()
- && ( ! ((InternalFriendlyFrameWnd*)m_pDockSite)->IsInRecalcLayout() )
- && (! CExtControlBar::ProfileBarStateIsSerializing( m_pDockSite ) )
- && (m_pDockSite->GetStyle()&WS_VISIBLE) != 0
- )
- {
- WINDOWPLACEMENT _wp;
- ZeroMemory( &_wp, sizeof(WINDOWPLACEMENT) );
- _wp.length = sizeof(WINDOWPLACEMENT);
- CWnd * pWndPlacement = stat_GetWndForPlacement( m_pDockSite );
- ASSERT_VALID( pWndPlacement );
- pWndPlacement->GetWindowPlacement( &_wp );
- if( _wp.showCmd == SW_SHOWMINIMIZED )
- {
- //m_pDockSite->DelayRecalcLayout();
- return;
- }
- m_pDockSite->RecalcLayout();
- }
- }
- bool CExtMenuControlBar::OnQueryShiftRTL() const
- {
- ASSERT_VALID( this );
- return ((g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0) ? true : false;
- }
- bool CExtMenuControlBar::OnQueryRevertRTL() const
- {
- ASSERT_VALID( this );
- return ((g_ResourceManager->OnQueryLangLayout()&LAYOUT_RTL) != 0) ? true : false;
- }
- void CExtMenuControlBar::_RecalcPositionsImpl()
- {
- CExtToolControlBar::_RecalcPositionsImpl();
- if( g_bHideMenuBarExpandContentButton
- && m_pRightBtn != NULL
- )
- {
- ASSERT_VALID( m_pRightBtn );
- if( m_pRightBtn->GetButtons().GetSize() == 0 )
- m_pRightBtn->Show( FALSE );
- }
- CWnd * pWndParent = GetParent();
- ASSERT_VALID( pWndParent );
- BOOL bInDockBar = pWndParent->IsKindOf(RUNTIME_CLASS(CDockBar));
- if( IsFloating() && bInDockBar )
- return;
- int nCountOfButtons = GetButtonsCount();
- if( nCountOfButtons <= 1 )
- return;
- int nRightIndex = nCountOfButtons - 1;
- CExtBarMdiRightButton * pRightTBB =
- DYNAMIC_DOWNCAST(
- CExtBarMdiRightButton,
- _GetButtonPtr( nRightIndex )
- );
- if( pRightTBB == NULL && nCountOfButtons > 1 )
- {
- nRightIndex--;
- pRightTBB =
- DYNAMIC_DOWNCAST(
- CExtBarMdiRightButton,
- _GetButtonPtr( nRightIndex )
- );
- } // if( pRightTBB == NULL && nCountOfButtons > 1 )
- if( pRightTBB == NULL )
- return;
- if( !pRightTBB->IsVisible() )
- return;
- ASSERT( nRightIndex >= 1 );
- #ifdef _DEBUG
- CExtBarButton * pPrevTBB =
- _GetButtonPtr( nRightIndex - 1 );
- ASSERT_VALID( pPrevTBB );
- /// ASSERT( pPrevTBB->IsVisible() );
- #endif // _DEBUG
- CExtBarButton * pExpandTBB = NULL;
- CRect rcBtnExpand(0,0,0,0);
- int nAlignMargin = 0;
- BOOL bHorz =
- bInDockBar
- ? IsDockedHorizontally()
- : ( (m_dwStyle & (CBRS_ALIGN_TOP|CBRS_ALIGN_BOTTOM))
- ? true
- : false
- )
- ;
- CRect rcClient;
- GetClientRect( &rcClient );
-
- if( nRightIndex < (nCountOfButtons-1) )
- {
- pExpandTBB = _GetButtonPtr( nRightIndex + 1 );
- ASSERT_VALID( pExpandTBB );
- if( ! pExpandTBB->IsKindOf( RUNTIME_CLASS(CExtBarContentExpandButton)) )
- pExpandTBB = NULL;
- } // if( nRightIndex < (nCountOfButtons-1) )
-
- if( pExpandTBB != NULL )
- { // if content-expand button exists
- if( pExpandTBB->IsVisible() )
- {
- rcBtnExpand = pExpandTBB->Rect();
- nAlignMargin =
- bHorz ? rcBtnExpand.left : rcBtnExpand.top;
- } // if( pExpandTBB->IsVisible() )
- else
- {
- pExpandTBB = NULL;
- nAlignMargin =
- bHorz ? rcClient.right : rcClient.bottom;
- } // else from if( pExpandTBB->IsVisible() )
- nAlignMargin -= __MENUBAR_RIGHT_ADJUST_GAP;
- } // if content-expand button exists
- else
- { // if content-expand button DOES NOT exists
- nAlignMargin =
- bHorz ? rcClient.right : rcClient.bottom;
- nAlignMargin -= __MENUBAR_RIGHT_ADJUST_GAP;
- } // if content-expand button DOES NOT exists
- CRect rcBtnRight = pRightTBB->Rect();
- if( bHorz && rcBtnRight.right >= nAlignMargin )
- return;
- if( (!bHorz) && rcBtnRight.bottom >= nAlignMargin )
- return;
- if( bHorz )
- rcBtnRight.OffsetRect(
- nAlignMargin - rcBtnRight.right,
- 0
- );
- else
- rcBtnRight.OffsetRect(
- 0,
- nAlignMargin - rcBtnRight.bottom
- );
- if( pExpandTBB == NULL )
- {
- pRightTBB->SetRect(rcBtnRight);
- return;
- }
- ASSERT( !rcBtnExpand.IsRectEmpty() );
- CRect rcBtnExpand2(
- bHorz ? rcBtnRight.left : rcBtnExpand.left,
- bHorz ? rcBtnExpand.top : rcBtnRight.top,
- bHorz ?
- rcBtnRight.left + rcBtnExpand.Width()
- :
- rcBtnExpand.left + rcBtnExpand.Width()
- ,
- bHorz ?
- rcBtnExpand.top + rcBtnExpand.Height()
- :
- rcBtnRight.top + rcBtnExpand.Height()
- );
- rcBtnRight.OffsetRect(
- bHorz ? rcBtnExpand.right - rcBtnRight.right : 0,
- bHorz ? 0 : rcBtnExpand.bottom - rcBtnRight.bottom
- );
- pRightTBB->SetRect(rcBtnRight);
- pExpandTBB->SetRect(rcBtnExpand2);
- if( g_bHideMenuBarExpandContentButton )
- pExpandTBB->Show( FALSE );
- }
- bool CExtMenuControlBar::_GetFullRowMode() const
- {
- ASSERT_VALID( this );
- return true;
- }
- bool CExtMenuControlBar::OnQueryMultiRowLayout() const
- {
- ASSERT_VALID( this );
- if( m_bPresubclassDialogMode
- // || m_pDockSite == NULL
- )
- return false;
- if( m_pDockBar != NULL )
- {
- if( IsFloating() )
- return false;
- if( _IsDockSiteCustomizeMode() )
- return true;
- } // if( m_pDockBar != NULL )
- return m_bMultiRowLayout;
- }
- CExtBarContentExpandButton * CExtMenuControlBar::OnCreateBarRightBtn()
- {
- ASSERT_VALID( this );
- if( m_bMultiRowLayout )
- return NULL;
- return CExtToolControlBar::OnCreateBarRightBtn();
- }
- void CExtMenuControlBar::_Dragging_OnStart()
- {
- _CancelFlatTracking();
- if( g_bMenuTracking )
- _CloseTrackingMenus();
- CExtToolControlBar::_Dragging_OnStart();
- }
- void CExtMenuControlBar::_Dragging_OnStop(
- CExtControlBar::InternalDraggingState_t & _dsOld,
- CExtControlBar::InternalDraggingState_t & _dsNew,
- bool bCancel
- )
- {
- CExtToolControlBar::_Dragging_OnStop(
- _dsOld,
- _dsNew,
- bCancel
- );
- if( _IsMdiApp() )
- {
- _InstallMdiDocButtons();
- _RecalcPositionsImpl();
- } // if( _IsMdiApp() )
- }
- HWND CExtMenuControlBar::_GetHwndMainFrame()
- {
- if( m_bPresubclassDialogMode )
- return NULL;
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- ASSERT( ::IsWindow(pFrame->GetSafeHwnd()) );
- return pFrame->GetSafeHwnd();
- }
- HWND CExtMenuControlBar::_GetHwndPlacement()
- {
- if( !m_bPresubclassDialogMode )
- return NULL;
- return m_hWndHelper;
- }
- HWND CExtMenuControlBar::_GetHwndChildFrame()
- {
- if( m_bPresubclassDialogMode )
- return NULL;
- return m_hWndHelper;
- }
- HWND CExtMenuControlBar::_GetHwndMdiArea()
- {
- if( m_bPresubclassDialogMode )
- return NULL;
- ASSERT( _IsMdiApp() );
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- ASSERT( ::IsWindow(pFrame->GetSafeHwnd()) );
- // FrameFeatures does not use CMDIFrameWnd
- // ASSERT_KINDOF( CMDIFrameWnd, pFrame );
- CMDIFrameWnd * pMdiFrame =
- DYNAMIC_DOWNCAST(
- CMDIFrameWnd,
- pFrame
- );
- if( pMdiFrame == NULL )
- {
- for( HWND hWnd = ::GetWindow( pFrame->GetSafeHwnd(), GW_CHILD );
- hWnd != NULL;
- hWnd = ::GetWindow( hWnd, GW_HWNDNEXT )
- )
- {
- ASSERT( ::IsWindow( hWnd ) );
- TCHAR strClassName[ 512 ];
- ::memset( strClassName, 0, sizeof(strClassName) );
- ::GetClassName( hWnd, strClassName, 512 );
- if( _tcslen( strClassName ) == 0 )
- continue;
- __EXT_MFC_STRLWR( strClassName, 512 );
- //if( _tcscmp( strClassName, _T("mdiclient") ) == 0 )
- if( _tcsstr( strClassName, _T("mdiclient") ) != NULL )
- return hWnd;
- }
- return NULL;
- } // if( pMdiFrame == NULL )
- //ASSERT_VALID( pMdiFrame );
- ASSERT( pMdiFrame->m_hWndMDIClient != NULL );
- ASSERT( ::IsWindow( pMdiFrame->m_hWndMDIClient ) );
- return pMdiFrame->m_hWndMDIClient;
- }
- int CExtMenuControlBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CExtToolControlBar::OnCreate(lpCreateStruct) == -1)
- return -1;
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- if( pFrame == NULL )
- {
- m_bPresubclassDialogMode = true;
- if( m_hWndHelper == NULL )
- {
- m_hWndHelper = ::GetParent( m_hWnd );
- ASSERT( m_hWndHelper != NULL );
- ASSERT( ::IsWindow( m_hWndHelper ) );
- if( !IsHookedWindow( m_hWndHelper ) )
- SetupHookWndSink( m_hWndHelper );
- } // if( m_hWndHelper == NULL )
- return 0;
- }
- ASSERT_VALID( pFrame );
- ASSERT( ::IsWindow(pFrame->GetSafeHwnd()) );
- ASSERT( m_menuFrame.GetSafeHmenu() == NULL );
- ASSERT( m_menuDoc.GetSafeHmenu() == NULL );
- if( (pFrame->GetStyle()&WS_CHILD) == 0 )
- {
- HMENU hFrameMenu = pFrame->GetMenu()->GetSafeHmenu();
- if( hFrameMenu != NULL )
- {
- m_menuFrame.Attach( hFrameMenu );
- _UpdateMenuBar( FALSE );
- pFrame->SetMenu( NULL );
- }
- } // if( (pFrame->GetStyle()&WS_CHILD) == 0 )
- HWND hWndMainFrame = _GetHwndMainFrame();
- if( hWndMainFrame != NULL )
- {
- CWnd * pWndForPlacement = stat_GetWndForPlacement( CWnd::FromHandle(hWndMainFrame) );
- if( ! SetupHookWndSink( pWndForPlacement->m_hWnd ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- if( pWndForPlacement->m_hWnd != hWndMainFrame )
- {
- if( ! SetupHookWndSink( hWndMainFrame ) )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- }
- // FrameFeatures does not use CMDIFrameWnd
- if( pFrame->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd))
- || _IsMdiApp()
- )
- { // if MDI App
- m_bMdiApp = true;
- HWND hWndMdiClient = _GetHwndMdiArea();
- if( hWndMdiClient != NULL )
- {
- VERIFY( _InitMdiChildHook( hWndMdiClient ) );
- }
- else
- SetTimer( 15, 10, NULL );
- // // pass message loop for smooth MDI client area update reasons
- // //CExtPopupMenuWnd::PassMsgLoop( CExtControlBar::g_bEnableOnIdleCalls );
- // MSG msg;
- // int i = 0;
- // for( ; PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) && i < 1000; i++ )
- // {
- // if( !AfxGetThread()->PumpMessage() )
- // break;
- // if( msg.message == WM_TIMER && msg.wParam == 15 )
- // break;
- // } // while( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) )
- } // if( pFrame->IsKindOf(RUNTIME_CLASS(CMDIFrameWnd)) ...
- } // if( hWndMainFrame != NULL )
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtBarMdiDocButton
- IMPLEMENT_DYNCREATE(CExtBarMdiDocButton,CExtBarButton)
- CExtBarMdiDocButton::CExtBarMdiDocButton(
- CExtToolControlBar * pBar, // = NULL
- UINT nCmdID, // = ID_SEPARATOR
- UINT nStyle // = 0
- )
- : CExtBarButton( pBar, nCmdID, nStyle )
- , m_hWndActiveMdiChild( NULL )
- , m_bHandleDblClickAsCloseCmd( true )
- {
- }
- CExtBarMdiDocButton::~CExtBarMdiDocButton()
- {
- }
- #if (!defined __EXT_MFC_NO_RIBBON_BAR)
- bool CExtBarMdiDocButton::IsRibbonPaintingMode() const
- {
- ASSERT_VALID( this );
- return false;
- }
- CSize CExtBarMdiDocButton::RibbonILV_CalcSize(
- CDC & dc,
- INT nILV // = -1 // -1 use current visual level
- ) const
- {
- ASSERT_VALID( this );
- nILV;
- return
- ( const_cast < CExtBarMdiDocButton * > ( this ) )
- -> CalculateLayout( dc, CSize(0,0), IsHorzBarOrientation() );
- }
- #endif // (!defined __EXT_MFC_NO_RIBBON_BAR)
- CSize CExtBarMdiDocButton::CalculateLayout(
- CDC & dc,
- CSize sizePreCalc,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT_VALID( (&dc) );
- ASSERT( CtrlGet() == NULL );
- ASSERT( ! IsSeparator() );
- dc;
- sizePreCalc;
- bHorz;
- CSize _size( 16, 16 );
- CExtCmdIcon * pIcon = GetIconPtr();
- if( pIcon != NULL
- && (! pIcon->IsEmpty() )
- )
- _size = pIcon->GetSize();
- _size.cx += 3;
- _size.cy += 3;
- return _size;
- }
- bool CExtBarMdiDocButton::CanStartCommandDrag()
- {
- ASSERT_VALID( this );
- return false;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * CExtBarMdiDocButton::GetCmdNode(
- bool bInitial // = false
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // bInitial;
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // return NULL;
- return CExtBarButton::GetCmdNode( bInitial );
- }
- void CExtBarMdiDocButton::SetBasicCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // ASSERT( FALSE ); // should be never called
- // pNode;
- CExtBarButton::SetBasicCmdNode( pNode );
- }
- void CExtBarMdiDocButton::SetCustomizedCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // ASSERT( FALSE ); // should be never called
- // pNode;
- CExtBarButton::SetCustomizedCmdNode( pNode );
- }
- CExtCustomizeCmdTreeNode * CExtBarMdiDocButton::OnCustomizeNodeInit(
- CExtCustomizeSite * pSite,
- CExtCustomizeCmdTreeNode * pParentNode // toolbar node
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( pSite != NULL );
- // ASSERT_VALID( pParentNode );
- // pSite;
- // pParentNode;
- // return NULL; // no customization support
- return CExtBarButton::OnCustomizeNodeInit( pSite, pParentNode );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- BOOL CExtBarMdiDocButton::PutToPopupMenu(
- CExtPopupMenuWnd * pPopup
- )
- {
- ASSERT( pPopup != NULL );
- ASSERT( pPopup->GetSafeHwnd() == NULL );
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT( CtrlGet() == NULL );
- ASSERT( ! IsSeparator() );
- HWND hWndActiveChild = _ActiveMdiChildWndGet();
- ASSERT( ::IsWindow( hWndActiveChild ) );
- //CFrameWnd * pFrame =
- // DYNAMIC_DOWNCAST(
- // CFrameWnd,
- // CWnd::FromHandle(hWndActiveChild)
- // );
- CMenu * pSysMenu =
- CWnd::FromHandle(hWndActiveChild) ->
- GetSystemMenu( FALSE );
- if( pSysMenu == NULL )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- ASSERT( ::IsMenu(pSysMenu->GetSafeHmenu()) );
- CExtCmdIcon & _icon = GetIcon();
- CExtSafeString sActiveDocument;
- if( ! g_ResourceManager->LoadString( sActiveDocument, IDS_ACTIVE_DOCUMENT ) )
- sActiveDocument = _T("Active document");
- if( ! pPopup->ItemInsert(
- (UINT)CExtPopupMenuWnd::TYPE_POPUP,
- -1,
- sActiveDocument,
- _icon
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- CExtPopupMenuWnd * pChildPopup =
- pPopup->ItemGetPopup(
- pPopup->ItemGetCount() - 1
- );
- ASSERT( pChildPopup != NULL );
- if( ! pChildPopup->UpdateFromMenu(
- GetBar()->GetSafeHwnd(),
- pSysMenu,
- false,
- false
- )
- )
- {
- ASSERT( FALSE );
- return FALSE;
- }
- pChildPopup->
- SetCmdTargetToAllItems(
- hWndActiveChild
- );
- if( (pPopup->TrackFlagsGet()&TPMX_PALETTE) != 0 )
- pPopup->ItemGetInfo(pPopup->ItemGetCount()-1).SetChildCombine();
- VERIFY(
- pPopup->ItemInsert(
- CExtPopupMenuWnd::TYPE_SEPARATOR,
- -1
- )
- );
- return TRUE;
- }
- HWND CExtBarMdiDocButton::_ActiveMdiChildWndGet()
- {
- ASSERT_VALID( this );
- if( m_hWndActiveMdiChild != NULL
- && ::IsWindow( m_hWndActiveMdiChild )
- )
- return m_hWndActiveMdiChild;
- /// if( p_bMaximized != NULL )
- /// (*p_bMaximized) = false;
- CMDIFrameWnd * pMdiFrame = DYNAMIC_DOWNCAST( CMDIFrameWnd, GetBar()->_GetDockingFrameImpl() );
- HWND hWndMdiClient = NULL;
- if( pMdiFrame == NULL )
- hWndMdiClient = ((CExtMenuControlBar*)GetBar())->_GetHwndMdiArea();
- else
- {
- ASSERT_VALID( pMdiFrame );
- hWndMdiClient = pMdiFrame->m_hWndMDIClient;
- } // else from if( pMdiFrame == NULL )
- if( hWndMdiClient == NULL )
- return NULL;
- ASSERT( ::IsWindow( hWndMdiClient ) );
- BOOL bMax = FALSE;
- HWND hWndActiveChildFrame = (HWND) ::SendMessage( hWndMdiClient, WM_MDIGETACTIVE, 0, (LPARAM)&bMax );
- if( hWndActiveChildFrame == NULL )
- {
- /// bMax = FALSE;
- }
- else
- {
- ASSERT( ::IsWindow( hWndActiveChildFrame ) );
- __EXT_MFC_LONG_PTR dwActiveChildFrameStyle =
- ::__EXT_MFC_GetWindowLong( hWndActiveChildFrame, GWL_STYLE );
- if( pMdiFrame == NULL )
- {
- if( (dwActiveChildFrameStyle&WS_VISIBLE) == 0 )
- {
- hWndActiveChildFrame = NULL;
- ///bMax = FALSE;
- } // if( (dwActiveChildFrameStyle&WS_VISIBLE) == 0 )
- } // if( pMdiFrame == NULL )
- else
- {
- CWnd * pWndTempAnalyze = CWnd::FromHandlePermanent( hWndActiveChildFrame );
- if( pWndTempAnalyze != NULL )
- {
- ASSERT_VALID( pWndTempAnalyze );
- CMDIChildWnd * pWndTempMDIChild = DYNAMIC_DOWNCAST( CMDIChildWnd, pWndTempAnalyze );
- if( pWndTempMDIChild != NULL
- && pWndTempMDIChild->m_bPseudoInactive
- && (dwActiveChildFrameStyle&WS_VISIBLE) == 0
- )
- {
- hWndActiveChildFrame = NULL;
- ///bMax = FALSE;
- }
- } // if( pWndTempAnalyze != NULL )
- } // else from if( pMdiFrame == NULL )
- } // else from if( hWndActiveChildFrame == NULL )
- /// if( p_bMaximized != NULL )
- /// (*p_bMaximized) = bMax ? true : false;
- return hWndActiveChildFrame;
- }
- HWND CExtBarMdiDocButton::_ActiveMdiChildWndAttach(
- HWND hWndActiveMdiChildNew
- )
- {
- ASSERT_VALID( this );
- if( hWndActiveMdiChildNew == m_hWndActiveMdiChild )
- return m_hWndActiveMdiChild;
- HWND hWndActiveMdiChildOld = m_hWndActiveMdiChild;
- m_hWndActiveMdiChild = hWndActiveMdiChildNew;
- m_iconCache.Empty();
- return hWndActiveMdiChildOld;
- }
- HWND CExtBarMdiDocButton::_ActiveMdiChildWndDetach()
- {
- ASSERT_VALID( this );
- return _ActiveMdiChildWndAttach( NULL );
- }
- CExtCmdIcon * CExtBarMdiDocButton::GetIconPtr()
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- if( m_hWndActiveMdiChild != NULL
- && ::IsWindow( m_hWndActiveMdiChild )
- && ( ! m_iconCache.IsEmpty() )
- )
- return (&m_iconCache);
- HWND hWndActiveChild = _ActiveMdiChildWndGet();
- if( hWndActiveChild == NULL )
- return NULL;
- if( m_hWndActiveMdiChild != hWndActiveChild )
- m_hWndActiveMdiChild = NULL;
- ASSERT( ::IsWindow(hWndActiveChild) );
- _ExtractWndIcon( hWndActiveChild, m_iconCache );
- if( m_iconCache.IsEmpty() )
- return NULL;
- return (&m_iconCache);
- }
- void CExtBarMdiDocButton::_ExtractWndIcon(
- HWND hWnd,
- CExtCmdIcon & _Icon
- )
- {
- _Icon.Empty();
- if( hWnd == NULL
- || ( ! ::IsWindow( hWnd ) )
- )
- return;
- HICON hIcon = (HICON)(__EXT_MFC_DWORD_PTR) ::SendMessage( hWnd, CExtControlBar::g_nMsgQueryIcon, 0, 0 );
- if( hIcon == NULL )
- {
- hIcon = (HICON)(__EXT_MFC_DWORD_PTR) ::SendMessage( hWnd, WM_GETICON, ICON_SMALL, 0 );
- if( hIcon == NULL )
- {
- hIcon = (HICON)(__EXT_MFC_DWORD_PTR) ::SendMessage( hWnd, WM_GETICON, ICON_BIG, 0 );
- if( hIcon == NULL )
- {
- hIcon = (HICON)(__EXT_MFC_DWORD_PTR) ::__EXT_MFC_GetClassLong( hWnd, __EXT_MFC_GCL_HICONSM );
- if( hIcon == NULL )
- {
- hIcon = (HICON)(__EXT_MFC_DWORD_PTR) ::__EXT_MFC_GetClassLong( hWnd, __EXT_MFC_GCL_HICON );
- if( hIcon == NULL )
- return;
- } // if( hIcon == NULL )
- } // if( hIcon == NULL )
- } // if( hIcon == NULL )
- } // if( hIcon == NULL )
- ASSERT( hIcon != NULL );
- // _Icon.AssignFromHICON( hIcon, true );
- CExtCmdIcon _iconBig;
- _iconBig.AssignFromHICON( hIcon, true );
- VERIFY(
- _Icon.CreateScaledCopy(
- _iconBig,
- CSize( 16, 16 )
- )
- );
- }
- void CExtBarMdiDocButton::OnUpdateCmdUI(
- CWnd * pTarget,
- BOOL bDisableIfNoHndler,
- int nIndex
- )
- {
- ASSERT_VALID( this );
- pTarget;
- bDisableIfNoHndler;
- nIndex;
- }
- bool CExtBarMdiDocButton::OnDblClick(
- CPoint point
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- if( ! IsEnabled() )
- return false;
- if( ! m_bHandleDblClickAsCloseCmd )
- return false;
- CWnd * pWndMdiChildFrame = GetCmdTargetWnd();
- if( pWndMdiChildFrame->GetSafeHwnd() == NULL )
- return true;
- bool bAllowClose = false;
- CMenu * pSysMenu = pWndMdiChildFrame->GetSystemMenu( FALSE );
- if( pSysMenu != NULL )
- {
- INT nCount = pSysMenu->GetMenuItemCount();
- for( INT nItem = 0; nItem < nCount; nItem++ )
- {
- UINT nID = pSysMenu->GetMenuItemID( nItem );
- if( nID != SC_CLOSE )
- continue;
- MENUITEMINFO mii;
- ::memset(&mii,0,sizeof(MENUITEMINFO));
- mii.cbSize = sizeof(MENUITEMINFO);
- mii.fMask = MIIM_STATE;
- if( !pSysMenu->GetMenuItemInfo(
- nItem,
- &mii,
- TRUE
- )
- )
- break;
- if( ( mii.fState & (MFS_DISABLED|MFS_GRAYED) ) == 0 )
- bAllowClose = true;
- break;
- } // for( INT nItem = 0; nItem < nCount; nItem++ )
- } // if( pSysMenu != NULL )
- if( ! bAllowClose )
- return true;
- GetBar()->ClientToScreen( &point );
- pWndMdiChildFrame->PostMessage(
- WM_SYSCOMMAND,
- SC_CLOSE,
- MAKELONG( point.x, point.y )
- );
- return true;
- }
- CWnd * CExtBarMdiDocButton::GetCmdTargetWnd()
- {
- ASSERT_VALID( GetBar() );
- HWND hWndActiveChild = _ActiveMdiChildWndGet();
- if( hWndActiveChild == NULL )
- return NULL;
- ASSERT( ::IsWindow(hWndActiveChild) );
- CWnd * pWnd = CWnd::FromHandlePermanent(hWndActiveChild);
- if( pWnd == NULL )
- {
- pWnd = CWnd::FromHandle(hWndActiveChild);
- ASSERT_VALID( pWnd );
- } // if( pWnd == NULL )
- #ifdef _DEBUG
- else
- {
- ASSERT_VALID( pWnd );
- // FrameFeatures specifics
- //ASSERT( pWnd->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) );
- } // else from if( pWnd == NULL )
- #endif // _DEBUG
- return pWnd;
- }
- UINT CExtBarMdiDocButton::OnTrackPopup(
- CPoint point,
- bool bSelectAny,
- bool bForceNoAnimation
- )
- {
- ASSERT_VALID( GetBar() );
- bool bDockSiteCustomizeMode =
- GetBar()->_IsDockSiteCustomizeMode();
- if( bDockSiteCustomizeMode )
- return UINT(-1L);
- CExtMenuControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- CWnd * pWnd = CExtBarMdiDocButton::GetCmdTargetWnd();
- //CFrameWnd * pFrame =
- // DYNAMIC_DOWNCAST(
- // CFrameWnd,
- // pWnd
- // );
- // ASSERT( pFrame != NULL );
- if( pBar == NULL
- //|| pFrame == NULL
- )
- {
- CExtBarButton::OnTrackPopup( point, bSelectAny, bForceNoAnimation );
- return UINT(-1L);
- }
- bool bPrevTBMT = CExtToolControlBar::g_bMenuTracking;
- if( CExtToolControlBar::g_bMenuTracking
- //&& CExtPopupMenuWnd::IsMenuTracking()
- && pBar->_GetIndexOf(this) ==
- pBar->m_nBtnIdxMenuTracking
- )
- return UINT(-1L);
- CExtToolControlBar::_CloseTrackingMenus();
- if( pBar->IsFloating() )
- {
- pBar->ActivateTopParent();
- CFrameWnd * pFrame =
- pBar->GetDockingFrame();
- ASSERT_VALID( pFrame );
- pFrame->BringWindowToTop();
- }
- __EXT_MFC_LONG_PTR dwExStyle = ::__EXT_MFC_GetWindowLong( pWnd->GetSafeHwnd(), GWL_EXSTYLE );
- bool bRTL = ( (dwExStyle & WS_EX_LAYOUTRTL) != 0 ) ? true : false;
- UINT nTrackFlags = TPMX_TOPALIGN;
- CRect rcBtn = Rect();
- // point.x = rcBtn.left;
- // point.y = rcBtn.bottom;
- switch( GetBar()->GetSafeDockBarDlgCtrlID() )
- {
- case AFX_IDW_DOCKBAR_BOTTOM:
- nTrackFlags = TPMX_BOTTOMALIGN;
- // point.x = rcBtn.left;
- // point.y = rcBtn.bottom;
- break;
- case AFX_IDW_DOCKBAR_LEFT:
- nTrackFlags = bRTL ? TPMX_RIGHTALIGN : TPMX_LEFTALIGN;
- // point.x = rcBtn.right;
- // point.y = rcBtn.top;
- break;
- case AFX_IDW_DOCKBAR_RIGHT:
- nTrackFlags = bRTL ? TPMX_LEFTALIGN : TPMX_RIGHTALIGN;
- // point.x = rcBtn.left;
- // point.y = rcBtn.top;
- break;
- } // switch( GetBar()->GetSafeDockBarDlgCtrlID() )
- pBar->ClientToScreen( &rcBtn );
- // pBar->ClientToScreen( &point );
- point = rcBtn.CenterPoint();
- CExtToolControlBar::g_bMenuTracking = bPrevTBMT;
- GetBar()->_SwitchMenuTrackingIndex(
- GetBar()->_GetIndexOf( this )
- );
- if( bForceNoAnimation )
- nTrackFlags |= TPMX_FORCE_NO_ANIMATION;
- g_pTrackingMenuTBB = this;
- pBar->m_bSysMenuTracking =
- pBar->
- _TrackFrameSystemMenu(
- pWnd,
- &point, // NULL,
- TRUE,
- &rcBtn,
- nTrackFlags,
- m_bHandleDblClickAsCloseCmd ? FALSE : TRUE
- ) ? true : false;
- CExtToolControlBar::g_bMenuTracking = true;
- return UINT(-1L);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CExtBarMdiRightButton
- IMPLEMENT_DYNCREATE(CExtBarMdiRightButton,CExtBarMdiDocButton)
- CExtBarMdiRightButton::CExtBarMdiRightButton(
- CExtToolControlBar * pBar, // = NULL
- UINT nCmdID, // = ID_SEPARATOR
- UINT nStyle // = 0
- ) :
- CExtBarMdiDocButton(
- pBar,
- nCmdID,
- nStyle
- )
- {
- }
- CExtBarMdiRightButton::~CExtBarMdiRightButton()
- {
- }
- BOOL CExtBarMdiRightButton::PutToPopupMenu(
- CExtPopupMenuWnd * pPopup
- )
- {
- ASSERT( pPopup != NULL );
- ASSERT( pPopup->GetSafeHwnd() == NULL );
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT( CtrlGet() == NULL );
- ASSERT( ! IsSeparator() );
- CExtMenuControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- ASSERT_VALID( pBar );
- BOOL bHorz = !pBar->IsDockedVertically();
- MdiMenuBarRightButtonsInfo_t _info;
- pBar->_GetMdiMenuBarRightButtonsInfo( _info, this, bHorz );
- if( !_info.m_bInitialized )
- return FALSE;
- HWND hWndActiveChild = _ActiveMdiChildWndGet();
- ASSERT( ::IsWindow( hWndActiveChild ) );
- int nCount = pPopup->ItemGetCount();
- if( nCount > 0 )
- {
- if( pPopup->ItemGetCmdID(nCount-1) !=
- CExtPopupMenuWnd::TYPE_SEPARATOR
- )
- {
- VERIFY(
- pPopup->ItemInsert(
- CExtPopupMenuWnd::TYPE_SEPARATOR,
- -1
- )
- );
- }
- }
- if( _info.m_bBtnHelp )
- {
- VERIFY(
- pPopup->ItemInsert(
- SC_CONTEXTHELP,
- -1,NULL,NULL,hWndActiveChild
- )
- );
- }
- if( _info.m_bBtnMinimize )
- {
- VERIFY(
- pPopup->ItemInsert(
- SC_MINIMIZE,
- -1,NULL,NULL,hWndActiveChild
- )
- );
- VERIFY(
- pPopup->ItemInsert(
- SC_RESTORE,
- -1,NULL,NULL,hWndActiveChild
- )
- );
- }
- // if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize )
- // {
- // VERIFY(
- // pPopup->ItemInsert(
- // SC_MAXIMIZE,
- // -1,NULL,NULL,hWndActiveChild
- // )
- // );
- // }
- if( _info.m_bBtnMaximize )
- {
- VERIFY(
- pPopup->ItemInsert(
- _info.m_bBtnMinimize ? SC_MAXIMIZE : SC_RESTORE,
- -1,NULL,NULL,hWndActiveChild
- )
- );
- }
- if( _info.m_bBtnClose )
- {
- VERIFY(
- pPopup->ItemInsert(
- SC_CLOSE,
- -1,NULL,NULL,hWndActiveChild
- )
- );
- }
- return TRUE;
- }
- CExtCmdIcon * CExtBarMdiRightButton::GetIconPtr()
- {
- return NULL;
- }
- void CExtMenuControlBar::_GetMdiMenuBarRightButtonsInfo(
- CExtBarMdiRightButton::MdiMenuBarRightButtonsInfo_t & _info,
- CExtBarMdiRightButton * pTBB,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( pTBB );
- _info.m_pWndMdiChildFrame = pTBB->GetCmdTargetWnd();
- if( _info.m_pWndMdiChildFrame == NULL )
- return;
- //ASSERT( _info.m_pWndMdiChildFrame->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)) );
- ASSERT_VALID( _info.m_pWndMdiChildFrame );
- _info.m_pBar = this;
- DWORD dwFrameStyle = _info.m_pWndMdiChildFrame->GetStyle();
- _info.m_bBtnClose = false;
- CMenu * pSysMenu = _info.m_pWndMdiChildFrame->GetSystemMenu( FALSE );
- if( pSysMenu != NULL )
- {
- INT nCount = pSysMenu->GetMenuItemCount();
- for( INT nItem = 0; nItem < nCount; nItem++ )
- {
- UINT nID = pSysMenu->GetMenuItemID( nItem );
- if( nID != SC_CLOSE )
- continue;
- MENUITEMINFO mii;
- ::memset(&mii,0,sizeof(MENUITEMINFO));
- mii.cbSize = sizeof(MENUITEMINFO);
- mii.fMask = MIIM_STATE;
- if( !pSysMenu->GetMenuItemInfo(
- nItem,
- &mii,
- TRUE
- )
- )
- break;
- if( ( mii.fState & (MFS_DISABLED|MFS_GRAYED) ) == 0 )
- _info.m_bBtnClose = true;
- break;
- } // for( INT nItem = 0; nItem < nCount; nItem++ )
- } // if( pSysMenu != NULL )
- _info.m_bBtnMaximize =
- (dwFrameStyle & WS_MAXIMIZEBOX) ?
- true : false;
- _info.m_bBtnMinimize =
- (dwFrameStyle & WS_MINIMIZEBOX) ?
- true : false;
- _info.m_bBtnHelp =
- (_info.m_bBtnMaximize && (_info.m_pWndMdiChildFrame->GetExStyle()&WS_EX_CONTEXTHELP)) ?
- true : false;
- if( bHorz )
- {
- _info.m_calcSize.cx = __GAP_BETWEEN_WND_RIGHT_BUTTONS;
- _info.m_calcSize.cy = _info.m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnMinimize )
- _info.m_calcSize.cx +=
- (_info.m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS)*2;
- if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize )
- _info.m_calcSize.cx +=
- _info.m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnHelp )
- _info.m_calcSize.cx +=
- _info.m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnClose )
- _info.m_calcSize.cx +=
- _info.m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- } // if( bHorz )
- else
- {
- _info.m_calcSize.cx = _info.m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- _info.m_calcSize.cy = __GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnMinimize )
- _info.m_calcSize.cy +=
- (_info.m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS)*2;
- if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize )
- _info.m_calcSize.cy +=
- _info.m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnHelp )
- _info.m_calcSize.cy +=
- _info.m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- if( _info.m_bBtnClose )
- _info.m_calcSize.cy +=
- _info.m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- } // else from if( bHorz )
- _info.m_bInitialized = true;
- }
- CExtBarMdiRightButton::MdiMenuBarRightButtonsInfo_t::
- MdiMenuBarRightButtonsInfo_t()
- {
- m_bInitialized
- = m_bBtnClose
- = m_bBtnMaximize
- = m_bBtnMinimize
- = m_bBtnHelp
- = false;
- m_pBar = NULL;
- m_pWndMdiChildFrame = NULL;
- if( g_PaintManager.m_bIsWinXPorLater )
- {
- CSize _sizeTmp( // (+ v.2.22)
- ::GetSystemMetrics(SM_CXSMSIZE),
- ::GetSystemMetrics(SM_CYSMSIZE)
- );
- int nMetric =
- max( _sizeTmp.cx, _sizeTmp.cy ) + 1;
- m_cxIcon = max( nMetric, 18 ); // 16->18 (+ v.2.23)
- m_cyIcon = max( nMetric, 18 ); // 16->18 (+ v.2.23)
- } // if( g_PaintManager.m_bIsWinXPorLater )
- else
- {
- m_cxIcon = ::GetSystemMetrics(SM_CXSIZE);
- m_cyIcon = ::GetSystemMetrics(SM_CYSIZE);
- } // else from if( g_PaintManager.m_bIsWinXPorLater )
- ASSERT(
- m_cxIcon > __GAP_BETWEEN_WND_RIGHT_BUTTONS
- &&
- m_cyIcon > __GAP_BETWEEN_WND_RIGHT_BUTTONS
- );
- m_cxIcon -= __GAP_BETWEEN_WND_RIGHT_BUTTONS;
- m_cyIcon -= __GAP_BETWEEN_WND_RIGHT_BUTTONS;
- m_calcSize.cx = m_calcSize.cy = 0;
- EmptyLocations();
- }
- void CExtBarMdiRightButton::MdiMenuBarRightButtonsInfo_t::
- EmptyLocations()
- {
- m_rcBtnClose.SetRectEmpty();
- m_rcBtnMaximize.SetRectEmpty();
- m_rcBtnRestore.SetRectEmpty();
- m_rcBtnMinimize.SetRectEmpty();
- m_rcBtnHelp.SetRectEmpty();
- }
- void CExtBarMdiRightButton::MdiMenuBarRightButtonsInfo_t::
- InitLocations(
- const CRect & rcBtn,
- BOOL bHorz
- )
- {
- ASSERT( m_bInitialized );
- EmptyLocations();
- if( rcBtn.IsRectEmpty() )
- return;
- CRect rcStart(0,0,0,0);
- CSize sizeOffset(0,0);
- if( bHorz )
- {
- int nOffset = (rcBtn.Height() - m_cyIcon) / 2;
- rcStart.SetRect(
- rcBtn.left + __GAP_BETWEEN_WND_RIGHT_BUTTONS,
- rcBtn.top + nOffset,
- rcBtn.left + __GAP_BETWEEN_WND_RIGHT_BUTTONS
- + m_cxIcon,
- rcBtn.top + nOffset + m_cyIcon
- );
- sizeOffset.cx = m_cxIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- } // if( bHorz )
- else
- {
- int nOffset = (rcBtn.Width() - m_cxIcon) / 2;
- rcStart.SetRect(
- rcBtn.left + nOffset,
- rcBtn.top + __GAP_BETWEEN_WND_RIGHT_BUTTONS,
- rcBtn.left + nOffset + m_cxIcon,
- rcBtn.top + __GAP_BETWEEN_WND_RIGHT_BUTTONS
- + m_cxIcon
- );
- sizeOffset.cy = m_cyIcon+__GAP_BETWEEN_WND_RIGHT_BUTTONS;
- } // else from if( bHorz )
- if( m_bBtnHelp )
- {
- m_rcBtnHelp = rcStart;
- rcStart.OffsetRect(sizeOffset);
- }
- if( m_bBtnMinimize )
- {
- m_rcBtnMinimize = rcStart;
- rcStart.OffsetRect(sizeOffset);
- m_rcBtnRestore = rcStart;
- rcStart.OffsetRect(sizeOffset);
- }
- if( m_bBtnMaximize && (! m_bBtnMinimize ) )
- {
- m_rcBtnMaximize = rcStart;
- rcStart.OffsetRect(sizeOffset);
- }
- if( m_bBtnClose )
- m_rcBtnClose = rcStart;
- }
- CSize CExtBarMdiRightButton::CalculateLayout(
- CDC & dc,
- CSize sizePreCalc,
- BOOL bHorz
- )
- {
- ASSERT_VALID( this );
- dc;
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT_VALID( (&dc) );
- ASSERT( CtrlGet() == NULL );
- // ASSERT( ! IsSeparator() );
- if( ( ! IsVisible() )
- || ( GetStyle() & TBBS_HIDDEN ) != 0
- )
- {
- m_ActiveSize.cx = m_ActiveSize.cy = 0;
- return m_ActiveSize;
- }
- CExtMenuControlBar * pBar =
- STATIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- ASSERT_VALID( pBar );
- MdiMenuBarRightButtonsInfo_t _info;
- pBar->_GetMdiMenuBarRightButtonsInfo( _info, this, bHorz );
- //ASSERT( _info.m_bInitialized );
- if( !_info.m_bInitialized )
- return CSize( 1, 1 );
- CSize _size( _info.m_calcSize );
- if( bHorz )
- {
- if( _size.cy < sizePreCalc.cy )
- _size.cy = sizePreCalc.cy;
- }
- else
- {
- if( _size.cx < sizePreCalc.cx )
- _size.cx = sizePreCalc.cx;
- }
-
- m_ActiveSize = _size;
- return _size;
- }
- void CExtBarMdiRightButton::PaintCompound(
- CDC & dc,
- bool bPaintParentChain,
- bool bPaintChildren,
- bool bPaintOneNearestChildrenLevelOnly
- )
- {
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT_VALID( (&dc) );
- ASSERT( CtrlGet() == NULL );
- // ASSERT( ! IsSeparator() );
- if( ! IsPaintAble( dc ) )
- return;
- if( AnimationClient_StatePaint( dc ) )
- return;
- if( bPaintParentChain )
- PaintParentChain( dc );
- CExtMenuControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- ASSERT_VALID( pBar );
- MdiMenuBarRightButtonsInfo_t _info;
- bool bHorz = IsHorzBarOrientation();
- pBar->_GetMdiMenuBarRightButtonsInfo( _info, this, bHorz );
- if( ! _info.m_bInitialized )
- return;
- CRect rcTBB = Rect();
- _info.InitLocations( rcTBB, bHorz );
- CPoint ptCursor( 0, 0 );
- ::GetCursorPos(&ptCursor);
- pBar->ScreenToClient( &ptCursor );
- bool bFlat = true;
- bool bDrawBorder = true;
- int eAlign =
- CExtPaintManager::__ALIGN_HORIZ_CENTER
- | CExtPaintManager::__ALIGN_VERT_CENTER;
- bool bEnabled = IsEnabled() ? true : false;
- bool bChecked =
- ( (GetStyle()&TBBS_CHECKED) != 0 )
- ? true
- : false;
- if( _info.m_bBtnHelp )
- {
- bool bHover =
- (IsHover() && _info.m_rcBtnHelp.PtInRect(ptCursor))
- ? true : false;
- bool bPushed =
- (IsPressed() && _info.m_rcBtnHelp.PtInRect(ptCursor))
- ? true : false;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbdCtxHelp(
- this,
- bHorz ? true : false,
- _info.m_rcBtnHelp,_T(""),NULL,bFlat,
- bHover, bPushed, false, bEnabled,
- bDrawBorder,false,false,eAlign,
- NULL, false, SC_CONTEXTHELP,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbdCtxHelp.m_bChecked = bChecked;
- _ppbdCtxHelp.m_nIconAlignment = CExtPaintManager::__ALIGN_HORIZ_CENTER | CExtPaintManager::__ALIGN_VERT_CENTER;
- pBar->PmBridge_GetPM()->PaintPushButtonMdiRight( dc, _ppbdCtxHelp );
- }
- if( _info.m_bBtnMinimize )
- {
- bool bHover =
- (IsHover() && _info.m_rcBtnRestore.PtInRect(ptCursor))
- ? true : false;
- bool bPushed =
- (IsPressed() && _info.m_rcBtnRestore.PtInRect(ptCursor))
- ? true : false;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbdRestore(
- this,
- bHorz ? true : false,
- _info.m_rcBtnRestore,_T(""),NULL,bFlat,
- bHover, bPushed, false, bEnabled,
- bDrawBorder,false,false,eAlign,
- NULL, false, SC_RESTORE,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbdRestore.m_bChecked = bChecked;
- pBar->PmBridge_GetPM()->PaintPushButtonMdiRight( dc, _ppbdRestore );
- bHover =
- (IsHover() && _info.m_rcBtnMinimize.PtInRect(ptCursor))
- ? true : false;
- bPushed =
- (IsPressed() && _info.m_rcBtnMinimize.PtInRect(ptCursor))
- ? true : false;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbdMinimize(
- this,
- bHorz ? true : false,
- _info.m_rcBtnMinimize,_T(""),NULL,bFlat,
- bHover, bPushed, false, bEnabled,
- bDrawBorder,false,false,eAlign,
- NULL, false, SC_MINIMIZE,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbdMinimize.m_bChecked = bChecked;
- pBar->PmBridge_GetPM()->PaintPushButtonMdiRight( dc, _ppbdMinimize );
- }
- if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize )
- {
- bool bHover =
- (IsHover() && _info.m_rcBtnMaximize.PtInRect(ptCursor))
- ? true : false;
- bool bPushed =
- (IsPressed() && _info.m_rcBtnMaximize.PtInRect(ptCursor))
- ? true : false;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbdMaximize(
- this,
- bHorz ? true : false,
- _info.m_rcBtnMaximize,_T(""),NULL,bFlat,
- bHover, bPushed, false, bEnabled,
- bDrawBorder,false,false,eAlign,
- NULL, false, SC_MAXIMIZE,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbdMaximize.m_bChecked = bChecked;
- pBar->PmBridge_GetPM()->PaintPushButtonMdiRight( dc, _ppbdMaximize );
- }
- if( _info.m_bBtnClose )
- {
- bool bHover =
- (IsHover() && _info.m_rcBtnClose.PtInRect(ptCursor))
- ? true : false;
- bool bPushed =
- (IsPressed() && _info.m_rcBtnClose.PtInRect(ptCursor))
- ? true : false;
- CExtPaintManager::PAINTPUSHBUTTONDATA _ppbdClose(
- this,
- bHorz ? true : false,
- _info.m_rcBtnClose,_T(""),NULL,bFlat,
- bHover, bPushed, false, bEnabled,
- bDrawBorder,false,false,eAlign,
- NULL, false, SC_CLOSE,
- (!bEnabled) || ( bEnabled && (!bHover) && (!bPushed) )
- );
- _ppbdClose.m_bChecked = bChecked;
- pBar->PmBridge_GetPM()->PaintPushButtonMdiRight( dc, _ppbdClose );
- }
- if( bPaintChildren )
- PaintChildren( dc, bPaintOneNearestChildrenLevelOnly );
- }
- UINT CExtBarMdiRightButton::OnTrackPopup(
- CPoint point,
- bool bSelectAny,
- bool bForceNoAnimation
- )
- {
- point;
- bSelectAny;
- bForceNoAnimation;
- return UINT( -1L );
- }
- void CExtBarMdiRightButton::OnClick(
- CPoint point,
- bool bDown
- )
- {
- bool bDockSiteCustomizeMode =
- GetBar()->_IsDockSiteCustomizeMode();
- if( bDockSiteCustomizeMode )
- return;
- if( bDown )
- return;
- // CExtMouseCaptureSink::ReleaseCapture();
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT( CtrlGet() == NULL );
- ASSERT( ! IsSeparator() );
- CExtMenuControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- ASSERT_VALID( pBar );
- BOOL bHorz = !pBar->IsDockedVertically();
- MdiMenuBarRightButtonsInfo_t _info;
- pBar->_GetMdiMenuBarRightButtonsInfo( _info, this, bHorz );
- if( !_info.m_bInitialized )
- return;
- _info.InitLocations( Rect(), bHorz );
- bool bInstallHideFlag = false;
- UINT nHelperSysCmdID = 0;
- if( _info.m_bBtnHelp
- && _info.m_rcBtnHelp.PtInRect(point)
- )
- nHelperSysCmdID = SC_CONTEXTHELP;
- else if( _info.m_bBtnMinimize
- && _info.m_rcBtnRestore.PtInRect(point)
- )
- {
- nHelperSysCmdID = SC_RESTORE;
- bInstallHideFlag = true;
- }
- else if( _info.m_bBtnMinimize
- && _info.m_rcBtnMinimize.PtInRect(point)
- )
- {
- nHelperSysCmdID = SC_MINIMIZE;
- bInstallHideFlag = true;
- }
- else if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize
- && _info.m_rcBtnMaximize.PtInRect(point)
- )
- nHelperSysCmdID = SC_MAXIMIZE;
- else if( _info.m_bBtnClose
- && _info.m_rcBtnClose.PtInRect(point)
- )
- nHelperSysCmdID = SC_CLOSE;
- if( nHelperSysCmdID == 0 )
- return;
- HWND hWndActiveChild = _ActiveMdiChildWndGet();
- if( hWndActiveChild == NULL )
- return;
- ASSERT( ::IsWindow( hWndActiveChild ) );
- if( bInstallHideFlag )
- {
- Show( FALSE );
- ASSERT( GetBar()->GetButtonsCount() > 0 );
- CExtBarButton * pTBB = GetBar()->GetButton( 0 );
- ASSERT_VALID( pTBB );
- if( pTBB->IsVisible()
- && pTBB->IsKindOf( RUNTIME_CLASS(CExtBarMdiDocButton) )
- )
- {
- pTBB->Show( FALSE );
- }
- // GetBar()->Invalidate();
- // GetBar()->UpdateWindow();
- // GetBar()->GetParentFrame()->DelayRecalcLayout();
- }
- if( nHelperSysCmdID == SC_MAXIMIZE )
- {
- HWND hWndMdiClientArea =
- ::GetParent( hWndActiveChild );
- ASSERT( hWndMdiClientArea != NULL );
- ASSERT( ::IsWindow( hWndMdiClientArea ) );
- ::PostMessage(
- hWndMdiClientArea,
- WM_MDIRESTORE,
- (WPARAM)hWndActiveChild,
- 0
- );
- } // if( nHelperSysCmdID == SC_MAXIMIZE )
- else
- {
- pBar->ClientToScreen( &point );
- pBar->_DelayUpdateMenuBar();
- ::SendMessage(
- hWndActiveChild,
- WM_SYSCOMMAND,
- nHelperSysCmdID,
- MAKELONG( point.x, point.y )
- );
- } // else
- }
- bool CExtBarMdiRightButton::OnDblClick(
- CPoint point
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- point;
- return false;
- }
- __EXT_MFC_INT_PTR CExtBarMdiRightButton::OnToolHitTest(
- CPoint point,
- TOOLINFO * pTI
- )
- {
- ASSERT_VALID( this );
- ASSERT_VALID( GetBar() );
- ASSERT( GetBar()->IsKindOf(RUNTIME_CLASS(CExtMenuControlBar)) );
- ASSERT( CtrlGet() == NULL );
- ASSERT( ! IsSeparator() );
- CExtMenuControlBar * pBar =
- DYNAMIC_DOWNCAST(
- CExtMenuControlBar,
- GetBar()
- );
- ASSERT_VALID( pBar );
- BOOL bHorz = !pBar->IsDockedVertically();
- MdiMenuBarRightButtonsInfo_t _info;
- pBar->_GetMdiMenuBarRightButtonsInfo( _info, this, bHorz );
- if( !_info.m_bInitialized )
- return -1;
- _info.InitLocations( Rect(), bHorz );
- if( _info.m_bBtnHelp
- && _info.m_rcBtnHelp.PtInRect(point)
- )
- {
- if( pTI != NULL )
- {
- ::CopyRect(
- &(pTI->rect),
- &_info.m_rcBtnHelp
- );
- CExtSafeString str;
- if( g_ResourceManager->LoadString( str, ID_CONTEXT_HELP ) )
- pTI->lpszText = (LPTSTR)
- ::calloc( (str.GetLength() + 1), sizeof(TCHAR) );
- if( pTI->lpszText != NULL )
- __EXT_MFC_STRCPY( pTI->lpszText, str.GetLength() + 1, str );
- else
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- }
- return ((__EXT_MFC_INT_PTR)ID_CONTEXT_HELP);
- }
- if( _info.m_bBtnMinimize
- && _info.m_rcBtnRestore.PtInRect(point)
- )
- {
- if( pTI != NULL )
- {
- ::CopyRect(
- &(pTI->rect),
- &_info.m_rcBtnRestore
- );
- CExtSafeString str;
- if( g_ResourceManager->LoadString( str, AFX_IDS_SCRESTORE ) )
- pTI->lpszText = (LPTSTR)
- ::calloc( (str.GetLength() + 1), sizeof(TCHAR) );
- if( pTI->lpszText != NULL )
- __EXT_MFC_STRCPY( pTI->lpszText, str.GetLength() + 1, str );
- else
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- }
- return ((int)AFX_IDS_SCRESTORE);
- }
- if( _info.m_bBtnMinimize
- && _info.m_rcBtnMinimize.PtInRect(point)
- )
- {
- if( pTI != NULL )
- {
- ::CopyRect(
- &(pTI->rect),
- &_info.m_rcBtnMinimize
- );
- CExtSafeString str;
- if( g_ResourceManager->LoadString( str, AFX_IDS_SCMINIMIZE ) )
- pTI->lpszText = (LPTSTR)
- ::calloc( (str.GetLength() + 1), sizeof(TCHAR) );
- if( pTI->lpszText != NULL )
- __EXT_MFC_STRCPY( pTI->lpszText, str.GetLength() + 1, str );
- else
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- }
- return ((__EXT_MFC_INT_PTR)AFX_IDS_SCMINIMIZE);
- }
- if( _info.m_bBtnMaximize && !_info.m_bBtnMinimize
- && _info.m_rcBtnMaximize.PtInRect(point)
- )
- {
- if( pTI != NULL )
- {
- ::CopyRect(
- &(pTI->rect),
- &_info.m_rcBtnMaximize
- );
- CExtSafeString str;
- if( g_ResourceManager->LoadString( str, AFX_IDS_SCMAXIMIZE ) )
- pTI->lpszText = (LPTSTR)
- ::calloc( (str.GetLength() + 1), sizeof(TCHAR) );
- if( pTI->lpszText != NULL )
- __EXT_MFC_STRCPY( pTI->lpszText, str.GetLength() + 1, str );
- else
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- }
- return ((__EXT_MFC_INT_PTR)AFX_IDS_SCMAXIMIZE);
- }
- if( _info.m_bBtnClose
- && _info.m_rcBtnClose.PtInRect(point)
- )
- {
- if( pTI != NULL )
- {
- ::CopyRect(
- &(pTI->rect),
- &_info.m_rcBtnClose
- );
- CExtSafeString str;
- if( g_ResourceManager->LoadString( str, AFX_IDS_SCCLOSE ) )
- pTI->lpszText = (LPTSTR)
- ::calloc( (str.GetLength() + 1), sizeof(TCHAR) );
- if( pTI->lpszText != NULL )
- __EXT_MFC_STRCPY( pTI->lpszText, str.GetLength() + 1, str );
- else
- pTI->lpszText = LPSTR_TEXTCALLBACK;
- }
- return ((__EXT_MFC_INT_PTR)AFX_IDS_SCCLOSE);
- }
- return -1;
- }
- bool CExtBarMdiRightButton::CanStartCommandDrag()
- {
- ASSERT_VALID( this );
- return false;
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeCmdTreeNode * CExtBarMdiRightButton::GetCmdNode(
- bool bInitial // = false
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // bInitial;
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // return NULL;
- return CExtBarMdiDocButton::GetCmdNode( bInitial );
- }
- void CExtBarMdiRightButton::SetBasicCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // ASSERT( FALSE ); // should be never called
- // pNode;
- CExtBarMdiDocButton::SetBasicCmdNode( pNode );
- }
- void CExtBarMdiRightButton::SetCustomizedCmdNode(
- CExtCustomizeCmdTreeNode * pNode
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( m_pCmdNodeI == NULL );
- // ASSERT( m_pCmdNodeC == NULL );
- // ASSERT( FALSE ); // should be never called
- // pNode;
- CExtBarMdiDocButton::SetCustomizedCmdNode( pNode );
- }
- CExtCustomizeCmdTreeNode * CExtBarMdiRightButton::OnCustomizeNodeInit(
- CExtCustomizeSite * pSite,
- CExtCustomizeCmdTreeNode * pParentNode // toolbar node
- )
- {
- ASSERT_VALID( this );
- // ASSERT_VALID( GetBar() );
- // ASSERT( pSite != NULL );
- // ASSERT_VALID( pParentNode );
- // pSite;
- // pParentNode;
- // return NULL; // no customization support
- return CExtBarMdiDocButton::OnCustomizeNodeInit( pSite, pParentNode );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- bool CExtBarMdiRightButton::OnQueryFlatTrackingEnabled() const
- {
- ASSERT_VALID( this );
- return false;
- }
- LRESULT CExtBarMdiRightButton::OnHelpHitTest(
- CPoint point
- )
- {
- ASSERT_VALID( this );
- return (LRESULT)OnToolHitTest(point,NULL);
- }
- void CExtMenuControlBar::_KillFrameMenu()
- {
- if( m_bPresubclassDialogMode )
- return;
- if( IsOleIpObjActive() )
- return;
- CFrameWnd * pFrame = _GetDockingFrameImpl();
- ASSERT_VALID( pFrame );
- HWND hWndFrame = pFrame->GetSafeHwnd();
- ASSERT( hWndFrame != NULL );
- ASSERT( ::IsWindow(hWndFrame) );
- HMENU hFrameRealMenu = ::GetMenu( hWndFrame );
- if( hFrameRealMenu == NULL )
- return;
- ::SetMenu( hWndFrame, NULL );
- _DelayUpdateMenuBar();
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtMenuControlBar::OnCustomizeModeEnter()
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnCustomizeModeEnter();
- }
- void CExtMenuControlBar::OnCustomizeModeLeave()
- {
- ASSERT_VALID( this );
- CExtToolControlBar::OnCustomizeModeLeave();
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtMenuControlBar::PreSubclassWindow()
- {
- CExtToolControlBar::PreSubclassWindow();
- m_bHelperTrackingCharCode = false;
- if( m_bPresubclassDialogMode && m_hWndHelper == NULL )
- {
- m_hWndHelper = ::GetParent( m_hWnd );
- if( m_hWndHelper != NULL )
- {
- ASSERT( ::IsWindow( m_hWndHelper ) );
- if( !IsHookedWindow( m_hWndHelper ) )
- SetupHookWndSink( m_hWndHelper );
- }
- } // if( m_bPresubclassDialogMode && m_hWndHelper == NULL )
- }
- BOOL CExtMenuControlBar::PreTranslateMessage(MSG* pMsg)
- {
- if( m_bPresubclassDialogMode )
- {
- if( TranslateMainFrameMessage(pMsg) )
- return TRUE;
- }
-
- return CExtToolControlBar::PreTranslateMessage(pMsg);
- }
- #if (!defined __EXT_MFC_NO_CUSTOMIZE)
- CExtCustomizeSite::CCmdMenuInfo * CExtMenuControlBar::MenuInfoGet()
- {
- ASSERT_VALID( this );
- return m_pMenuInfo;
- }
- CExtCustomizeSite::CCmdMenuInfo * CExtMenuControlBar::MenuInfoDetach()
- {
- ASSERT_VALID( this );
- CExtCustomizeSite::CCmdMenuInfo * pMenuInfo = m_pMenuInfo;
- m_pMenuInfo = NULL;
- return pMenuInfo;
- }
- CExtCustomizeSite::CCmdMenuInfo * CExtMenuControlBar::MenuInfoAttach(
- CExtCustomizeSite::CCmdMenuInfo * pMenuInfo
- )
- {
- ASSERT_VALID( this );
- CExtCustomizeSite::CCmdMenuInfo * pMenuInfoOld = m_pMenuInfo;
- m_pMenuInfo = pMenuInfo;
- return pMenuInfoOld;
- }
- void CExtMenuControlBar::MenuInfoUpdate()
- {
- ASSERT_VALID( this );
- CExtCustomizeSite * pSite =
- GetCustomizeSite();
- if( pSite == NULL )
- return;
- CExtCustomizeSite::CCmdMenuInfo * pMenuInfo =
- pSite->MenuInfoFindForMenuBar();
- if( ((LPVOID)pMenuInfo) != ((LPVOID)MenuInfoGet()) )
- MenuInfoAttach( pMenuInfo );
- }
- #endif // (!defined __EXT_MFC_NO_CUSTOMIZE)
- void CExtMenuControlBar::SetMdiWindowPopupName(
- __EXT_MFC_SAFE_LPCTSTR sMdiWindowPopupName // = NULL
- )
- {
- ASSERT_VALID( this );
- m_sMdiWindowPopupName =
- ( sMdiWindowPopupName != NULL )
- ? sMdiWindowPopupName
- : _T("")
- ;
- m_sMdiWindowPopupName.TrimLeft();
- m_sMdiWindowPopupName.TrimRight();
- while( m_sMdiWindowPopupName.Replace( _T("&"), _T("") ) > 0 )
- {
- m_sMdiWindowPopupName.TrimLeft();
- m_sMdiWindowPopupName.TrimRight();
- }
- }