InsertVR Example for C++ 6.0 and later
short nRet;
short nCode;
short nRestrict;
IDicomVRItemPtr pCurrentVR=NULL;
int nIndex;
CString szItem;
nCode = 10234;
nRestrict = DICOM_VR_FIXED | DICOM_VR_TEXT;
nRet = m_pLEADDicomDS->FindVR (nCode);
if(nRet == 0)
{
AfxMessageBox("Already Exists!");
return;
}
nRet = m_pLEADDicomDS->InsertVR (nCode, "My Test VR", 64, nRestrict, 1);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
//add item to the ListView control
pCurrentVR = m_pLEADDicomDS->GetCurrentVR();
szItem.Format("%ld", pCurrentVR->GetCode());
nIndex = m_ListView1.InsertItem(m_ListView1.GetItemCount(), szItem);
BSTR bstr = pCurrentVR->GetName();
szItem = bstr;
SysFreeString(bstr);
m_ListView1.SetItemText(nIndex, 1, szItem);
szItem.Format("%ld", pCurrentVR->GetLength());
m_ListView1.SetItemText(nIndex, 2, szItem);
szItem.Format("%d", pCurrentVR->GetRestrict());
m_ListView1.SetItemText(nIndex, 3, szItem);
szItem.Format("%d", pCurrentVR->GetUnitSize());
m_ListView1.SetItemText(nIndex, 4, szItem);
m_ListView1.SetItemState(nIndex, LVIS_SELECTED, LVIF_STATE);
m_ListView1.Update(nIndex);