//******************************************************************************
BOOL CBCGPRibbonButtonsGroup::ReplaceByID (UINT uiCmdID, CBCGPBaseRibbonElement* pElem)
{
	ASSERT_VALID (this);
	ASSERT_VALID (pElem);

	for (int i = 0; i < m_arButtons.GetSize (); i++)
	{
		CBCGPBaseRibbonElement* pButton = m_arButtons [i];
		ASSERT_VALID (pButton);

		if (pButton->GetID () == uiCmdID)
		{
			pElem->CopyFrom (*pButton);
			m_arButtons [i] = pElem;

			delete pButton;
			return TRUE;
		}

		if (pButton->ReplaceByID (uiCmdID, pElem))
		{
			return TRUE;
		}
	}
	
	return FALSE;
}