ntrolBar);
			}
			else if (pTabbedControlBar != NULL)
			{
				m_pContainerManager->AddPaneToList(pTabbedControlBar);
				m_pBarRightBottom = pTabbedControlBar;
			}
			return pTabbedControlBar;
		}

		m_pBarRightBottom = pBar;

		bShowSlider = (m_pBarLeftTop != NULL) || (m_pLeftContainer != NULL);

		if (m_pBarLeftTop != NULL)
		{
			m_pBarLeftTop->GetWindowRect(rectSecondBar);
		}
		else if (m_pLeftContainer != NULL)
		{
			m_pLeftContainer->GetWindowRect(rectSecondBar);
		}

		pDockSite->ScreenToClient(rectSecondBar);

		if (m_pSlider != NULL)
		{
			if (IsPaneDividerHorz())
			{
				rectSlider.bottom = rectNew.top;
				rectSlider.top = rectSlider.bottom - m_pSlider->GetWidth();
				rectSecondBar.bottom = rectSlider.top;
			}
			else
			{
				rectSlider.right = rectNew.left;
				rectSlider.left = rectSlider.right - m_pSlider->GetWidth();
				rectSecondBar.right = rectSlider.left;
			}
		}

		if (m_pBarLeftTop != NULL)
		{
			hdwp = m_pBarLeftTop->MoveWindow(rectSecondBar, FALSE, hdwp);
		}
		else if (m_pLeftContainer != NULL)
		{
			m_pLeftContainer->Resize(rectSecondBar, hdwp);
		}
	}

	if (m_pSlider != NULL)
	{
		if (bShowSlider)
		{
			hdwp = m_pSlider->MoveWindow(rectSlider, FALSE, hdwp);
		}
		else
		{
			m_pSlider->ShowWindow(SW_HIDE);
		}
	}

	rectContainer.UnionRect(rectNew, rectSecondBar);
	pDockSite->ClientToScreen(rectContainer);

	if (bExpandParentContainer)
	{
		// find the first parent container that has non-empty rectangle and
		// whose left/right bar/container should be expanded

		if (pNextContainer != NULL)
		{
			const CPaneDivider* pParentSlider = pNextContainer->GetPaneDivider();

			if (pParentSlider != NULL)
			{
				ASSERT_VALID(pParentSlider);

				CPaneContainer* pLeftContainer = (CPaneContainer*) pNextContainer->GetLeftPaneContainer();
				CPaneContainer* pRightContainer = (CPaneContainer*) pNextContainer->GetRightPaneContainer();

				BOOL bIsLeftContainer = FALSE;

				if (pLeftContainer != NULL &&
					pLeftContainer-> FindSubPaneContainer(this, BC_FIND_BY_CONTAINER))
				{
					bIsLeftContainer = TRUE;
				}
				else if (pRightContainer != NULL &&
					pRightContainer-> FindSubPaneContainer(this, BC_FIND_BY_CONTAINER))
				{
					bIsLeftContainer = FALSE;
				}
				else
				{
					return pBar;
				}

				pParentSlider->GetWindowRect(rectSlider);

				int nOffset = pParentSlider->GetWidth();

				if (bIsLeftContainer)
				{
					if (pParentSlider->IsHorizontal())
					{
						nOffset += nNewHeight;
						rectSlider.top = rectContainer.bottom;
						rectSlider.bottom = rectSlider.top + pParentSlider->GetWidth();
					}
					else
					{
						nOffset += nNewWidth;
						rectSlider.left = rectContainer.right;
						rectSlider.right = rectSlider.left + pParentSlider->GetWidth();
					}
				}
				else
				{
					if (pParentSlider->IsHorizontal())
					{
						nOffset = -(nNewHeight + pParentSlider->GetWidth());
						rectSlider.bottom = rectContainer.top;
						rectSlider.top = rectSlider.bottom - pParentSlider->GetWidth();
					}
					else
					{
						nOffset = -(nNewWidth + pParentSlider->GetWidth());;
						rectSlider.right = rectContainer.left;
						rectSlider.left = rectSlider.right - pParentSlider->GetWidth();
					}
				}

				pDockSite->ScreenToClient(rectSlider);
				if (m_pSlider != NULL)
				{
					hdwp = m_pSlider->MoveWindow(rectSlider, FALSE, hdwp);
				}
				pNextContainer->ResizePartOfPaneContainer(nOffset, !bIsLeftContainer, hdwp);
	