SetCurrentElement Example for C++Builder

   Cardinal uCount = 0;
   bool bFound = false,
         bFinished = false;
   THandle hPrevElement = 0,
           hFirstElement;
   AnsiString sOut;

   LEADDicom1->MoveFirstElement(false);
   hFirstElement = LEADDicom1->CurrentElement->hElement;
   while(!bFound && !bFinished)
      if(LEADDicom1->CurrentElement->Tag == TAG_PIXEL_DATA)
         bFound = true;
      else if(LEADDicom1->CurrentElement->hElement == hPrevElement)
         bFinished = true;
      else
      {
         hPrevElement = LEADDicom1->CurrentElement->hElement;
         LEADDicom1->MoveNextElement(false);
         uCount++;
      }
   if(bFound)
   {
      LEADDicom1->FindTag(LEADDicom1->CurrentElement->Tag);
      sOut = "Found Pixel Data Element: " + LEADDicom1->CurrentTag->Name +"\n";
      LEADDicom1->SetCurrentElement(hFirstElement);
      LEADDicom1->FindTag(LEADDicom1->CurrentElement->Tag);
      sOut = sOut + "First Data Element in list was: " + LEADDicom1->CurrentTag->Name +"\n";
      sOut = sOut + "There are " + IntToStr(uCount) + " Elements between the two";
      ShowMessage(sOut);
   }