GetPresentationCount Example for C++ 6.0 and later
{
int i;
int nID;
int iMaxID;
CString strMsg, strTmp;
//create the Associate Class as Request
m_pLEADDicomNet->CreateAssociate (TRUE);
//set the Associate to the default
m_pLEADDicomNet->DefaultAssociate (m_pLEADDicomNet->GethPDU());
//get current ID's and display them
strMsg = "Presentation Contexts";
iMaxID = 0;
for (i = 0; i < m_pLEADDicomNet->GetPresentationCount (m_pLEADDicomNet->GethPDU()); i++)
{
nID = m_pLEADDicomNet->GetPresentationID (m_pLEADDicomNet->GethPDU(), i);
strTmp.Format("\n[%d]", nID);
strMsg = strMsg + strTmp;
//store the highest nID
if (nID > iMaxID)
iMaxID = nID;
}
AfxMessageBox(strMsg);
//nID must be unique and odd number
nID = iMaxID + 2;
//change the some ids and then display them all
for (i = 0; i<m_pLEADDicomNet->GetPresentationCount (m_pLEADDicomNet->GethPDU()); i++)
{
m_pLEADDicomNet->SetPresentationID (m_pLEADDicomNet->GethPDU(), i, nID);
nID = nID + 2;
}
strMsg = "Presentation Contexts--new IDs";
for (i = 0; i<m_pLEADDicomNet->GetPresentationCount (m_pLEADDicomNet->GethPDU()); i++)
{
nID = m_pLEADDicomNet->GetPresentationID (m_pLEADDicomNet->GethPDU(), i);
strTmp.Format("\n[%d]", nID);
strMsg = strMsg + strTmp;
}
AfxMessageBox(strMsg);
//add a presentation context
strMsg = "Presentation Contexts--Added 1";
m_pLEADDicomNet->AddPresentation (m_pLEADDicomNet->GethPDU(), 1, 1, UID_CT_IMAGE_STORAGE);
for (i = 0; i<m_pLEADDicomNet->GetPresentationCount (m_pLEADDicomNet->GethPDU()); i++)
{
nID = m_pLEADDicomNet->GetPresentationID (m_pLEADDicomNet->GethPDU(), i);
strTmp.Format("\n[%d]", nID);
strMsg = strMsg + strTmp;
}
AfxMessageBox(strMsg);
//delete the one we added
strMsg = "Presentation Contexts--Deleted 1";
m_pLEADDicomNet->DeletePresentation (m_pLEADDicomNet->GethPDU(), 1);
for (i = 0; i<m_pLEADDicomNet->GetPresentationCount (m_pLEADDicomNet->GethPDU()); i++)
{
nID = m_pLEADDicomNet->GetPresentationID (m_pLEADDicomNet->GethPDU(), i);
strTmp.Format("\n[%d]", nID);
strMsg = strMsg + strTmp;
}
AfxMessageBox(strMsg);
m_pLEADDicomNet->FreeAssociate (m_pLEADDicomNet->GethPDU());
}