#include "dicsrv.h" L_VOID DrawImageBtn(HWND hDlg, LPDRAWITEMSTRUCT pds) { DrawFrameControl(pds->hDC, &pds->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH|DFCS_PUSHED); if(gBitmap.Flags.Allocated) PaintBitmap(pds->hDC, &pds->rcItem, &gBitmap); return; } L_VOID PaintBitmap(HDC hDC, LPRECT pDest, pBITMAPHANDLE pBitmap) { HPALETTE hPaintPal, hOldPal; HBRUSH hBrush, hOldBrush; HPEN hPen, hOldPen; RECT rcDest; hBrush = GetStockObject(GRAY_BRUSH); hPen = GetStockObject(BLACK_PEN); hOldBrush = SelectObject(hDC, hBrush); hOldPen = SelectObject(hDC, hPen); CopyRect(&rcDest, pDest); hPaintPal = L_CreatePaintPalette(hDC, pBitmap); if(hPaintPal) { hOldPal = SelectPalette(hDC, hPaintPal, FALSE); RealizePalette(hDC); } MatchAspectRatio(&rcDest, BITMAPWIDTH(pBitmap), BITMAPHEIGHT(pBitmap)); InflateRect(&rcDest, -2, -2); L_PaintDC(hDC, pBitmap, NULL, NULL, &rcDest, NULL, SRCCOPY); if(hPaintPal) { SelectPalette(hDC, hOldPal, FALSE); DeleteObject(hPaintPal); } SelectObject(hDC, hOldBrush); SelectObject(hDC, hOldPen); return; } L_VOID DisplayDICOMDir(HWND hDlg) { pDICOMELEMENT pKey=NULL; TreeView_DeleteAllItems(GetDlgItem(hDlg, IDC_TREE1)); TreeView_DeleteAllItems(GetDlgItem(hDlg, IDC_TREE2)); if(gBitmap.Flags.Allocated) L_FreeBitmap(&gBitmap); pKey = L_DicomGetFirstKey(ghServerDS, NULL, FALSE); if(pKey) pKey = L_DicomGetRootKey(ghServerDS, pKey); if(pKey) DisplayDirDS(hDlg, pKey, NULL, FALSE); } L_VOID DisplayDirDS(HWND hDlg, pDICOMELEMENT pElement, HTREEITEM hParent, L_BOOL bChild) { HTREEITEM hItem=NULL; pDICOMELEMENT pChild=NULL; pDICOMELEMENT pNext=NULL; hItem = DisplayDSKey(hDlg, pElement, hParent, bChild); //try children pChild = L_DicomGetChildKey(ghServerDS, pElement); if(pChild) DisplayDirDS(hDlg, pChild, hItem, TRUE); //recurse //try next pNext = L_DicomGetNextKey(ghServerDS, pElement, TRUE); while(pNext) { hItem = DisplayDSKey(hDlg, pNext, hParent, bChild); pChild = L_DicomGetChildKey(ghServerDS, pNext); if(pChild) DisplayDirDS(hDlg, pChild, hItem, TRUE); //recurse pNext = L_DicomGetNextKey(ghServerDS, pNext, TRUE); } } HTREEITEM DisplayDSKey(HWND hDlg, pDICOMELEMENT pKey, HTREEITEM hParent, L_BOOL bChild) { L_CHAR L_FAR *pszKey=NULL; L_CHAR L_FAR *pVal=NULL; HTREEITEM hItem=NULL; L_CHAR szKey[400]; pDICOMELEMENT pElement=NULL; pDICOMELEMENT pTemp=NULL; L_UINT32 lSize; TV_INSERTSTRUCT tvis; //display key pszKey = L_DicomGetValueKey(ghServerDS, pKey); lstrcpy(szKey, ""); if(!lstrcmp(pszKey, "PATIENT")) { pTemp = L_DicomGetChildElement(ghServerDS, pKey, FALSE); pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_PATIENT_NAME, TRUE); if(!pElement) pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_PATIENT_ID, TRUE); if(pElement) { lSize = L_DicomGetConvertValue(ghServerDS, pElement, NULL); pVal = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, lSize*sizeof(L_CHAR)); if(pVal) L_DicomGetConvertValue(ghServerDS, pElement, pVal); } } else if(!lstrcmp(pszKey, "STUDY")) { pTemp = L_DicomGetChildElement(ghServerDS, pKey, FALSE); pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_STUDY_ID, TRUE); if(!pElement) pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_STUDY_INSTANCE_UID, TRUE); if(pElement) { lSize = L_DicomGetConvertValue(ghServerDS, pElement, NULL); pVal = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, lSize*sizeof(L_CHAR)); if(pVal) L_DicomGetConvertValue(ghServerDS, pElement, pVal); } } else if(!lstrcmp(pszKey, "SERIES")) { pTemp = L_DicomGetChildElement(ghServerDS, pKey, FALSE); pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_SERIES_NUMBER, TRUE); if(!pElement) pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_SERIES_INSTANCE_UID, TRUE); if(pElement) { lSize = L_DicomGetConvertValue(ghServerDS, pElement, NULL); pVal = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, lSize*sizeof(L_CHAR)); if(pVal) L_DicomGetConvertValue(ghServerDS, pElement, pVal); } } else if(!lstrcmp(pszKey, "IMAGE")) { pTemp = L_DicomGetChildElement(ghServerDS, pKey, FALSE); pElement = L_DicomFindFirstElement(ghServerDS, pTemp, TAG_INSTANCE_NUMBER, TRUE); if(pElement) { lSize = L_DicomGetConvertValue(ghServerDS, pElement, NULL); pVal = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, lSize*sizeof(L_CHAR)); if(pVal) L_DicomGetConvertValue(ghServerDS, pElement, pVal); } } else return(NULL); memset(&tvis, 0, sizeof(TV_INSERTSTRUCT)); memset(&tvis.item, 0, sizeof(TV_ITEM)); lstrcpy(szKey, pszKey); lstrcat(szKey, "-"); lstrcat(szKey, pVal); tvis.item.mask = TVIF_TEXT | TVIF_PARAM; tvis.item.pszText = szKey; tvis.item.lParam = (long)pKey; tvis.hInsertAfter = TVI_LAST; if(!hParent) tvis.hParent = TVI_ROOT; else if(!bChild) tvis.hParent = TreeView_GetNextItem(GetDlgItem(hDlg, IDC_TREE1), hParent, TVGN_PARENT); else tvis.hParent = hParent; hItem = TreeView_InsertItem(GetDlgItem(hDlg, IDC_TREE1), &tvis); if(pVal) GlobalFreePtr(pVal); return(hItem); } L_VOID DisplayKey(HWND hDlg, pDICOMELEMENT pElement, HTREEITEM hParent) { L_CHAR szTag[80]; HTREEITEM hItem=NULL; L_CHAR szName[200]; pDICOMELEMENT pTemp=NULL; L_CHAR szVal[1000]; L_UINT32 lCount; L_UINT32 x; pDICOMTAG pTag=NULL; L_CHAR L_FAR *pVal=NULL; HWND hCtl=NULL; TV_INSERTSTRUCT tvis; L_CHAR szOut[1200]; hCtl = GetDlgItem(hDlg, IDC_TREE2); ShowWindow(GetDlgItem(hDlg, IDC_LEAD1), SW_HIDE); ShowWindow(hCtl, SW_SHOW); x = 0; wsprintf(szTag, "%04X:%04X", GETGROUP(pElement->nTag), GETELEMENT(pElement->nTag)); pTag = L_DicomFindTag(pElement->nTag); lstrcpy(szName, "Unknown"); if(pTag) lstrcpy(szName, pTag->pszName); /*display value(s)*/ lstrcpy(szVal, ""); if(pElement->nTag != TAG_PIXEL_DATA) { if(pElement->nLength < 1000) /*I don't display anything > 1K*/ { lstrcpy(szVal, ": "); lCount = L_DicomGetConvertValue(ghServerDS, pElement, NULL); pVal = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, lCount*sizeof(L_CHAR)); if(pVal) { lCount = L_DicomGetConvertValue(ghServerDS, pElement, pVal); for(x=0; xhClient == hClient) break; hItem = TreeView_GetNextItem(hConnectionsCtrl, hItem, TVGN_NEXT); } if (!hItem) return; memset(&tvis, 0, sizeof(TV_INSERTSTRUCT)); tvis.hParent = hItem; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; tvis.item.pszText = "Association:"; tvis.item.iImage = 1; tvis.item.iSelectedImage = 1; hChild = TreeView_InsertItem(hConnectionsCtrl, &tvis); wsprintf(szOut, "Version: %d", L_DicomGetVersion(hPDU)); //display version tvis.hParent = hChild; tvis.hInsertAfter = TVI_LAST; tvis.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT; tvis.item.pszText = szOut; tvis.item.iImage = 2; tvis.item.iSelectedImage = 2; hChildNode = TreeView_InsertItem(hConnectionsCtrl, &tvis); wsprintf(szOut, "Called: %s", L_DicomGetCalled(hPDU)); //display called application hChildNode = TreeView_InsertItem(hConnectionsCtrl, &tvis); wsprintf(szOut, "Calling: %s", L_DicomGetCalling(hPDU)); //display calling application hChildNode = TreeView_InsertItem(hConnectionsCtrl, &tvis); pszTest = L_DicomGetApplication(hPDU); pUID = L_DicomFindUID(pszTest); if(pUID) wsprintf(szOut, "Application Context: %s - %s", pUID->pszName, pszTest); //display application context else wsprintf(szOut, "Application Context: %s", pszTest); //display application context hChildNode = TreeView_InsertItem(hConnectionsCtrl, &tvis); //get each Presentation Context for(x=0; x 0) { pUID = L_DicomFindUID(pszAbstract); if(pUID) wsprintf(szOut, "Abstract Syntax: %s - %s", pUID->pszName, pszAbstract); else wsprintf(szOut, "Abstract Syntax: %s", pszAbstract); tvis.hParent = hChildNode; TreeView_InsertItem(hConnectionsCtrl, &tvis); } //each Presentation Context can have one or more Transfer Syntax(es) lCount = L_DicomGetTransferCount(hPDU, nID); if(lCount > 0) { for(y=0; y 0) { pUID = L_DicomFindUID(pszTransfer); if(pUID) wsprintf(szOut, "Transfer Syntax: %s - %s", pUID->pszName, pszTransfer); else wsprintf(szOut, "Transfer Syntax: %s", pszTransfer); tvis.hParent = hChildNode; TreeView_InsertItem(hConnectionsCtrl, &tvis); } } } } lstrcpy(szOut, "User Information"); tvis.hParent = hChild; hChildNode = TreeView_InsertItem(hConnectionsCtrl, &tvis); if(L_DicomIsMaxLength(hPDU)) { wsprintf(szOut, "Maximum Length = %ld", L_DicomGetMaxLength(hPDU)); tvis.hParent = hChildNode; TreeView_InsertItem(hConnectionsCtrl, &tvis); } if(L_DicomIsImplementClass(hPDU)) { pszClass = L_DicomGetImplementClass(hPDU); pUID = L_DicomFindUID(pszClass); if(pUID) wsprintf(szOut, "Implementation Class: %s - %s", pUID->pszName, pszClass); else wsprintf(szOut, "Implementation Class: %s", pszClass); tvis.hParent = hChildNode; TreeView_InsertItem(hConnectionsCtrl, &tvis); } if(L_DicomIsAsyncOperations(hPDU)) { lstrcpy(szOut, "Asynchronous Operations"); tvis.hParent = hChildNode; hTemp = TreeView_InsertItem(hConnectionsCtrl, &tvis); wsprintf(szOut, "Invoked Operations: %ld", L_DicomGetInvokedOperations(hPDU)); tvis.hParent = hTemp; TreeView_InsertItem(hConnectionsCtrl, &tvis); wsprintf(szOut, "Performed Operations: %ld", L_DicomGetPerformedOperations(hPDU)); tvis.hParent = hTemp; TreeView_InsertItem(hConnectionsCtrl, &tvis); } if(L_DicomIsImplementVersion(hPDU)) { pszVersion = L_DicomGetImplementVersion(hPDU); wsprintf(szOut, "Implementation Version: %s", pszVersion); tvis.hParent = hChildNode; TreeView_InsertItem(hConnectionsCtrl, &tvis); } lCount = L_DicomGetUserInfoCount(hPDU); if(lCount > 0) { for(y=0; y