//******************************************************************************
void CBCGPDragFrameImpl::RemoveTabPreDocking (CBCGPDockingControlBar* pOldTargetBar)
{
	if (pOldTargetBar == NULL)
	{
		pOldTargetBar = m_pOldTargetBar;
	}

	if (pOldTargetBar != NULL && m_nInsertedTabID != -1)
	{
	    CBCGPBaseTabbedBar* pOldTabbedBar = 
			    DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, pOldTargetBar);
		if (pOldTabbedBar != NULL && !m_bFrameTabDrawn && m_pWndDummy != NULL && m_pWndDummy->GetSafeHwnd () != NULL)
		{
			CBCGPSmartDockingManager* pSDManager = NULL;
			BOOL bSDockingIsOn = FALSE;

			if (m_pDockManager != NULL
				&& (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
				&& pSDManager->IsStarted())
			{
				bSDockingIsOn = TRUE;
			}

			m_pWndDummy->ShowWindow (SW_HIDE);
			if (!bSDockingIsOn)
			{
				m_pDockManager->LockUpdate (FALSE);
			}
			CWnd* pWnd = pOldTabbedBar->GetUnderlinedWindow ()->GetTabWnd (m_nInsertedTabID);
			if (pWnd == m_pWndDummy)
			{
				pOldTabbedBar->GetUnderlinedWindow ()->RemoveTab (m_nInsertedTabID);
			}
			if (!bSDockingIsOn)
			{
				m_pDockManager->LockUpdate (TRUE);
			}
		}
		else
		{
			DrawFrameTab (pOldTargetBar, TRUE);
		}

		CBCGPSmartDockingManager* pSDManager = NULL;

		if ((pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
			&& pSDManager->IsStarted())
		{
			m_pDraggedWnd->ShowWindow (SW_SHOW);
		}
	}

	m_nInsertedTabID = -1;
	m_pOldTargetBar = NULL;
}
//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::DrawDragFrame (LPCRECT lpRectOld, LPCRECT lpRectNew, 
										BOOL bFirstTime, int nNewThickness, 
										int nOldThikness)
{
	CWindowDC dc (m_pDraggedWnd->GetDesktopWindow ());

	CSize szNewThickness (nNewThickness, nNewThickness);
	CSize szOldThickness (nOldThikness, nOldThikness);

    CBCGPSmartDockingManager* pSDManager = NULL;

    if (m_pDockManager != NULL
        && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        pSDManager->ShowPlaceAt (lpRectNew);
    } 
	else
	{
		if (bFirstTime)
		{
			dc.DrawDragRect (lpRectNew, szNewThickness, NULL, szOldThickness);
		}
		else
		{
			dc.DrawDragRect (lpRectNew, szNewThickness, lpRectOld, szOldThickness);
		}
	}
}
//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::EndDrawDragFrame (BOOL bClearInternalRects)
{
	if (m_pDockManager == NULL)
	{
		return;
	}

    BOOL bSDockingIsOn = FALSE;
    CBCGPSmartDockingManager* pSDManager = NULL;

    if ((pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        bSDockingIsOn = TRUE;
        pSDManager->HidePlace ();
    }

	CRect rectEmpty; rectEmpty.SetRectEmpty ();
	CRect rectDocked = m_rectExpectedDocked.IsRectEmpty () ? m_rectDrag : 
															 m_rectExpectedDocked;

	// do not draw the final frame (meaning - clear) if it was not drawn because of tab
	if (m_nInsertedTabID == -1)
	{
        if (!bSDockingIsOn)
        {
		    DrawDragFrame (rectEmpty, rectDocked, 0, m_nOldThikness);
        }
	}
	else
	{
		m_bDockToTab = TRUE;
	}
	
	if (bClearInternalRects)
	{
        RemoveTabPreDocking ();

		m_rectExpectedDocked.SetRectEmpty ();
		m_rectDrag.SetRectEmpty ();

		m_pFinalTargetBar = m_pTargetBar;
		m_pTargetBar = NULL;
	}

	m_bDragStarted = FALSE;
	
	ASSERT (m_pDockManager != NULL);
	if (!bSDockingIsOn)
	{
		m_pDockManager->LockUpdate (FALSE);
	}
}
//******************************************************************************
void CBCGPDragFrameImpl::PlaceTabPreDocking (CBCGPBaseTabbedBar* pTabbedBar, BOOL bFirstTime)
{
	if (m_nInsertedTabID != -1)
	{
		return;
	}
	if (!bFirstTime)
	{
		EndDrawDragFrame (FALSE);
	}
	CString strLabel;
	if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMultiMiniFrameWnd)))
	{
		CBCGPMultiMiniFrameWnd* pMultiMiniFrame = 
			DYNAMIC_DOWNCAST (CBCGPMultiMiniFrameWnd, m_pDraggedWnd);
		if (pMultiMiniFrame != NULL)
		{
			CWnd* pBar = pMultiMiniFrame->GetFirstVisibleBar ();
			ASSERT_VALID (pBar);

			if (pBar != NULL)
			{
				pBar->GetWindowText (strLabel);
			}
		}
	}
	else
	{
		m_pDraggedWnd->GetWindowText (strLabel);
	}	
	
	if (m_pWndDummy == NULL)
	{
		m_pWndDummy = new CBCGPDummyDockingControlBar;
		m_pWndDummy->CreateEx (0, _T (""), BCGCBProGetTopLevelFrame (m_pDraggedWnd), CRect (0, 0, 0, 0), 
							FALSE, BCGP_DUMMY_WND_ID, WS_CHILD);
	}

	pTabbedBar->GetUnderlinedWindow ()->AddTab (m_pWndDummy, strLabel);
	
	CBCGPSmartDockingManager* pSDManager = NULL;
	if ((pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
		&& pSDManager->IsStarted())
	{
		m_pDraggedWnd->ShowWindow (SW_HIDE);
	}

	m_nInsertedTabID = pTabbedBar->GetUnderlinedWindow ()->GetTabFromHwnd (*m_pWndDummy);
	m_pOldTargetBar = pTabbedBar;
}
示例#5
0
//------------------------------------------------------------------------//
BOOL CBCGPGlobalUtils::CheckAlignment (CPoint point, CBCGPBaseControlBar* pBar, int nSencitivity, 
                                       const CBCGPDockManager* pDockManager,
									   BOOL bOuterEdge, DWORD& dwAlignment, 
									   DWORD dwEnabledDockBars, LPCRECT lpRectBounds) const
{
    BOOL bSmartDocking = FALSE;
    CBCGPSmartDockingMarker::SDMarkerPlace nHilitedSide = CBCGPSmartDockingMarker::sdNONE;
	
	if (pDockManager == NULL && pBar != NULL)
    {
        pDockManager = globalUtils.GetDockManager (pBar->GetParent());
    }
	
	if (pDockManager != NULL)
	{
        CBCGPSmartDockingManager* pSDManager = pDockManager->GetSDManagerPermanent ();
        if (pSDManager != NULL && pSDManager->IsStarted ())
        {
            bSmartDocking = TRUE;
            nHilitedSide = pSDManager->GetHilitedMarkerNo ();
        }
	}
	
	CRect rectBounds;
	if (pBar != NULL)
	{
		pBar->GetWindowRect (rectBounds);
		
	}
	else if (lpRectBounds != NULL)
	{
		rectBounds = *lpRectBounds;
	}
	else
	{
		ASSERT(FALSE);
		return FALSE;
	}
	
	int nCaptionHeight = 0;
	int nTabAreaTopHeight = 0; 
	int nTabAreaBottomHeight = 0;
	
	CBCGPDockingControlBar* pDockingBar = 
		DYNAMIC_DOWNCAST (CBCGPDockingControlBar, pBar);
	
	if (pDockingBar != NULL)
	{
		nCaptionHeight = pDockingBar->GetCaptionHeight ();
		
		CRect rectTabAreaTop;
		CRect rectTabAreaBottom;
		pDockingBar->GetTabArea (rectTabAreaTop, rectTabAreaBottom);
		nTabAreaTopHeight = rectTabAreaTop.Height ();
		nTabAreaBottomHeight = rectTabAreaBottom.Height ();
	}
	
	// build rect for top area
	if (bOuterEdge)
	{
        if (bSmartDocking)
        {
            switch (nHilitedSide)
            {
            case CBCGPSmartDockingMarker::sdLEFT:
				dwAlignment = CBRS_ALIGN_LEFT;
				return TRUE;
            case CBCGPSmartDockingMarker::sdRIGHT:
				dwAlignment = CBRS_ALIGN_RIGHT;
				return TRUE;
            case CBCGPSmartDockingMarker::sdTOP:
				dwAlignment = CBRS_ALIGN_TOP;
				return TRUE;
            case CBCGPSmartDockingMarker::sdBOTTOM:
				dwAlignment = CBRS_ALIGN_BOTTOM;
				return TRUE;
            }
        }
		else
        {
			CRect rectToCheck (rectBounds.left - nSencitivity, rectBounds.top - nSencitivity, 
				rectBounds.right + nSencitivity, rectBounds.top);
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_TOP)
			{
				dwAlignment = CBRS_ALIGN_TOP;
				return TRUE;
			}
			
			// build rect for left area
			rectToCheck.right = rectBounds.left;
			rectToCheck.bottom = rectBounds.bottom + nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_LEFT)
			{
				dwAlignment = CBRS_ALIGN_LEFT;
				return TRUE;
			}
			
			// build rect for bottom area
			rectToCheck.left = rectBounds.left - nSencitivity;
			rectToCheck.top = rectBounds.bottom;
			rectToCheck.right = rectBounds.right + nSencitivity;
			rectToCheck.bottom = rectBounds.bottom + nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_BOTTOM)
			{
				dwAlignment = CBRS_ALIGN_BOTTOM;
				return TRUE;
			}
			
			// build rect for right area
			rectToCheck.left = rectBounds.right;
			rectToCheck.top = rectBounds.top - nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_RIGHT)
			{
				dwAlignment = CBRS_ALIGN_RIGHT;
				return TRUE;
			}
        }
	}
	else
	{
        if (bSmartDocking)
        {
            switch (nHilitedSide)
            {
            case CBCGPSmartDockingMarker::sdCLEFT:
				dwAlignment = CBRS_ALIGN_LEFT;
				return TRUE;
            case CBCGPSmartDockingMarker::sdCRIGHT:
				dwAlignment = CBRS_ALIGN_RIGHT;
				return TRUE;
            case CBCGPSmartDockingMarker::sdCTOP:
				dwAlignment = CBRS_ALIGN_TOP;
				return TRUE;
            case CBCGPSmartDockingMarker::sdCBOTTOM:
				dwAlignment = CBRS_ALIGN_BOTTOM;
				return TRUE;
            }
        }
		else
        {
#ifdef __BOUNDS_FIX__
			CRect rectToCheck (rectBounds.left, rectBounds.top, 
				rectBounds.right, 
				rectBounds.top + nSencitivity + nCaptionHeight);
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_TOP)
			{
				dwAlignment = CBRS_ALIGN_TOP;
				return TRUE;
			}
			
			
			// build rect for left area
			rectToCheck.right = rectBounds.left + nSencitivity;
			rectToCheck.bottom = rectBounds.bottom + nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_LEFT)
			{
				dwAlignment = CBRS_ALIGN_LEFT;
				return TRUE;
			}
			
			// build rect for bottom area
			rectToCheck.left = rectBounds.left;
			rectToCheck.top = rectBounds.bottom - nSencitivity - nTabAreaBottomHeight;
			rectToCheck.right = rectBounds.right;
			rectToCheck.bottom = rectBounds.bottom;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_BOTTOM)
			{
				dwAlignment = CBRS_ALIGN_BOTTOM;
				return TRUE;
			}
			
			// build rect for right area
			rectToCheck.left = rectBounds.right - nSencitivity;
			rectToCheck.top = rectBounds.top - nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_RIGHT)
			{
				dwAlignment = CBRS_ALIGN_RIGHT;
				return TRUE;
			}
