GetBinaryValue Example for C++ 6.0 and later
void CDicomDlg::TestProc1()
{
long lCount;
long x;
short nRet;
short nLen;
short byteVal;
CString szBytes;
CString szByte;
IDicomDSElementPtr pCurrentElement=NULL;
m_pLEADDicomDS->EnableMethodErrors = FALSE;
//move to the root element
m_pLEADDicomDS->MoveFirstElement(FALSE);
m_pLEADDicomDS->MoveRootElement();
m_List1.ShowWindow(SW_SHOW);
m_List1.ResetContent();
//insert some bytes into the element
szBytes = "This is a Test 1234!";
nLen = szBytes.GetLength();
m_pLEADDicomDS->BinaryValueCount = nLen;
for(x=0; x<nLen; x++)
{
byteVal = (short)szBytes.GetAt(x);
m_pLEADDicomDS->BinaryValues[x] = byteVal;
}
//set the bytes
nRet = m_pLEADDicomDS->SetBinaryValue(nLen);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
m_pLEADDicomDS->BinaryValueCount = 0; //free the values
//get the byte count
pCurrentElement = m_pLEADDicomDS->GetCurrentElement();
lCount = pCurrentElement->GetLength();
CString szOut;
szOut.Format("There are %ld bytes!", lCount);
AfxMessageBox(szOut);
//get the bytes
nRet = m_pLEADDicomDS->GetBinaryValue (lCount);
if(nRet == 0)
{
for(x=0; x<m_pLEADDicomDS->GetBinaryValueCount (); x++)
{
//display each byte as a char separated by a space
szOut.Format("%c", (char)m_pLEADDicomDS->GetBinaryValues (x));
m_List1.AddString(szOut);
}
}
AfxMessageBox("wait");
}