void COXDockTabCtrl::ShowSelectedTab()
{
	int iSelected = GetCurSel();

	// Show first
	for (int i = 0; i < GetItemCount(); i++)
	{
		CControlBar* pBar = GetBar(i);
		if (iSelected == i)
		{
			pBar->GetDockingFrame()->ShowControlBar(pBar, TRUE, TRUE); // show
		}
		else
		{
			pBar->GetDockingFrame()->ShowControlBar(pBar, FALSE, TRUE); // hide
		}
	}

	CRect rect;
	m_pSizeDockBar->GetClientRect(rect);

	CControlBar* pBar = GetBar(iSelected);
	if (pBar != NULL)
	{
		COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, pBar);
		if (m_pSizeDockBar->IsBarHorizontal())
		{
			if (m_pLastSelectedBar != NULL)
			{
				pSizeBar->m_HorzDockSize.cx = m_pLastSelectedBar->m_HorzDockSize.cx;
			}
			m_pLastSelectedBar = pSizeBar;
		}
		else // vertical
		{
			CFrameWnd* pMF = (CFrameWnd*) GetParentFrame();//AfxGetMainWnd();
			if (pMF != NULL)
			{
				if (pMF->GetControlBar(AFX_IDW_DOCKBAR_LEFT) == m_pSizeDockBar)
					rect.right -= 3;

				if (pMF->GetControlBar(AFX_IDW_DOCKBAR_RIGHT) == m_pSizeDockBar)
					rect.left += 4;
			}
			
			rect.bottom -= m_pSizeDockBar->GetTabHeight();

			pBar->MoveWindow(rect, TRUE);

			COXSizeControlBar* pSizeBar = DYNAMIC_DOWNCAST(COXSizeControlBar, pBar);
			if (pSizeBar)
			{
				pSizeBar->m_VertDockSize.cx = rect.Width();
				pSizeBar->m_VertDockSize.cy = rect.Height() + 5;
			}
		}
	}
}
Exemplo n.º 2
0
void CSizingControlBar::AlignControlBars()
{
    int nFirst, nLast, nThis;
    GetRowInfo(nFirst, nLast, nThis);

    BOOL bHorz = IsHorzDocked();
    BOOL bNeedRecalc = FALSE;
    int nPos, nAlign = bHorz ? -2 : 0;

    CRect rc, rcDock;
    m_pDockBar->GetWindowRect(&rcDock);

    for (int i = nFirst; i <= nLast; i++)
    {
        CControlBar* pBar = (CControlBar*)m_pDockBar->m_arrBars[i];
        if (HIWORD(pBar) == 0) continue; // placeholder
        if (!pBar->IsVisible()) continue;

        pBar->GetWindowRect(&rc);
        rc.OffsetRect(-rcDock.TopLeft());

        if ((nPos = FindSizingBar(pBar)) >= 0)
            rc = CRect(rc.TopLeft(), bHorz ?
                m_arrBars[nPos]->m_szHorz : m_arrBars[nPos]->m_szVert);

        if ((bHorz ? rc.left : rc.top) != nAlign)
        {
            if (!bHorz)
                rc.OffsetRect(0, nAlign - rc.top - 2);
            else if (m_nDockBarID == AFX_IDW_DOCKBAR_TOP)
                rc.OffsetRect(nAlign - rc.left, -2);
            else
                rc.OffsetRect(nAlign - rc.left, 0);
            pBar->MoveWindow(rc);
            bNeedRecalc = TRUE;
        }
        nAlign += (bHorz ? rc.Width() : rc.Height()) - 2;
    }

    if (bNeedRecalc)
    {
        m_pDockSite->DelayRecalcLayout();
        TRACE(_T("ccc\n"));
    }
}