void CXTPTaskPanelItems::DoPropExchange(CXTPPropExchange* pPX)
{
	m_pPanel->SetLockRedraw(TRUE);

	try
	{
		pPX->m_dwData = (DWORD_PTR)m_pPanel;

		CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("Item")));
		POSITION pos = pEnumerator->GetPosition(GetCount());

		if (pPX->IsStoring())
		{
			for (int i = 0; i < GetCount(); i++)
			{
				CXTPTaskPanelItem* pItem = GetAt(i);

				CXTPPropExchangeSection sec(pEnumerator->GetNext(pos));
				PX_Object(&sec, pItem, GetDefaultItemClass());
			}
		}
		else
		{
			Clear(FALSE);

			while (pos)
			{
				CXTPTaskPanelItem* pItem = NULL;

				CXTPPropExchangeSection sec(pEnumerator->GetNext(pos));
				PX_Object(&sec, pItem, GetDefaultItemClass());

				if (!pItem)
					AfxThrowArchiveException(CArchiveException::badClass);

				pItem->m_pItems = this;
				pItem->OnInserted();

				m_arrItems.Add(pItem);
			}
		}
	}
	catch (COleException* pEx)
	{
		TRACE(_T("CXTPTaskPanelItems::Serialize. OLE exception: %x\r\n"),
			pEx->m_sc);
		pEx->Delete ();
	}
	catch (CArchiveException* pEx)
	{
		TRACE(_T("CXTPTaskPanelItems::Serialize. Archive exception\r\n"));
		pEx->Delete ();
	}

	m_pPanel->SetLockRedraw(FALSE);

}
void CXTPFlowGraphPages::DoPropExchange(CXTPPropExchange* pPX)
{
	CXTPPropExchangeEnumeratorPtr pEnumRecords(pPX->GetEnumerator(_T("Page")));

	if (pPX->IsStoring())
	{
		int nCount = (int)GetCount();
		POSITION pos = pEnumRecords->GetPosition((DWORD)nCount);

		for (int i = 0; i < nCount; i++)
		{
			CXTPFlowGraphPage* pPage = GetAt(i);
			ASSERT(pPage);

			CXTPPropExchangeSection sec(pEnumRecords->GetNext(pos));
			PX_Object(&sec, pPage, RUNTIME_CLASS(CXTPFlowGraphPage));

			BOOL bActive = m_pControl->GetActivePage() == pPage;
			PX_Bool(&sec, _T("Active"), bActive, FALSE);
		}
	}
	else
	{
		RemoveAll();

		POSITION pos = pEnumRecords->GetPosition();

		CXTPFlowGraphPage* pActivePage = NULL;

		while (pos)
		{
			CXTPFlowGraphPage* pPage = NULL;

			CXTPPropExchangeSection sec(pEnumRecords->GetNext(pos));

			if (!sec->ExchangeObjectInstance((CObject*&)pPage, RUNTIME_CLASS(CXTPFlowGraphPage)))
				AfxThrowArchiveException(CArchiveException::badClass);

			pPage->m_pControl = m_pControl;
			pPage->DoPropExchange(&sec);

			m_arrPages.Add(pPage);

			BOOL bActive = FALSE;
			PX_Bool(&sec, _T("Active"), bActive, FALSE);

			if (bActive)
				pActivePage = pPage;
		}

		m_pControl->SetActivePage(pActivePage);
	}
}
void CXTPRibbonControlTab::DoPropExchange(CXTPPropExchange* pPX)
{
	if (pPX->IsStoring())
	{
		long nCount = (long)m_arrItems.GetSize();
		int i;

		CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("Tab")));
		POSITION posEnum = pEnumerator->GetPosition(nCount, FALSE);

		for (i = 0; i < nCount; i++)
		{
			CXTPRibbonTab* pTab = (CXTPRibbonTab*)GetItem(i);

			CXTPPropExchangeSection secItem(pEnumerator->GetNext(posEnum));
			PX_Object(&secItem, pTab, RUNTIME_CLASS(CXTPRibbonTab));
		}
	}
	else
	{
		CXTPPropExchangeEnumeratorPtr pEnumerator(pPX->GetEnumerator(_T("Tab")));
		POSITION posEnum = pEnumerator->GetPosition(0, FALSE);

		DeleteAllItems();

		while (posEnum)
		{
			CXTPPropExchangeSection secItem(pEnumerator->GetNext(posEnum));
			secItem->m_pOwner = this;

			CXTPRibbonTab* pTab = NULL;
			PX_Object(&secItem, pTab, RUNTIME_CLASS(CXTPRibbonTab));

			if (!pTab)
				AfxThrowArchiveException(CArchiveException::badClass);

			AddItem(GetItemCount(), pTab);
		}
	}
}
void CXTPReportRecord::DoPropExchange(CXTPPropExchange* pPX)
{
	PX_Bool(pPX, _T("Locked"), m_bLocked);
	PX_Bool(pPX, _T("Editable"), m_bEditable);

	BOOL bPreview = m_pPreviewItem != NULL;
	PX_Bool(pPX, _T("Preview"), bPreview);


	int nCount = GetItemCount();

	CXTPPropExchangeEnumeratorPtr pEnumItems(pPX->GetEnumerator(_T("Item")));

	if (pPX->IsStoring())
	{
		POSITION posItem = pEnumItems->GetPosition((DWORD)nCount);

		for (int i = 0; i < nCount; i++)
		{
			CXTPReportRecordItem* pItem = GetItem(i);
			ASSERT(pItem);
			if (!pItem)
				AfxThrowArchiveException(CArchiveException::badClass);

			CXTPPropExchangeSection secItem(pEnumItems->GetNext(posItem));
			PX_Object(&secItem, pItem, RUNTIME_CLASS(CXTPReportRecordItem));
		}
	}
	else
	{
		RemoveAll();

		POSITION posItem = pEnumItems->GetPosition();

		while (posItem)
		{
			CXTPReportRecordItem* pItem = NULL;

			CXTPPropExchangeSection sec(pEnumItems->GetNext(posItem));
			PX_Object(&sec, pItem, RUNTIME_CLASS(CXTPReportRecordItem));

			if (!pItem)
				AfxThrowArchiveException(CArchiveException::badClass);

			AddItem(pItem);
		}
	}

	//------------------------------------------------------------
	if (bPreview)
	{
		CXTPPropExchangeSection secPreviewItem(pPX->GetSection(_T("PreviewItem")));

		if (pPX->IsLoading())
		{
			CMDTARGET_RELEASE(m_pPreviewItem);
		}

		PX_Object(&secPreviewItem, m_pPreviewItem, RUNTIME_CLASS(CXTPReportRecordItemPreview));

		if (m_pPreviewItem && pPX->IsLoading())
		{
			m_pPreviewItem->m_pRecord = this;
		}
	}

	//------------------------------------------------------------
	if (pPX->GetSchema() > _XTP_SCHEMA_1041)
	{
		BOOL bHasChildren = HasChildren();
		PX_Bool(pPX, _T("HasChildren"), bHasChildren, FALSE);

		if (bHasChildren)
		{
			CXTPPropExchangeSection secChildren(pPX->GetSection(_T("Children")));
			GetChilds()->_DoPropExchange(&secChildren);
		}
		else if (m_pChildren)
		{
			m_pChildren->RemoveAll();
		}
	}
}