Loading a Data Set (C++Builder)

Take the following steps to start a project and to add some code that loads a DICOM Data Set and prints information about the data set:

1.

Start C++Builder.

2.

From the File menu, choose New Application

3.

On the C++Builder toolbar, click the LEADTOOLS tab. Select the LEAD DICOM control and add the control to your main form.

4.

Add a command button to your form and name it as follows:

 

Name

Caption

 

LoadLead

Load Image

5.

Add the following initialization code to the main form's Create procedure. In online help, you can use the copy the block of code and paste it in your form.

void __fastcall TForm1::FormCreate(TObject *Sender)
{
   /*Unlock DICOM support.*/
   /*Note that this is a sample key, which will not work in your toolkit.*/
   LEADDicom1->UnlockSupport(L_SUPPORT_MEDICAL, "TestKey");
}

6.

Code the LoadLead button's click procedure as follows:

void __fastcall TForm1::LeadLoadClick(TObject *Sender)
{
   Integer nRet;
   Cardinal uCount;
   bool bResult;

   LEADDicom1->EnableMethodErrors = false;
   nRet = LEADDicom1->LoadDS("c:\\LEAD\\Images\\test2.dic", 0);
   if( nRet != SUCCESS)
   {
      ShowMessage("Error " + IntToStr(nRet) + " loading file!");
      return;
   }
   uCount = LEADDicom1->GetModuleCount();
   LEADDicom1->FindIndexModule(0);
   bResult = LEADDicom1->SetCurrentElement(LEADDicom1->CurrentModule->Element[0]->hElement);
   if(bResult)
      ShowMessage("There are " + IntToStr(uCount) + " modules in this data set.\n"+
         "The first module has " + IntToStr(LEADDicom1->CurrentModule->ElementCount) +
         " elements.\nThe first element has: \nTag number:" +
         IntToHex(LEADDicom1->CurrentElement->Tag, 0) + "\nVR: " +
         IntToHex(LEADDicom1->CurrentElement->VR, 0));
   LEADDicom1->EnableMethodErrors = true;
}

7.

Run your program to test it.

8.

Save the project to use as a starting point for other tasks in this tutorial.