Using the DicomFileInsert Event for Visual Basic
' [General][Declarations]
Private WithEvents DicomDir As LEADDicomDir
Private Sub DicomDir_DicomFileInsert(ByVal bstrFileName As String, _
ByVal hDicomDS As Long, _
ByVal nStatus As Integer, _
pReturnVal As Integer)
Dim Buffer As String
Dim Result As VbMsgBoxResult
If nStatus = DICOMDIR_INSERTDICOMFILE_PREADD Then
Buffer = "About to add the file """ & bstrFileName & """." & _
vbCrLf & vbCrLf & "Proceed?"
Result = MsgBox(Buffer, vbYesNoCancel, "DICOM Directory Sample")
If Result = vbNo Then
pReturnVal = DICOM_ERROR_FORMAT ' Skip the file
Exit Sub
ElseIf Result = vbCancel Then
pReturnVal = DICOM_ERROR_END ' Abort
Exit Sub
End If
ElseIf nStatus = DICOM_SUCCESS Then
Buffer = "The file """ & bstrFileName & _
""" has been added successfully." & _
vbCrLf & vbCrLf & "Continue?"
Result = MsgBox(Buffer, vbYesNo, "DICOM Directory Sample")
If Result = vbNo Then
pReturnVal = DICOM_ERROR_END ' Abort
Exit Sub
End If
End If
End Sub
Private Sub CreateDicomDir()
Set DicomDir = New LEADDicomDir
Dim DicomFactory As New LEADDicomFactory
Dim DicomKernel As LEADDicomKernel
Dim strLic As String
strLic = "LEADTOOLS OCX Copyright (c) 1991-2005 LEAD Technologies, Inc."
Set DicomKernel = DicomFactory.CreateObject ("LEADDicomKernel.LEADDicomKernel", strLic)
DicomKernel.UnlockSupport L_SUPPORT_MEDICAL, L_KEY_MEDICAL
If DicomKernel.IsSupportLocked(L_SUPPORT_MEDICAL) Then
MsgBox "Medical Support must be unlocked for this demo!", vbExclamation
Exit Sub
End If
' Set the destination folder
DicomDir.ResetDicomDir "C:\Medical Images"
' Files in subfolders should also be included
DicomDir.IncludeSubfolders = True
' Add all the DICOM files to the Directory
DicomDir.InsertDicomFile ""
' Save the DICOMDIR File
DicomDir.SaveDicomDir
End Sub