#else
			
			// build rect for top area
			CRect rectToCheck (rectBounds.left - nSencitivity, rectBounds.top - nSencitivity, 
				rectBounds.right + nSencitivity, 
				rectBounds.top + nSencitivity + nCaptionHeight);
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_TOP)
			{
				dwAlignment = CBRS_ALIGN_TOP;
				return TRUE;
			}
			
			
			// build rect for left area
			rectToCheck.right = rectBounds.left + nSencitivity;
			rectToCheck.bottom = rectBounds.bottom + nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_LEFT)
			{
				dwAlignment = CBRS_ALIGN_LEFT;
				return TRUE;
			}
			
			// build rect for bottom area
			rectToCheck.left = rectBounds.left - nSencitivity;
			rectToCheck.top = rectBounds.bottom - nSencitivity - nTabAreaBottomHeight;
			rectToCheck.right = rectBounds.right + nSencitivity;
			rectToCheck.bottom = rectBounds.bottom + nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_BOTTOM)
			{
				dwAlignment = CBRS_ALIGN_BOTTOM;
				return TRUE;
			}
			
			// build rect for right area
			rectToCheck.left = rectBounds.right - nSencitivity;
			rectToCheck.top = rectBounds.top - nSencitivity;
			
			if (rectToCheck.PtInRect (point) && dwEnabledDockBars & CBRS_ALIGN_RIGHT)
			{
				dwAlignment = CBRS_ALIGN_RIGHT;
				return TRUE;
			}
