DefaultIOD example for C++ 6.0 and later
void CDicomDlg::OnButton2()
{
short nRet;
HCURSOR hOldCursor=NULL;
nRet = MessageBox("This may take a few seconds, are you sure?","", MB_YESNO);
if(nRet == IDYES)
{
m_TreeView1.DeleteAllItems();
hOldCursor = SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_WAIT)));
m_pLEADDicomDS->DefaultIOD();
FillTree();
SetCursor(hOldCursor);
DisplayNode();
}
}
void CDicomDlg::FillTree()
{
//move to root of tree
m_pLEADDicomDS->MoveFirstIOD(FALSE); //move to first IOD in tree
m_pLEADDicomDS->MoveRootIOD(); //get the root of this IOD
//now, add the IOD items
FillSubTree(NULL);
}
void CDicomDlg::FillSubTree(HTREEITEM hParent)
{
short nRet;
HTREEITEM hItem=NULL;
CString szText;
//add the node to the tree
IDicomIODItemPtr pCurrentIOD=NULL;
pCurrentIOD = m_pLEADDicomDS->GetCurrentIOD();
BSTR bstr = pCurrentIOD->GetName();
szText = bstr;
SysFreeString(bstr);
if(hParent)
hItem = m_TreeView1.InsertItem(szText, hParent);
else
hItem = m_TreeView1.InsertItem(szText);
m_TreeView1.SetItemData(hItem, pCurrentIOD->GethIOD());
nRet = m_pLEADDicomDS->MoveChildIOD(); //does this node have a child?
if(nRet == 0)
FillSubTree(hItem);
//move to next node in same level (if one)
nRet = m_pLEADDicomDS->MoveNextIOD(TRUE);
if(nRet == 0)
FillSubTree(hParent);
else
{
//move back to parent
m_pLEADDicomDS->MoveParentIOD();
}
}
void CDicomDlg::DisplayNode()
{
IDicomIODItemPtr pCurrentIOD=NULL;
CString szDisplay;
pCurrentIOD = m_pLEADDicomDS->GetCurrentIOD();
szDisplay.Format("%ld", pCurrentIOD->GetCode());
m_Text1.SetWindowText(szDisplay);
BSTR bstr = pCurrentIOD->GetName();
szDisplay = bstr;
SysFreeString(bstr);
m_Text2.SetWindowText(szDisplay);
szDisplay.Format("%d", pCurrentIOD->GetType());
m_Text3.SetWindowText(szDisplay);
szDisplay.Format("%d", pCurrentIOD->GetUsage());
m_Text4.SetWindowText(szDisplay);
bstr = pCurrentIOD->GetDescription();
szDisplay = bstr;
SysFreeString(bstr);
m_Text5.SetWindowText(szDisplay);
m_Text6.SetWindowText(szDisplay);
}