MoveRootElement Example for C++ 6.0 and later
short nRet1;
short nRet2;
IDicomDSElementPtr pCurrentElement=NULL;
ILEADDicomTagPtr pCurrentTag=NULL;
m_pLEADDicomDS->EnableMethodErrors = FALSE;
//move to first element in Data Set
m_pLEADDicomDS->MoveFirstElement (FALSE);
pCurrentElement = m_pLEADDicomDS->GetCurrentElement ();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
//move to next element in the same level of the Data Set
m_pLEADDicomDS->MoveNextElement (TRUE);
pCurrentElement = m_pLEADDicomDS->GetCurrentElement ();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
//move to last element in the same level of the Data Set
m_pLEADDicomDS->MoveLastElement(TRUE);
pCurrentElement = m_pLEADDicomDS->GetCurrentElement();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
//move to previous element in the same level of the Data Set
m_pLEADDicomDS->MovePrevElement(TRUE);
pCurrentElement = m_pLEADDicomDS->GetCurrentElement ();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
//find the first element that has a child
nRet1 = m_pLEADDicomDS->MoveFirstElement (FALSE);
while(nRet1 == 0)
{
nRet2 = m_pLEADDicomDS->MoveChildElement ();
if(nRet2 == 0)
{
pCurrentElement = m_pLEADDicomDS->GetCurrentElement ();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
nRet1 = 1; //end loop
}
if(nRet1 != 1)
{
//check next element in this same level
nRet1 = m_pLEADDicomDS->MoveNextElement (TRUE);
}
}
m_pLEADDicomDS->EnableMethodErrors = TRUE;
//move back to the element's parent
if(nRet1 == 1)
{
m_pLEADDicomDS->MoveParentElement ();
pCurrentElement = m_pLEADDicomDS->GetCurrentElement ();
m_pLEADDicomDS->FindTag(pCurrentElement->GetTag());
pCurrentTag = m_pLEADDicomDS->GetCurrentTag ();
AfxMessageBox("Element: " + pCurrentTag->GetName());
}