void CXTPRibbonBuilder::BuildControlPopupBar(CXTPPropExchange* pPX, CXTPControl*& pParent, CRuntimeClass* pPopupBarClass) { CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("ELEMENT"))); BOOL bBeginGroup = FALSE; BOOL bEmpty = TRUE; POSITION pos = pEnumerator->GetPosition(0); while (pos) { CXTPPropExchangeSection pxControl(pEnumerator->GetNext(pos)); CString strElementName; PX_String(&pxControl, _T("ELEMENT_NAME"), strElementName); if (strElementName == _T("Separator")) { bBeginGroup = TRUE; continue; } CCmdTarget* pElement = CreateElement(strElementName); if (pElement == NULL) continue; CXTPControl* pControl = DYNAMIC_DOWNCAST(CXTPControl, pElement); if (!pControl) { delete pElement; continue; } if (bEmpty) { CXTPControlPopup* pPopupButton = CXTPControlPopup::CreateControlPopup(xtpControlPopup); CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pPopupBarClass->CreateObject(); if (pPopupBar->IsKindOf(RUNTIME_CLASS(CXTPRibbonSystemPopupBarPage))) { pPopupBar->SetIconSize(CSize(32, 32)); pPopupBar->SetWidth(300); pPopupBar->SetShowGripper(FALSE); pPopupBar->SetDefaultButtonStyle(xtpButtonCaptionAndDescription); } pPopupButton->SetCommandBar(pPopupBar); pPopupBar->InternalRelease(); pParent->InternalRelease(); pParent = pPopupButton; bEmpty = FALSE; } BuildControl(&pxControl, pControl); pParent->GetCommandBar()->GetControls()->Add(pControl, pControl->GetID()); pParent->SetBeginGroup(bBeginGroup); bBeginGroup = FALSE; } }