#endif		
        }
	}
	
	return FALSE;
}
//*******************************************************************************************
BOOL CBCGPFrameWnd::PreTranslateMessage(MSG* pMsg)
{
    BOOL bProcessAccel = TRUE;

    switch (pMsg->message)
    {
    case WM_SYSKEYDOWN:
#ifndef BCGP_EXCLUDE_RIBBON
        if (m_Impl.m_pRibbonBar != NULL && m_Impl.m_pRibbonBar->OnSysKeyDown (this, pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }

        if (pMsg->wParam == VK_F4 && m_Impl.m_pRibbonBar != NULL && m_Impl.m_pRibbonBar->IsBackstageViewActive())
        {
            break;
        }
#endif
        if (CBCGPPopupMenu::GetSafeActivePopupMenu() == NULL)
        {
            m_Impl.CancelToolbarMode();
        }

    case WM_CONTEXTMENU:
        if (!globalData.m_bSysUnderlineKeyboardShortcuts && !globalData.m_bUnderlineKeyboardShortcuts)
        {
            globalData.m_bUnderlineKeyboardShortcuts = TRUE;
            CBCGPToolBar::RedrawUnderlines ();
        }

        if (CBCGPPopupMenu::GetSafeActivePopupMenu() != NULL && (pMsg->wParam == VK_MENU || pMsg->wParam == VK_F10))
        {
            CBCGPPopupMenu::m_pActivePopupMenu->SendMessage (WM_CLOSE);
            return TRUE;
        }
        else if (m_Impl.ProcessKeyboard ((int) pMsg->wParam))
        {
            return TRUE;
        }
        break;

    case WM_SYSKEYUP:
        if (m_Impl.ProcessSysKeyUp(pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }
        break;

    case WM_KEYDOWN:
        //-----------------------------------------
        // Pass keyboard action to the active menu:
        //-----------------------------------------
        if (!CBCGPFrameImpl::IsHelpKey (pMsg) &&
                m_Impl.ProcessKeyboard ((int) pMsg->wParam, &bProcessAccel))
        {
            return TRUE;
        }

        if (pMsg->wParam == VK_ESCAPE)
        {
            if (IsFullScreen())
            {
                if (!IsPrintPreview())
                {
                    m_Impl.InvokeFullScreenCommand();
                    return TRUE;
                }
            }

            CBCGPSmartDockingManager* pSDManager = NULL;
            if ((pSDManager = m_dockManager.GetSDManagerPermanent()) != NULL &&
                    pSDManager->IsStarted())
            {
                pSDManager->CauseCancelMode ();
            }

            CBCGPSlider* pSlider = DYNAMIC_DOWNCAST (CBCGPSlider, GetCapture ());
            if (pSlider != NULL)
            {
                pSlider->SendMessage (WM_CANCELMODE);
                return TRUE;
            }
        }

        if (!bProcessAccel)
        {
            return FALSE;
        }
        break;

    case WM_LBUTTONDOWN:
    case WM_RBUTTONDOWN:
    case WM_RBUTTONUP:
    case WM_MBUTTONDOWN:
    case WM_MBUTTONUP:
    {
        CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
        CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd);

        if (pWnd != NULL && ::IsWindow (pMsg->hwnd))
        {
            pWnd->ClientToScreen (&pt);
        }

        if (m_Impl.ProcessMouseClick (pMsg->message, pt, pMsg->hwnd))
        {
            return TRUE;
        }

        if (!::IsWindow (pMsg->hwnd))
        {
            return TRUE;
        }
    }
    break;

    case WM_NCLBUTTONDOWN:
    case WM_NCLBUTTONUP:
    case WM_NCRBUTTONDOWN:
    case WM_NCRBUTTONUP:
    case WM_NCMBUTTONDOWN:
    case WM_NCMBUTTONUP:
        if (m_Impl.ProcessMouseClick (pMsg->message,
                                      CPoint (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)),
                                      pMsg->hwnd))
        {
            return TRUE;
        }
        break;

    case WM_MOUSEWHEEL:
        if (m_Impl.ProcessMouseWheel (pMsg->wParam, pMsg->lParam))
        {
            return TRUE;
        }
        break;

    case WM_MOUSEMOVE:
    {
        CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam));
        CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd);

        if (pWnd != NULL)
        {
            pWnd->ClientToScreen (&pt);
        }

        if (m_Impl.ProcessMouseMove (pt))
        {
            return TRUE;
        }
    }
    }

    return CFrameWnd::PreTranslateMessage(pMsg);
}
//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::DrawFrameTab (CBCGPDockingControlBar* pTargetBar, BOOL bErase)
{
	CRect rectWnd;
	pTargetBar->GetWindowRect (rectWnd);
	
    CBCGPSmartDockingManager* pSDManager = NULL;
    BOOL bSDockingIsOn = FALSE;

    if (m_pDockManager != NULL
        && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        bSDockingIsOn = TRUE;
    }

	int nThikness = globalData.m_nDragFrameThiknessDock;
	CRect rectSmallTab = rectWnd;
	// to be changed to tab height
	
	if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
	{
		rectWnd.top += globalData.GetTextHeight ();  
		rectSmallTab.bottom = rectSmallTab.top + globalData.GetTextHeight (); 
		rectSmallTab.left += 10;
		rectSmallTab.right = rectSmallTab.left + 40;
	}
	else
	{
		rectWnd.bottom -= globalData.GetTextHeight ();  
		rectSmallTab.top = rectSmallTab.bottom - globalData.GetTextHeight (); 
		rectSmallTab.left += 10;
		rectSmallTab.right = rectSmallTab.left + 40;
	}

	if (rectSmallTab.right >= rectWnd.right)
	{
		rectSmallTab.right = rectWnd.right - nThikness - 4;
	}

	CRect rectEmpty; rectEmpty.SetRectEmpty ();
	

	CRect rectLine; 
	if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
	{
		rectLine.SetRect (rectSmallTab.left + nThikness, 
							rectSmallTab.bottom - nThikness,  
							rectSmallTab.right - nThikness, 
							rectSmallTab.bottom + nThikness);
	}
	else
	{
		rectLine.SetRect (rectSmallTab.left + nThikness, 
							rectSmallTab.top  - nThikness,  
							rectSmallTab.right - nThikness, 
							rectSmallTab.top + nThikness);
	}

	if (bErase)
	{
        if (bSDockingIsOn)
        {
            pSDManager->HidePlace ();
        } 
		else
        {
			DrawDragFrame (rectEmpty, rectSmallTab, FALSE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectWnd, FALSE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectLine, FALSE, nThikness, nThikness);
			m_bFrameTabDrawn = FALSE;
        }
	}
	else
	{
        if (bSDockingIsOn)
        {
            pSDManager->ShowTabbedPlaceAt (&rectWnd, 10, rectSmallTab.Width(), rectSmallTab.Height());
        } 
		else
        {
			
			DrawDragFrame (rectEmpty, rectSmallTab, TRUE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectWnd, TRUE, nThikness, nThikness);
			DrawDragFrame (rectEmpty, rectLine, TRUE, nThikness, nThikness);
			m_bFrameTabDrawn = TRUE;
        }
	}
}
//--------------------------------------------------------------------------------------//
void CBCGPDragFrameImpl::MoveDragFrame (BOOL bForceMove)
{
	ASSERT_VALID (m_pDraggedWnd);

	m_pFinalTargetBar = NULL;

	if (m_pDraggedWnd == NULL || m_pDockManager == NULL)
	{
		return;
	}

	if (m_pWndDummy == NULL)
	{
		m_pWndDummy = new CBCGPDummyDockingControlBar;
		m_pWndDummy->CreateEx (0, _T (""), BCGCBProGetTopLevelFrame (m_pDraggedWnd), CRect (0, 0, 0, 0), 
							FALSE, BCGP_DUMMY_WND_ID, WS_CHILD);
	}

	CSize szSencitivity = CBCGPDockingControlBar::GetDragSencitivity ();

	CPoint ptMouse;
	GetCursorPos (&ptMouse);

	CPoint ptOffset = ptMouse - m_ptHot;

	if (abs (ptOffset.x) < szSencitivity.cx && 
		abs (ptOffset.y) < szSencitivity.cy && 
		m_rectDrag.IsRectEmpty () && !bForceMove)
	{
		return;
	}

	m_bDragStarted = TRUE;
	
	m_pDockManager->LockUpdate (TRUE);
		
	CRect rectOld = m_rectExpectedDocked.IsRectEmpty () ? m_rectDrag : m_rectExpectedDocked;
	BOOL bFirstTime = FALSE;

	if (m_rectDrag.IsRectEmpty ())
	{
		if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd)))
		{
			m_pDraggedWnd->GetWindowRect (m_rectDrag);
		}
		else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar)))
		{
			CBCGPControlBar* pBar = 
				DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd);
			ASSERT_VALID (pBar);
			m_pDraggedWnd->GetWindowRect (m_rectDrag);

			// if the bar is docked then the floating rect has to be set to recent floating rect
			if (pBar->GetParentMiniFrame () == NULL)
			{
				m_rectDrag.right = 
					m_rectDrag.left + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Width ();
				m_rectDrag.bottom = 
					m_rectDrag.top + pBar->m_recentDockInfo.m_rectRecentFloatingRect.Height ();
			}

			if (!m_rectDrag.PtInRect (m_ptHot))
			{
				int nOffset = m_rectDrag.left - m_ptHot.x;
				m_rectDrag.OffsetRect (-nOffset - 5, 0); // offset of mouse pointer 
														 // from the drag rect bound
			}
		}
		bFirstTime = TRUE;
	}


	BOOL bDrawTab = FALSE;
	CBCGPDockingControlBar* pOldTargetBar = m_pTargetBar;
	CRect rectExpected; rectExpected.SetRectEmpty ();

    CBCGPSmartDockingManager* pSDManager = NULL;
    BOOL bSDockingIsOn = FALSE;

    if (m_pDockManager != NULL
        && (pSDManager = m_pDockManager->GetSDManagerPermanent()) != NULL
        && pSDManager->IsStarted())
    {
        bSDockingIsOn = TRUE;
    }

	
	m_pDockManager->CalcExpectedDockedRect (m_pDraggedWnd, ptMouse, 
							rectExpected, bDrawTab, &m_pTargetBar);

	if (pOldTargetBar != NULL && m_nInsertedTabID != -1 && 
		(pOldTargetBar != m_pTargetBar || !bDrawTab))
	{
        RemoveTabPreDocking (pOldTargetBar);
		bFirstTime = TRUE;
	}

	BOOL bCanBeAttached = TRUE;
	if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPMiniFrameWnd)))
	{
	}
	else if (m_pDraggedWnd->IsKindOf (RUNTIME_CLASS (CBCGPControlBar)))
	{
		CBCGPControlBar* pBar = 
			DYNAMIC_DOWNCAST (CBCGPControlBar, m_pDraggedWnd);
		bCanBeAttached = pBar->CanBeAttached ();
	}

	if (m_pTargetBar != NULL && bCanBeAttached)
	{
		CBCGPBaseTabbedBar* pTabbedBar = 
				DYNAMIC_DOWNCAST (CBCGPBaseTabbedBar, m_pTargetBar);
		if (pTabbedBar != NULL && bDrawTab && 
			 (pTabbedBar->GetVisibleTabsNum () > 1 && pTabbedBar->IsHideSingleTab () ||
			  pTabbedBar->GetVisibleTabsNum () > 0 && !pTabbedBar->IsHideSingleTab ()))
		{
			PlaceTabPreDocking (pTabbedBar, bFirstTime);
			return;
		}
		else if (bDrawTab)
		{
			if (m_nInsertedTabID != -1)
			{
				return;
			}
			if (!bFirstTime)
			{
				EndDrawDragFrame (FALSE);
			}
			DrawFrameTab (m_pTargetBar, FALSE);
			m_nInsertedTabID = 1;
			return;
		}
	}	
	
	m_rectDrag.OffsetRect (ptOffset);
	m_ptHot = ptMouse;

	m_rectExpectedDocked = rectExpected;

	int nNewThickness = m_rectExpectedDocked.IsRectEmpty ()? 
							globalData.m_nDragFrameThiknessFloat : 
							globalData.m_nDragFrameThiknessDock;

	CRect rectDocked;
	if (m_rectExpectedDocked.IsRectEmpty ())
	{
		if (!m_rectDrag.PtInRect (ptMouse))
		{
			CPoint ptMiddleRect (m_rectDrag.TopLeft ().x + m_rectDrag.Width () / 2, 
								 m_rectDrag.top + 5);

			CPoint ptOffset = ptMouse - ptMiddleRect;
			m_rectDrag.OffsetRect (ptOffset);
		}
		rectDocked = m_rectDrag;
	}
	else
	{
		rectDocked = m_rectExpectedDocked;
	}
	if (!bSDockingIsOn || !m_rectExpectedDocked.IsRectEmpty ())
	{
		DrawDragFrame (rectOld, rectDocked, bFirstTime, nNewThickness, m_nOldThikness);
		m_nOldThikness = nNewThickness;
	}
	
}