void CXTPDockingPaneTabbedContainer::OnTabsChanged()
{
	if (!m_hWnd)
		return;

	m_nLockReposition += 1;

	DeleteAllItems();

	m_bCloseItemButton = GetDockingPaneManager()->m_bShowCloseTabButton;

	POSITION pos = GetHeadPosition();
	while (pos)
	{
		CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos);

		CXTPTabManagerItem* pItem = AddItem(GetItemCount());
		if (m_pSelectedPane == pPane) SetSelectedItem(pItem);

		pItem->SetCaption(pPane->GetTabCaption());
		pItem->SetColor(pPane->GetItemColor());
		pItem->SetTooltip(pPane->GetTitle());
		pItem->SetEnabled(pPane->GetEnabled() & xtpPaneEnableClient);
		pItem->SetClosable((pPane->GetOptions() & xtpPaneNoCloseable) == 0);

		pItem->SetData((DWORD_PTR)pPane);
	}
	//////////////////////////////////////////////////////////////////////////

	m_pCaptionButtons->CheckForMouseOver(CPoint(-1, -1));

	m_nLockReposition -= 1;
}