GetCharValue Example for C++ 6.0 and later
void CDicomDlg::TestProc2()
{
long lCount;
long x;
short nRet;
short nLen;
short byteVal;
CString szChars;
CString szChar;
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 a new element for the Char Values
m_pLEADDicomDS->InsertElement(FALSE, TAG_PIXEL_DATA, VR_OB, FALSE, 0);
m_List1.ShowWindow(SW_SHOW);
m_List1.ResetContent();
//insert some char values into the element
szChars = "This is a Test 1234!";
nLen = szChars.GetLength();
m_pLEADDicomDS->CharValueCount = nLen;
for(x=0; x<nLen; x++)
{
byteVal = (short)szChars.GetAt(x);
m_pLEADDicomDS->CharValues[x] = byteVal;
}
//set the chars
nRet = m_pLEADDicomDS->SetCharValue(nLen);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
m_pLEADDicomDS->CharValueCount = 0; //free the values
//get the value count
lCount = m_pLEADDicomDS->GetValueCount ();
CString szOut;
szOut.Format("There are %ld values!", lCount);
AfxMessageBox(szOut);
//get the values
nRet = m_pLEADDicomDS->GetCharValue (0, lCount);
if(nRet == 0)
{
for(x=0; x<m_pLEADDicomDS->GetCharValueCount (); x++)
{
//display each value separated by a '.'
szOut.Format("%c", (char)m_pLEADDicomDS->GetCharValues(x));
m_List1.AddString(szOut);
}
}
AfxMessageBox("wait");
}