GetStringValue Example for C++ 6.0 and later
void CDicomDlg::TestProc7()
{
long lCount;
long x;
short nRet;
m_pLEADDicomDS->EnableMethodErrors = FALSE;
//move to the root element
m_pLEADDicomDS->MoveFirstElement (FALSE);
m_pLEADDicomDS->MoveRootElement ();
//insert a new element for the String Values
nRet = m_pLEADDicomDS->InsertElement (FALSE, TAG_IMAGE_TYPE, VR_CS, FALSE, 0);
//insert some String values into the element
m_pLEADDicomDS->StringValueCount = 5;
for(x=0; x<5; x++)
{
CString szText;
szText.Format("%d", x+1);
szText = "String#" + szText;
BSTR bstr = szText.AllocSysString();
m_pLEADDicomDS->StringValues [x] = bstr;
SysFreeString(bstr);
}
//set the Strings
nRet = m_pLEADDicomDS->SetStringValue (5);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
m_pLEADDicomDS->StringValueCount = 0; //free the values
//get the value count
lCount = m_pLEADDicomDS->GetValueCount ();
CString szOut;
szOut.Format("There are %ld values!", lCount);
AfxMessageBox(szOut);
szOut.Empty();
//get the values
nRet = m_pLEADDicomDS->GetStringValue (0, lCount);
if(nRet == 0)
{
for(x=0; x<m_pLEADDicomDS->GetStringValueCount (); x++)
{
//display each value separated by a '.'
szOut += m_pLEADDicomDS->GetStringValues (x);
szOut += "\n";
}
}
AfxMessageBox(szOut);
}