DeleteKey Example for C++ Builder
int x;
LEADDicom1->ResetDS ();
LEADDicom1->InitDS (DICOM_CLASS_UNKNOWN, 0);
//insert some keys
LEADDicom1->InsertKey ("PATIENT", True); //insert PATIENT level key
LEADDicom1->InsertKey ("STUDY", True); //insert STUDY level key
//insert 5 SERIES level keys and some data
for (x= 1; x <= 5; x ++)
{
LEADDicom1->StringValueCount = 1;
LEADDicom1->InsertKey ("SERIES", True);
LEADDicom1->MoveChildElement ();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->StringValues [0]= IntToStr(x);
LEADDicom1->SetStringValue (1);
LEADDicom1->MoveParentElement ();
LEADDicom1->MoveParentKey (); //move back up one level
}
//move to root key
LEADDicom1-> MoveRootKey ();//PATIENT level
ShowMessage (LEADDicom1->GetKeyValue ()) ;
//move to SERIES level
LEADDicom1->MoveChildKey ();//STUDY
LEADDicom1->MoveChildKey ();//SERIES
//find first SERIES
LEADDicom1->FindFirstKey ("SERIES", True);
LEADDicom1->MoveChildElement ( ) ;
LEADDicom1->FindFirstElement ( TAG_REFERENCED_FILE_ID, True ) ;
LEADDicom1->GetStringValue ( 0, 1 ) ;
ShowMessage ( LEADDicom1->StringValues[0] ) ;
//find next series
LEADDicom1->FindNextKey (True ) ;
LEADDicom1->MoveChildElement ( ) ;
LEADDicom1->FindFirstElement ( TAG_REFERENCED_FILE_ID, True ) ;
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues [0]);
//find last SERIES
LEADDicom1->FindLastKey ("SERIES", True);
LEADDicom1->MoveChildElement();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues[0]);
//find previous SERIES
LEADDicom1->FindPrevKey (True);
LEADDicom1->MoveChildElement ();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues[0]);
//find last SERIES and delete it
LEADDicom1->FindLastKey ("SERIES", True);
LEADDicom1->DeleteKey ();
//move to root key
LEADDicom1->MoveFirstKey (False);
ShowMessage (String(LEADDicom1->GetKeyValue ()));
//move to SERIES level
LEADDicom1->MoveChildKey (); //STUDY
LEADDicom1->MoveChildKey(); //SERIES
//move to first SERIES
LEADDicom1->MoveFirstKey (True);
LEADDicom1->MoveChildElement();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues [0]);
//move to next series
LEADDicom1->MoveNextKey (True);
LEADDicom1->MoveChildElement ();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues[0]);
//move to last SERIES
LEADDicom1->MoveLastKey (True);
LEADDicom1->MoveChildElement ();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues[0]);
//move to previous SERIES
LEADDicom1->MovePrevKey (True);
LEADDicom1->MoveChildElement ();
LEADDicom1->FindFirstElement (TAG_REFERENCED_FILE_ID, True);
LEADDicom1->GetStringValue (0, 1);
ShowMessage (LEADDicom1->StringValues [0]);