예제 #1
0
void CDockContext::EndDrag()
/**************************/
{
    DrawFocusRect( TRUE );
    if( m_dwOverDockStyle != 0L && !m_bForceFrame ) {
        CDockBar *pDockBar = GetDockBar( m_dwOverDockStyle );
        ASSERT( pDockBar != NULL );
        if( ((m_dwOverDockStyle & CBRS_ORIENT_HORZ) && !m_bFlip) ||
            ((m_dwOverDockStyle & CBRS_ORIENT_VERT) && m_bFlip) ) {
            pDockBar->DockControlBar( m_pBar, &m_rectDragHorz );
        } else {
            pDockBar->DockControlBar( m_pBar, &m_rectDragVert );
        }
        m_dwOverDockStyle = 0L;
        m_uMRUDockID = pDockBar->GetDlgCtrlID();
        m_pBar->GetWindowRect( &m_rectMRUDockPos );
    } else {
        ASSERT( m_pDockSite != NULL );
        if( ((m_dwStyle & CBRS_ORIENT_HORZ) && !m_bFlip) ||
            ((m_dwStyle & CBRS_ORIENT_VERT) && m_bFlip) ) {
            m_pDockSite->FloatControlBar( m_pBar, m_rectFrameDragHorz.TopLeft(),
                CBRS_ALIGN_TOP | (m_dwDockStyle & CBRS_FLOAT_MULTI) );
            m_ptMRUFloatPos = m_rectFrameDragHorz.TopLeft();
        } else {
            m_pDockSite->FloatControlBar( m_pBar, m_rectFrameDragVert.TopLeft(),
                CBRS_ALIGN_LEFT | (m_dwDockStyle & CBRS_FLOAT_MULTI) );
            m_ptMRUFloatPos = m_rectFrameDragVert.TopLeft();
        }
    }
    delete m_pDC;
    m_pDC = NULL;
    m_bDragging = FALSE;
}
예제 #2
0
void CFrameWnd::DockControlBar( CControlBar *pBar, UINT nDockBarID, LPCRECT lpRect )
/**********************************************************************************/
{
    CDockBar *pDockBar = NULL;
    if( nDockBarID != 0 ) {
         pDockBar = (CDockBar *)GetControlBar( nDockBarID );
         if( pDockBar == NULL ) {
             // We're trying to dock to a dock bar that doesn't exist, so just don't do
             // anything.
             return;
         }
         if( !(pBar->m_dwDockStyle & (pDockBar->m_dwStyle & CBRS_ALIGN_ANY)) ) {
             // We don't support docking to a bar of this style, so just don't do
             // anything.
             return;
         }
         ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
         if( lpRect != NULL ) {
            RECT    rectJunk;
            CRect   rectBar;
            pDockBar->GetWindowRect( &rectBar );
            if( rectBar.left == rectBar.right ) {
                rectBar.left--;
                rectBar.right++;
            }
            if( rectBar.top == rectBar.bottom ) {
                rectBar.top--;
                rectBar.bottom++;
            }
            if( !::IntersectRect( &rectJunk, &rectBar, lpRect ) ) {
                // The rectangle and the dock bar identifier don't coincide, so just
                // don't do anything.
                return;
            }
        }
    } else if( lpRect != NULL ){
        CanDock( *lpRect, pBar->m_dwDockStyle, &pDockBar );
    } else {
        CanDock( CRect( 0, 0, 32767, 32767 ), pBar->m_dwDockStyle, &pDockBar );
    }
    if( pDockBar != NULL ) {
        ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
        pDockBar->DockControlBar( pBar, lpRect );
    }
}
예제 #3
0
//--------------------------------------------------------------------------------------------
void CMRCMDIFrameWndSizeDock::UnFloatInMDIChild(CControlBar* pBar, CPoint point, DWORD dwStyle)
// removes the control bar from an MDI floating window, and then floats the bar
//--------------------------------------------------------------------------------------------
{
	ASSERT(pBar != NULL);
	ASSERT(pBar->IsFloating());
	CMRCMDIFloatWnd * pFloatFrame = (CMRCMDIFloatWnd *)pBar->GetParentFrame();
	ASSERT(pFloatFrame->IsKindOf(RUNTIME_CLASS(CMRCMDIFloatWnd)));

	// point at which to float is ignored at present - use the co-ordinates of the current frame
	CRect rcMDIFloat;
	pFloatFrame->GetWindowRect(&rcMDIFloat);
	point = rcMDIFloat.TopLeft();
	
	// This is basically the code from MFC's CFrameWnd::FloatControlBar(), with the
	// test to avoid destroying/creating the floating frame window removed. 
	// Tried explicitly removing the control bar, but this doesn't work as it destroys the
	// CMDIFloatWnd, which in turn kills the child control bar. So need to create the floating
	// frame first, and then dock into this.  

	ASSERT(m_pFloatingFrameClass != NULL);

	CMiniDockFrameWnd* pDockFrame = CreateFloatingFrame(dwStyle);
	ASSERT(pDockFrame != NULL);
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout();
	pDockFrame->ShowWindow(SW_SHOWNA);
	pDockFrame->UpdateWindow();
}
예제 #4
0
void CFrameWnd::FloatControlBar( CControlBar *pBar, CPoint pt, DWORD dwStyle )
/****************************************************************************/
{
    ASSERT( pBar != NULL );
    if( pBar->IsFloating() && !(pBar->m_pDockBar->GetBarStyle() & CBRS_FLOAT_MULTI) ) {
        CFrameWnd *pFrame = pBar->GetParentFrame();
        pFrame->SetWindowPos( NULL, pt.x, pt.y, 0, 0,
                              SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
    } else {
        CMiniDockFrameWnd *pFrame = CreateFloatingFrame( dwStyle );
        ASSERT( pFrame != NULL );
        CDockBar *pDockBar = (CDockBar *)pFrame->GetDlgItem( AFX_IDW_DOCKBAR_FLOAT );
        ASSERT( pDockBar != NULL );
        ASSERT( pDockBar->IsKindOf( RUNTIME_CLASS( CDockBar ) ) );
        pDockBar->DockControlBar( pBar );
        if( pt.x != CW_USEDEFAULT && pt.y != CW_USEDEFAULT ) {
            pFrame->SetWindowPos( NULL, pt.x, pt.y, 0, 0,
                                  SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER );
        }
        pFrame->ShowWindow( SW_SHOW );
        pFrame->UpdateWindow();
        RecalcLayout();
    }
}
예제 #5
0
void CFrameWnd::FloatControlBar(CControlBar* pBar, CPoint point, DWORD dwStyle)
{
	ASSERT(pBar != NULL);

	// if the bar is already floating and the dock bar only contains this
	// bar and same orientation then move the window rather than recreating
	// the frame
	if (pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL)
	{
		CDockBar* pDockBar = pBar->m_pDockBar;
		ASSERT_KINDOF(CDockBar, pDockBar);
		if (pDockBar->m_bFloating && pDockBar->GetDockedCount() == 1 &&
			(dwStyle & pDockBar->m_dwStyle & CBRS_ALIGN_ANY) != 0)
		{
			CMiniDockFrameWnd* pDockFrame =
				(CMiniDockFrameWnd*)pDockBar->GetParent();
			ASSERT(pDockFrame != NULL);
			ASSERT_KINDOF(CMiniDockFrameWnd, pDockFrame);
			pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
				SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
			pDockFrame->RecalcLayout(TRUE);
			pDockFrame->UpdateWindow();
			return;
		}
	}

	if (pBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
	{
		dwStyle |= CBRS_SIZE_DYNAMIC;
		if (dwStyle & CBRS_ORIENT_VERT)
		{
			dwStyle &= ~CBRS_ALIGN_ANY;
			dwStyle |= CBRS_ALIGN_TOP;
		}
	}

	CMiniDockFrameWnd* pDockFrame = CreateFloatingFrame(dwStyle);
	ASSERT(pDockFrame != NULL);
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT_KINDOF(CDockBar, pDockBar);

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout(TRUE);
	if (GetWindowLong(pBar->m_hWnd, GWL_STYLE) & WS_VISIBLE)
	{
		pDockFrame->ShowWindow(SW_SHOWNA);
		pDockFrame->UpdateWindow();
	}
}
예제 #6
0
//-----------------------------------------------------------------------------------------------------
void CMRCMDIFrameWndSizeDock::FloatControlBarInMDIChild(CControlBar* pBar, CPoint point, DWORD dwStyle)
// float a control bar in an MDI Child window
// pBar = bar to float
// point = position in screen co-ordinates
//-----------------------------------------------------------------------------------------------------
{
	ASSERT(pBar != NULL);

	// point is in screen co-ords - map to client
	::ScreenToClient(m_hWndMDIClient, &point);

	// clip to client MDI client rectangle - ensures it's going to be visible
	CRect rcMDIClient;
	::GetClientRect(m_hWndMDIClient, &rcMDIClient);
	point.x = min (point.x, rcMDIClient.right - 32);
	point.x = max (point.x, rcMDIClient.left);		
	point.y = min (point.y, rcMDIClient.bottom - 20);
	point.y = max (point.y, rcMDIClient.top);		
	
	// If the bar is already floating in an MDI child, then just move it
	// MFC has a similar optimization for CMiniDockFrameWnd 
	if (pBar->m_pDockSite != NULL && pBar->m_pDockBar != NULL)
	{
		CDockBar* pDockBar = pBar->m_pDockBar;
		ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));
		CFrameWnd* pDockFrame = (CFrameWnd*)pDockBar->GetParent();
		ASSERT(pDockFrame != NULL);
		ASSERT(pDockFrame->IsKindOf(RUNTIME_CLASS(CFrameWnd)));
		if (pDockFrame->IsKindOf(RUNTIME_CLASS(CMRCMDIFloatWnd)))
		{
		 	// already a floating as an MDI child, so just move it.
			if (pDockBar->m_bFloating && pDockBar->GetDockedCount() == 1 &&
				(dwStyle & pDockBar->m_dwStyle & CBRS_ALIGN_ANY) != 0)
		 	{
				pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
							SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
				return;
			}
		}
	}

	// Create a CMRCMDIFloatWnd, and dock the bar into it.
	CMRCMDIFloatWnd * pDockFrame = (CMRCMDIFloatWnd *)(RUNTIME_CLASS(CMRCMDIFloatWnd))->CreateObject();
	ASSERT(pDockFrame != NULL);
	if (!pDockFrame->Create(this, dwStyle))
		AfxThrowResourceException();
	
	pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
		SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
	
	if (pDockFrame->m_hWndOwner == NULL)
		pDockFrame->m_hWndOwner = pBar->m_hWnd;

	// Gets the dockbar created by the CMRCMDIFloatWnd
	CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
	ASSERT(pDockBar != NULL);
	ASSERT(pDockBar->IsKindOf(RUNTIME_CLASS(CDockBar)));

	ASSERT(pBar->m_pDockSite == this);
	// if this assertion occurred it is because the parent of pBar was not
	//  initially this CFrameWnd when pBar's OnCreate was called
	// (this control bar should have been created with a different
	//  parent initially)

	pDockBar->DockControlBar(pBar);
	pDockFrame->RecalcLayout();
	pDockFrame->ShowWindow(SW_SHOWNA);
	pDockFrame->UpdateWindow(); 
}