GetTimeValue Example for C++ 6.0 and later
void CDicomDlg::TestProc10()
{
long lCount;
short nRet;
ITIMEVALUEItemPtr pTimeValue=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 a new element for the Time Values
nRet = m_pLEADDicomDS->InsertElement (FALSE, TAG_PATIENT_BIRTH_TIME, VR_TM, FALSE, 0);
//insert an Time value into the element
m_pLEADDicomDS->TimeValueCount = 1;
pTimeValue = m_pLEADDicomDS->GetTimeValues (0);
pTimeValue->Hours = 12;
pTimeValue->Minutes = 25;
pTimeValue->Seconds = 33;
pTimeValue->Fractions = 50;
//set the Time
nRet = m_pLEADDicomDS->SetTimeValue(1);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
m_pLEADDicomDS->TimeValueCount = 0; //free the value
//get the value count
lCount = m_pLEADDicomDS->GetValueCount ();
CString szOut;
szOut.Format("There are %ld values!", lCount);
AfxMessageBox(szOut);
//get the value
nRet = m_pLEADDicomDS->GetTimeValue (0, lCount);
//display the value
pTimeValue = m_pLEADDicomDS->GetTimeValues (0);
szOut.Format("Hours: %d", pTimeValue->GetHours());
m_List1.AddString(szOut);
szOut.Format("Minutes: %d", pTimeValue->GetMinutes());
m_List1.AddString(szOut);
szOut.Format("Seconds: %d", pTimeValue->GetSeconds());
m_List1.AddString(szOut);
szOut.Format("Fractions: %ld", pTimeValue->GetFractions());
m_List1.AddString(szOut);
AfxMessageBox("wait");
}