InsertIOD Example for Visual Basic
Private Sub TestFunc(bChild As Boolean)
Dim bInsert As Boolean
Dim lCode As Long
Dim nType As Integer
Dim hIOD As Long
Dim hTemp As Long
Dim nRet As Integer
bInsert = False
LEADDICOM1.EnableMethodErrors = True
On Error GoTo INSERTIODERROR
lCode = 1048593
nType = DICOM_IOD_TYPE_CLASS
'store current IOD
hIOD = LEADDICOM1.CurrentIOD.hIOD
LEADDICOM1.EnableMethodErrors = False
'does an IOD already exist on the target level?
If (bChild = True) Then
'if the current IOD has a child, move to that child's level
nRet = LEADDICOM1.MoveChildIOD
If (nRet <> 0) Then 'no children, so insert is OK
bInsert = True
LEADDICOM1.SetCurrentIOD hIOD
Else 'check the child's level to see if target IOD already exists
hTemp = LEADDICOM1.CurrentIOD.hIOD
LEADDICOM1.MoveFirstIOD True
nRet = LEADDICOM1.FindIOD(lCode, nType, True)
If (nRet <> 0) Then
bInsert = True
End If
'move back to parent level
LEADDICOM1.SetCurrentIOD hTemp
LEADDICOM1.MoveParentIOD
End If
Else
'check the current IOD's level
LEADDICOM1.MoveFirstIOD (True)
nRet = LEADDICOM1.FindIOD(lCode, nType, True)
If (nRet <> 0) Then
bInsert = True
End If
LEADDICOM1.SetCurrentIOD hIOD
End If
LEADDICOM1.EnableMethodErrors = True
'allow user to insert item at the same level as the current or as child
If (bInsert = True) Then
LEADDICOM1.InsertIOD bChild, nType, lCode, "My Test IOD", 5, "Test
Description"
Else
MsgBox "Already exists"
End If
Exit Sub
INSERTIODERROR:
MsgBox "Error"
LEADDICOM1.EnableMethodErrors = True
End Sub