Loading a Data Set (VB.NET)

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 Visual Studio .NET.

3.

Add the LEAD COM Objects to your project.

 

On the Tools pull-down menu, use the Add/Remove Toolbox Items... option, select the COM Components Tab, then select the LEAD Raster View Control (14.5).

 

On the Project pull-down menu, use the Add Reference... option, select the COM Tab, then select the following:
LEAD Raster Object Library (14.5)
LEAD Raster Variant Object Library (14.5)
LEAD Raster Process Object Library (14.5)
LEAD Raster IO Object Library (14.5)
LEAD DICOM Kernel COM Object Library (14.5)
LEAD DICOM DS COM Object Library (14.5)
.

4.

Select the LEAD Raster View Control, then add the control to your main form.

5.

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

 

Name

Text

 

LoadImage

Load Image

6.

Add the following initialization code to the main form's Load event handler. In online help, you can use the Edit pull-down menu to copy the block of code.

'class data-members
Private WithEvents LEADDICOM1 As LEADDicomDS

 

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   'Unlock DICOM support.
   
'Note that this is a sample key, which will not work in your toolkit.
   
Dim Factory As New LTDicomKernelLib.LEADDicomFactory
   
Dim DicomKernel As LTDicomKernelLib.LEADDicomKernel
   
Dim szLic As String

   szLic = "LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc." Factory = CreateObject("LEADDicomFactory.LEADDicomFactory")
   
DicomKernel = Factory.CreateObject("LEADDicomKernel.LEADDicomKernel", szLic)
   
LEADDICOM1 = Factory.CreateObject("LEADDicomDS.LEADDicomDS", szLic)

   DicomKernel.UnlockSupport(LTDicomKernelLib.DicomSupportLockConstants.L_SUPPORT_MEDICAL, "TestKey")

End Sub

6.

Code the LoadImage button's click event handler as follows:

Private Sub LoadImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadImage.Click

   Dim nRet As Short
   
Dim lCount As Short
   
Dim result As Boolean

   LEADDICOM1.EnableMethodErrors = False
   
nRet = LEADDICOM1.LoadDS("D:\lead14\dist\images\dicom\image1.dic", 0)
   
If (nRet <> LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS) Then
      
MessageBox.Show("Error " & CStr(nRet) & " loading file!")
   
End If
   
lCount = LEADDICOM1.GetModuleCount
   
LEADDICOM1.FindIndexModule(0)
   
result = LEADDICOM1.SetCurrentElement(LEADDICOM1.CurrentModule.Element(0).hElement)
   
If (result = True) Then
      
MessageBox.Show("There are " & CStr(lCount) & " modules in this data set." & (Chr(13)) & "The first module has " & CStr(LEADDICOM1.CurrentModule.ElementCount) & " elements." & (Chr(13)) & "The first element has: " & (Chr(13)) & "Tag number:" & Hex(LEADDICOM1.CurrentElement.Tag) & (Chr(13)) & "VR: " & Hex(LEADDICOM1.CurrentElement.VR))
   
End If

   LEADDICOM1.EnableMethodErrors = True

End Sub

7.

Run your program to test it.

8.

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