/*[]=====================================================================[]*/ /*[] LeadTools Run Time Library - Version 11 []*/ /*[] []*/ /*[] []*/ /*[] Copyright (c) 1991-2000 LEAD Technologies, Inc. []*/ /*[] All Rights Reserved. []*/ /*[] []*/ /*[] File Dicom.c []*/ /*[] []*/ /*[]=====================================================================[]*/ /*------------------------------------------------------------------------- We have made the assumption that the user has the knowledge of programming in C and Windows. This demo program demonstrates the use of the LEAD Dicom API functions to build a complete Dicom Client application. After compiling this demo, go to the "Network" menu, then "Connect" to bring up the "Connections" dialog box. Click the "Insert" button to add information for a Dicom server. Here you also specify the timeout (in seconds) for each client-server communication. After a valid server configuration has been added, choose the "Connect" button to connect to the server. Now you can choose a Dicom services, including * C-ECHO-RQ * C-STORE-RQ * Find Patient Root * Find Patient Study * Find Patient Root/Study Only * C-CANCEL-RQ When finished, close the connection to the server by choosing "Disconnect" from the "Network" menu item. --------------------------------------------------------------------------*/ #include #include #include /* Needed for message crackers. */ #include /* Windows' header for common controls. */ #include "resource.h" #include "..\\..\\..\\include\\ltkrn.h" #include "..\\..\\..\\include\\ltfil.h" #include "..\\..\\..\\include\\ltdic.h" #include "..\\..\\..\\include\\ltlck.h" #include "dicom.h" #include "utils.h" #include "commun.h" #include "globals.h" #include "dirTree.h" #include "draw.h" #include "store.h" #include "process.h" #define MAX_LOADSTRING 100 // Global Variables: TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text //IDD_ASSOCIATION_DIALOG state variables L_BOOL m_bMaxLength; L_BOOL m_bImplementClass; L_BOOL m_bAsyncOperations; L_BOOL m_bImplementVersion; HWND CreateStatusBar(HWND hwndParent, L_INT nStatusID) { HWND hwndStatus; L_INT nParts = 5; // Ensure that the common control DLL is loaded. InitCommonControls(); // Create the status bar. hwndStatus = CreateWindowEx( 0, // no extended styles STATUSCLASSNAME, // name of status bar class (LPCTSTR) NULL, // no text when first created WS_CHILD | WS_VISIBLE |WS_CLIPSIBLINGS | CCS_BOTTOM | SBARS_SIZEGRIP, 0, 0, 0, 0, // ignores size and position hwndParent, // handle to parent window (HMENU) nStatusID, // child window identifier hInst, // handle to application instance NULL); // no window creation data return hwndStatus; } L_VOID DisplayInfoTitleBar(HWND hDlg) { L_CHAR szMsg[MAX_STRING_LEN]; switch (uSecureMode) { case DICOM_SECURE_NONE: wsprintf(szMsg, "hNetGlobal[%x] hNetListenGlobal[%x]", hNetGlobal, hNetListenGlobal); break; case DICOM_SECURE_ISCL: wsprintf(szMsg, "hNetGlobal[%x] hNetListenGlobal[%x]", hNetGlobalISCL, hNetListenGlobal); break; case DICOM_SECURE_TLS: wsprintf(szMsg, "hNetGlobal[%x] hNetListenGlobal[%x]", hNetGlobalTLS, hNetListenGlobal); break; } SetWindowText(hDlg, szMsg); } L_VOID InitConnections() { L_INT i; L_INT iRet; HANDLE hFile; DWORD dBytesRead; connections.nCount = 0; //If connections file exists, load into connections strucure hFile = CreateFile( FILE_CONNECTIONS, // pointer to name of the file GENERIC_READ, // access (read-write) mode FILE_SHARE_READ, // share mode NULL, // pointer to security attributes OPEN_EXISTING, // how to create FILE_ATTRIBUTE_NORMAL, // file attributes SECURITY_ANONYMOUS // handle to file with attributes to copy ); if (INVALID_HANDLE_VALUE != hFile) { ReadFile( hFile, // handle of file to read (LPVOID)&uTimeOutGlobal, // pointer to buffer that receives data sizeof(uTimeOutGlobal), // number of bytes to read &dBytesRead, // pointer to number of bytes read NULL // pointer to structure for data ); ReadFile( hFile, // handle of file to read (LPVOID)&connections.nCount, // pointer to buffer that receives data sizeof(connections.nCount), // number of bytes to read &dBytesRead, // pointer to number of bytes read NULL // pointer to structure for data ); for (iRet = !EOF, i = 0; ( iRet != EOF) && (i < MAX_CONNECTIONS) && (i szName); ListView_SetItemText(hListView, iIndex, 1, pConnection->szServerIP); ListView_SetItemText(hListView, iIndex, 2, IntToString(pConnection->uServerPort, szPort)); ListView_SetItemText(hListView, iIndex, 3, pConnection->szCalledAE); ListView_SetItemText(hListView, iIndex, 4, pConnection->szCallingAE); ListView_SetItemText(hListView, iIndex, 5, pConnection->szClientIP); ListView_SetItemText(hListView, iIndex, 6, IntToString(pConnection->uClientPort, szPort)); } L_VOID ListViewAddConnection(HWND hListView, L_INT i, pCONNECTION pConnection) { LV_ITEM lvItem; L_CHAR szPort[MAX_STRING_LEN]; lvItem.mask = LVIF_TEXT; lvItem.pszText = pConnection->szName; lvItem.iItem = i; //ListView_GetItemCount(hListView); lvItem.iSubItem = 0; ListView_InsertItem(hListView, &lvItem); lvItem.pszText = pConnection->szServerIP; lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); lvItem.pszText = IntToString(pConnection->uServerPort, szPort); lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); lvItem.pszText = pConnection->szCalledAE; lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); lvItem.pszText = pConnection->szCallingAE; lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); lvItem.pszText = pConnection->szClientIP; lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); lvItem.pszText = IntToString(pConnection->uClientPort, szPort); lvItem.iSubItem++; ListView_SetItem(hListView, &lvItem); } L_VOID AddConnection(HWND hListView, pCONNECTION pConnection) { if (connections.nCount < MAX_CONNECTIONS) { connections.connection[connections.nCount] = *pConnection; connections.nCount++; ListViewAddConnection(hListView,connections.nCount-1, pConnection); } } L_VOID ListViewInit(HWND hDlg) { LV_COLUMN col; HWND hListView = GetDlgItem(hDlg,IDC_CONNECTIONS); L_INT i; col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; col.fmt = LVCFMT_LEFT; col.cx = 120; col.pszText = "Name"; col.iSubItem = 0; ListView_InsertColumn(hListView, 0, &col); col.pszText = "Server Address"; col.cx = 100; ListView_InsertColumn(hListView, 1, &col); col.pszText = "Server Port"; col.cx = 75; ListView_InsertColumn(hListView, 2, &col); col.pszText = "Called Application"; col.cx = 100; ListView_InsertColumn(hListView, 3, &col); col.pszText = "Calling Application"; ListView_InsertColumn(hListView, 4, &col); col.pszText = "Local Address"; ListView_InsertColumn(hListView, 5, &col); col.pszText = "Local Port"; col.cx = 75; ListView_InsertColumn(hListView, 6, &col); for (i = 0; i < connections.nCount; i++) { ListViewAddConnection(hListView, i, &connections.connection[i]); } SetDlgItemInt(hDlg, IDC_TIMEOUT, uTimeOutGlobal, FALSE); } L_INT APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, L_INT nCmdShow) { MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_DICOM, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_DICOM); L_DlgInit(DLG_INIT_COLOR); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } L_DlgFree(); return msg.wParam; } HWND CreateTreeKey(HWND hWnd) { HWND hTreeKey; DWORD dwStyle; RECT rcRect, rcStatus; GetClientRect(hWnd, &rcRect); GetClientRect(hStatusBarGlobal, &rcStatus); //Create TreeView dwStyle = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP; //Create tree control for logging messages hTreeKey = CreateWindowEx( WS_EX_CLIENTEDGE, // extended window style WC_TREEVIEW, // pointer to registered class name "", // pointer to window name dwStyle, // window style rcRect.right / 2, // horizontal position of window 0, // vertical position of window rcRect.right / 2, // window width rcRect.bottom - rcStatus.bottom, // window height hWnd, // handle to parent or owner window (HMENU)IDC_KEY, // handle to menu, or child-window identifier hInst, // handle to application instance NULL // pointer to window-creation data ); return hTreeKey; } HWND CreateTreeMsg(HWND hWnd) { HWND hTreeMsg; DWORD dwStyle; RECT rcRect; RECT rcStatus; GetClientRect(hWnd, &rcRect); GetClientRect(hStatusBarGlobal, &rcStatus); //Create TreeView dwStyle = WS_CHILD | WS_BORDER | WS_VISIBLE | WS_VSCROLL | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP; //Create tree control for logging messages hTreeMsg = CreateWindowEx( WS_EX_CLIENTEDGE, // extended window style WC_TREEVIEW, // pointer to registered class name "", // pointer to window name dwStyle, // window style 0, // horizontal position of window (L_INT)(rcRect.bottom * TREE_FRACTION), // vertical position of window rcRect.right/2, // window width (L_INT)(rcRect.bottom * (1-TREE_FRACTION ) - rcStatus.bottom), // window height hWnd, // handle to parent or owner window (HMENU)IDC_MESSAGE, // handle to menu, or child-window identifier hInst, // handle to application instance NULL // pointer to window-creation data ); if (hTreeMsg) { TreeView_SetImageList(hTreeMsg, hImageListGlobal, TVSIL_NORMAL); } return hTreeMsg; } //uFlag = MF_ENABLED or MF_DISABLED L_VOID EnableMenus(HWND hWnd, UINT uFlag) { HMENU hMenu; hMenu = GetMenu(hWnd); //Network Menu EnableMenuItem(hMenu, ID_NETWORK_CONNECT, uFlag); EnableMenuItem(hMenu, ID_NETWORK_DISCONNECT, uFlag); EnableMenuItem(hMenu, ID_NETWORK_INFO, uFlag); EnableMenuItem(hMenu, ID_NETWORK_CLEAR, uFlag); EnableMenuItem(hMenu, ID_NETWORK_CLEARALL, uFlag); EnableMenuItem(hMenu, IDM_EXIT, MF_ENABLED); //Services Menu EnableMenuItem(hMenu, ID_SERVICES_ECHO, uFlag); EnableMenuItem(hMenu, ID_SERVICES_STORE, uFlag); EnableMenuItem(hMenu, ID_SERVICES_FINDPATIENTROOT, uFlag); EnableMenuItem(hMenu, ID_SERVICES_FINDSTUDYROOT, uFlag); EnableMenuItem(hMenu, ID_SERVICES_FINDPATIENTSTUDYONLY, uFlag); EnableMenuItem(hMenu, ID_SERVICES_RETRIEVE, uFlag); if (uFlag == MF_ENABLED) EnableMenuItem(hMenu, ID_SERVICES_CANCEL, MF_DISABLED); else EnableMenuItem(hMenu, ID_SERVICES_CANCEL, MF_ENABLED); //Preferences Menu EnableMenuItem(hMenu, ID_PREFERENCES_ASSOCIATION, uFlag); EnableMenuItem(hMenu, ID_PREFERENCES_UIDS, uFlag); } L_VOID UpdateMenus(HWND hWnd) { HMENU hMenu; UINT uConnectEnable, uConnectDisable; UINT uAssociateEnable, uAssociateDisable; UINT uFindPatientRootEnable, uFindStudyRootEnable, uFindPatientStudyOnlyEnable; UINT uRetrieveEnable, uCancel; L_UCHAR nPresentationID; L_BOOL bLogEmpty, bAllEmpty, bAssociated; L_BOOL bFindPatientRootEnable, bFindStudyRootEnable, bFindPatientStudyOnlyEnable; L_BOOL bRetrieveEnable, bCancel; HTREEITEM hDirItem; L_CHAR* pszDRType; //if a process is currently running, disable all windows except Cancel if (processGlobal.nStatus == PROCESS_STATUS_PENDING) { EnableMenus(hWnd, MF_GRAYED); return; } //Set flags hMenu = GetMenu(hWnd); uConnectDisable = bConnectedGlobal*MF_GRAYED + (!bConnectedGlobal)*MF_ENABLED; uConnectEnable = (!bConnectedGlobal*MF_GRAYED) + (bConnectedGlobal)*MF_ENABLED; bAssociated = (hAssociateAccept != NULL); uAssociateDisable = bAssociated*MF_GRAYED + (!bAssociated)*MF_ENABLED; uAssociateEnable = (!bAssociated*MF_GRAYED) + (bAssociated)*MF_ENABLED; bFindPatientRootEnable = FALSE; bFindStudyRootEnable = FALSE; bFindPatientStudyOnlyEnable = FALSE; bRetrieveEnable = FALSE; if (bAssociated) { //FindPatientRoot menu item nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_PATIENT_ROOT_QUERY_FIND); bFindPatientRootEnable = (nPresentationID != 0) && (L_DicomGetResult(hAssociateAccept, nPresentationID) == PDU_ACCEPT_RESULT_SUCCESS); //FindStudyRoot menu item nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_STUDY_ROOT_QUERY_FIND); bFindStudyRootEnable = (nPresentationID != 0) && (L_DicomGetResult(hAssociateAccept, nPresentationID) == PDU_ACCEPT_RESULT_SUCCESS); //FindPatientStudyOnly menu item nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_PATIENT_STUDY_QUERY_FIND); bFindPatientStudyOnlyEnable = (nPresentationID != 0) && (L_DicomGetResult(hAssociateAccept, nPresentationID) == PDU_ACCEPT_RESULT_SUCCESS); // "Retrieve" menu item bRetrieveEnable = TRUE; hDirItem = TreeView_GetSelection(hTreeDir); if (hDirItem) { pszDRType = L_DicomGetValueKey(hDSGlobal, (pDICOMELEMENT) TV_GetItemData(hTreeDir, hDirItem)); if (lstrcmpi("IMAGE", pszDRType) == 0) { if ((TV_GetItemState(hTreeDir, hDirItem, TVIS_BOLD) & TVIS_BOLD) == 0) bRetrieveEnable = FALSE; } } else { bRetrieveEnable = FALSE; } if (bRetrieveEnable) { nPresentationID = 0; switch (nQueryMethodGlobal) { case QUERY_PATIENT_ROOT: nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_PATIENT_ROOT_QUERY_MOVE); break; case QUERY_STUDY_ROOT: nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_STUDY_ROOT_QUERY_MOVE); break; case QUERY_PATIENT_STUDY_ONLY: nPresentationID = L_DicomFindAbstract(hAssociateAccept, UID_PATIENT_STUDY_QUERY_MOVE); break; } bRetrieveEnable = (nPresentationID != 0) && (L_DicomGetResult(hAssociateAccept, nPresentationID) == PDU_ACCEPT_RESULT_SUCCESS); } } uFindPatientRootEnable = (!bFindPatientRootEnable*MF_GRAYED) + (bFindPatientRootEnable)*MF_ENABLED; uFindStudyRootEnable = (!bFindStudyRootEnable*MF_GRAYED) + (bFindStudyRootEnable)*MF_ENABLED; uFindPatientStudyOnlyEnable = (!bFindPatientStudyOnlyEnable*MF_GRAYED) + (bFindPatientStudyOnlyEnable)*MF_ENABLED; uRetrieveEnable = (!bRetrieveEnable * MF_GRAYED) + (bRetrieveEnable * MF_ENABLED); //Network Menu EnableMenuItem(hMenu, ID_NETWORK_CONNECT, uConnectDisable); EnableMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, uConnectDisable); EnableMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, uConnectDisable); EnableMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, uConnectDisable); EnableMenuItem(hMenu, ID_SECURITY_SETTINGS, uConnectDisable); EnableMenuItem(hMenu, ID_NETWORK_DISCONNECT, uConnectEnable); EnableMenuItem(hMenu, ID_NETWORK_INFO, uAssociateEnable); bLogEmpty = GetLogCount() == 0; EnableMenuItem(hMenu, ID_NETWORK_CLEAR, bLogEmpty*MF_GRAYED + (!bLogEmpty)*MF_ENABLED); bAllEmpty = GetAllCount() == 0; EnableMenuItem(hMenu, ID_NETWORK_CLEARALL, bAllEmpty*MF_GRAYED + (!bAllEmpty)*MF_ENABLED); bCancel = processGlobal.nStatus == PROCESS_STATUS_PENDING; uCancel = (!bCancel*MF_GRAYED) + (bCancel)*MF_ENABLED; //Services Menu EnableMenuItem(hMenu, ID_SERVICES_ECHO, uAssociateEnable); EnableMenuItem(hMenu, ID_SERVICES_STORE, uAssociateEnable); EnableMenuItem(hMenu, ID_SERVICES_FINDPATIENTROOT, uFindPatientRootEnable); EnableMenuItem(hMenu, ID_SERVICES_FINDSTUDYROOT, uFindStudyRootEnable); EnableMenuItem(hMenu, ID_SERVICES_FINDPATIENTSTUDYONLY, uFindPatientStudyOnlyEnable); EnableMenuItem(hMenu, ID_SERVICES_RETRIEVE, uRetrieveEnable); EnableMenuItem(hMenu, ID_SERVICES_CANCEL, uCancel); //Preferences Menu EnableMenuItem(hMenu, ID_PREFERENCES_ASSOCIATION, uAssociateDisable); EnableMenuItem(hMenu, ID_PREFERENCES_UIDS, uAssociateDisable); } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage is only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_DICOM); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_DICOM; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_LEAD); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, L_INT) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, L_INT nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } VOID InitOptions() { char* pBackslash; DWORD dwSize; // The folder where the received files will be stored if (GetModuleFileName(NULL, szStoreFolder, sizeof(szStoreFolder))) { pBackslash = strrchr(szStoreFolder, '\\'); if (pBackslash) *(pBackslash + 1) = '\0'; } else { szStoreFolder[0] = '\0'; } lstrcpy(szExtension, "dcm"); // The extension used // The folder used for temporary files szTempFilesFolder[0] = '\0'; dwSize = GetTempPath(0, NULL); if (dwSize != 0 && dwSize <= sizeof(szTempFilesFolder)) { if (!GetTempPath(sizeof(szTempFilesFolder), szTempFilesFolder)) { szTempFilesFolder[0] = '\0'; } } if (szTempFilesFolder[0] == '\0') { lstrcpy(szTempFilesFolder, szStoreFolder); } } // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { L_INT wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; HMENU hMenu; L_INT nRet; switch (message) { case WM_CREATE: UNLOCKSUPPORT(); { L_BOOL ret1, ret2; ret1 = L_IsSupportLocked(L_SUPPORT_MEDICAL); ret2 = L_IsSupportLocked(L_SUPPORT_MEDICAL_NET); if ( ret1 || ret2 ) { MessageBox(hWnd, "Dicom capabilities are locked!", "Warning", MB_ICONEXCLAMATION); } } //Load status bar icons and create status bar hIconRedGlobal = LoadIcon(hInst, MAKEINTRESOURCE(IDI_RED)); hIconGreen1Global = LoadIcon(hInst, MAKEINTRESOURCE(IDI_GREEN1)); hIconGreen2Global = LoadIcon(hInst, MAKEINTRESOURCE(IDI_GREEN2)); hIconStatusGlobal = hIconRedGlobal; hStatusBarGlobal = CreateStatusBar(hWnd, ID_STATUS_BAR); //Create image list for tree views hImageListGlobal = ImageList_Create(IMAGESIZE, IMAGESIZE, ILC_COLOR, NUM_ICONS, 1); ImageList_AddIcon(hImageListGlobal, LoadIcon(hInst, MAKEINTRESOURCE(IDI_BULLET))); ImageList_AddIcon(hImageListGlobal, LoadIcon(hInst, MAKEINTRESOURCE(IDI_SEND))); ImageList_AddIcon(hImageListGlobal, LoadIcon(hInst, MAKEINTRESOURCE(IDI_RECEIVE))); ImageList_AddIcon(hImageListGlobal, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ERROR_))); //Create the TreeViews hTreeMsg = CreateTreeMsg(hWnd); hTreeDir = CreateTreeDir(hWnd); hTreeKey = CreateTreeKey(hWnd); //Store a handle to the main window hWndMainGlobal = hWnd; //Create a button for displaying the image hButtonImage = CreateButtonImage(hWnd); InitOptions(); //Initialize global Data Set hDSGlobal = L_DicomCreateDS(szTempFilesFolder); //Start the network (ONCE per session) nRet = L_DicomStartUp(); //Create hNetGlobal object ONCE per session hNetGlobal = L_DicomCreateNet(szTempFilesFolder, DICOM_SECURE_NONE); hNetGlobalISCL = L_DicomCreateNet(szTempFilesFolder, DICOM_SECURE_ISCL); hNetGlobalTLS = L_DicomCreateNet(szTempFilesFolder, DICOM_SECURE_TLS); LoadDefaultSettings(); SetCallbacks(hNetGlobal); SetCallbacks(hNetGlobalISCL); SetCallbacks(hNetGlobalTLS); SetCallbacksExt(hNetGlobalTLS); //Create hNet object for when server connects to me //This happens on CGet and CMove requests hNetListenGlobal = L_DicomCreateNet(szTempFilesFolder, DICOM_SECURE_NONE); SetCallbacks(hNetListenGlobal); //Initialize the associate request and default associate objects hAssociateRequest = L_DicomCreateAssociate(TRUE); L_DicomDefaultAssociate(hAssociateRequest); L_DicomSetImplementClass(hAssociateRequest, TRUE, IMPLEMENTATION_CLASS_UID); L_DicomSetImplementVersion(hAssociateRequest, TRUE, IMPLEMENTATION_VERSION_NAME); hAssociateAll = L_DicomCreateAssociate(TRUE); if (DEBUG_PROCESS_MSG) DisplayInfoTitleBar(hWnd); //Initialize the dicom bitmap L_InitBitmap(&DicomBitmap, sizeof(BITMAPHANDLE),0, 0, 16); if (hPaletteGlobal != NULL) { DeleteObject(hPaletteGlobal); hPaletteGlobal = NULL; } //Initialize the status bar StatusInit(TRUE); uSecureMode = DICOM_SECURE_NONE; nQueryMethodGlobal = QUERY_PATIENT_ROOT; break; case WM_SIZE: { L_INT nParts = 5; L_INT aWidths[5]; RECT rcClient, rcStatus; L_INT nWidth, nHeight; GetClientRect(hWnd, &rcClient); GetClientRect(hStatusBarGlobal, &rcStatus); //Resize the status bar nWidth = rcClient.right; nHeight = rcClient.bottom; aWidths[0] = nWidth - 500; aWidths[1] = nWidth - 400; aWidths[2] = nWidth - 300; aWidths[3] = nWidth - 50; aWidths[4] = nWidth; SendMessage(hStatusBarGlobal, SB_SETPARTS, (WPARAM)nParts, (LPARAM)&aWidths[0]); MoveWindow(hStatusBarGlobal, 0, rcClient.bottom -rcStatus.bottom, LOWORD(lParam), HIWORD(lParam), TRUE); PaintBlink(); StatusInit(FALSE); //Resize Tree Views MoveWindow(hTreeDir, 0, 0, (L_INT)(nWidth/2), (L_INT)(nHeight * (TREE_FRACTION)), TRUE); MoveWindow(hTreeKey, (L_INT)(nWidth/2), 0, (L_INT)(nWidth/2), nHeight - rcStatus.bottom, TRUE); MoveWindow( hTreeMsg, 0, (L_INT)(nHeight * TREE_FRACTION), (L_INT)(nWidth/2), (L_INT)(nHeight * (1-TREE_FRACTION)) - rcStatus.bottom, TRUE); //Resize Button Image MoveWindow(hButtonImage, (L_INT)(nWidth/2), 0, (L_INT)(nWidth/2), nHeight - rcStatus.bottom, TRUE); } break; case WM_INITMENUPOPUP: UpdateMenus(hWnd); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); switch (wmId) { case ID_NETWORK_CONNECT: AllClear(); InitProcess(); switch (uSecureMode) { case DICOM_SECURE_NONE: DialogBoxParam(hInst, (LPCTSTR)IDD_CLTCONN_DIALOG, hWnd, (DLGPROC)DlgConnections, (LPARAM)&hNetGlobal); break; case DICOM_SECURE_ISCL: DialogBoxParam(hInst, (LPCTSTR)IDD_CLTCONN_DIALOG, hWnd, (DLGPROC)DlgConnections, (LPARAM)&hNetGlobalISCL); break; case DICOM_SECURE_TLS: DialogBoxParam(hInst, (LPCTSTR)IDD_CLTCONN_DIALOG, hWnd, (DLGPROC)DlgConnections, (LPARAM)&hNetGlobalTLS); break; } break; case ID_NETWORK_DISCONNECT: switch (uSecureMode) { case DICOM_SECURE_NONE: DisconnectFromServer(hNetGlobal); break; case DICOM_SECURE_ISCL: DisconnectFromServer(hNetGlobalISCL); break; case DICOM_SECURE_TLS: DisconnectFromServer(hNetGlobalTLS); break; } InfoClear(); break; case ID_NETWORK_INFO: DialogBox(hInst, (LPCTSTR)IDD_SESSION_INFO_DIALOG, hWnd, (DLGPROC)DlgSessionInfo); break; case ID_NETWORK_CLEAR: case ID_CLEAR: LogClear(); break; case ID_NETWORK_CLEARALL: AllClear(); break; case ID_SECURITY_NOSECUREMODE: hMenu = GetSubMenu(GetMenu(hWnd), 1); nRet = CheckMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, MF_BYCOMMAND); if (nRet == MF_CHECKED) { CheckMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, MF_UNCHECKED); } else { uSecureMode = DICOM_SECURE_NONE; CheckMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, MF_CHECKED); CheckMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, MF_UNCHECKED); CheckMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, MF_UNCHECKED); } break; case ID_SECURITY_ISCLSECUREMODE: hMenu = GetSubMenu(GetMenu(hWnd), 1); nRet = CheckMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, MF_BYCOMMAND); if (nRet == MF_CHECKED) { CheckMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, MF_UNCHECKED); } else { uSecureMode = DICOM_SECURE_ISCL; CheckMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, MF_UNCHECKED); CheckMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, MF_CHECKED); CheckMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, MF_UNCHECKED); } break; case ID_SECURITY_TLSSECUREMODE: hMenu = GetSubMenu(GetMenu(hWnd), 1); nRet = CheckMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, MF_BYCOMMAND); if (nRet == MF_CHECKED) { CheckMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, MF_UNCHECKED); } else { uSecureMode = DICOM_SECURE_TLS; CheckMenuItem(hMenu, ID_SECURITY_NOSECUREMODE, MF_UNCHECKED); CheckMenuItem(hMenu, ID_SECURITY_ISCLSECUREMODE, MF_UNCHECKED); CheckMenuItem(hMenu, ID_SECURITY_TLSSECUREMODE, MF_CHECKED); } break; case ID_SECURITY_SETTINGS: InitSecurity(hWnd); break; case ID_SERVICES_ECHO: CEchoRequest(); break; case ID_SERVICES_STORE: CStoreRequest(hWnd); break; case ID_SERVICES_FINDPATIENTROOT: { PATIENT patient; L_INT nRet; patient.uQueryType = QUERY_PATIENT_ROOT; nRet = DialogBoxParam( hInst, (LPCTSTR)IDD_FIND_PATIENT_DIALOG, hWnd, (DLGPROC)DlgFindPatientRoot, (LPARAM)&patient); if (nRet == IDOK) { FindPatientRoot(&patient); } } break; case ID_SERVICES_FINDSTUDYROOT: { STUDY study; L_INT nRet; nRet = DialogBoxParam( hInst, (LPCTSTR)IDD_FIND_STUDY_DIALOG, hWnd, (DLGPROC)DlgFindStudyRoot, (LPARAM)&study); if (nRet == IDOK) { FindStudyRoot(&study); } } break; case ID_SERVICES_FINDPATIENTSTUDYONLY: { PATIENT patient; L_INT nRet; patient.uQueryType = QUERY_PATIENT_STUDY_ONLY; nRet = DialogBoxParam( hInst, (LPCTSTR)IDD_FIND_PATIENT_DIALOG, hWnd, (DLGPROC)DlgFindPatientRoot, (LPARAM)&patient); if (nRet == IDOK) { FindPatientRoot(&patient); } } break; case ID_SERVICES_RETRIEVE: Retrieve(); break; case ID_SERVICES_CANCEL: switch (uSecureMode) { case DICOM_SECURE_NONE: L_DicomSendCCancelRequest( hNetGlobal, processGlobal.nPresentationID, (L_UINT16) (uUniqueMessageID - 1) ); break; case DICOM_SECURE_ISCL: L_DicomSendCCancelRequest( hNetGlobalISCL, processGlobal.nPresentationID, (L_UINT16) (uUniqueMessageID - 1) ); break; case DICOM_SECURE_TLS: L_DicomSendCCancelRequest( hNetGlobalTLS, processGlobal.nPresentationID, (L_UINT16) (uUniqueMessageID - 1) ); break; } LogMessage(MSG_SEND, "C-CANCEL-RQ"); StatusCommand(STATUS_NONE, "Sending C-CANCEL-RQ", TRUE); break; case ID_PREFERENCES_ASSOCIATION: DialogBox(hInst, (LPCTSTR)IDD_ASSOCIATION_DIALOG, hWnd, (DLGPROC)DlgAssociation); break; case ID_PREFERENCES_OPTIONS: DialogBox(hInst, (LPCTSTR)IDD_OPTIONS_DIALOG, hWnd, (DLGPROC)DlgOptions); break; case ID_PREFERENCES_UIDS: DialogBox(hInst, (LPCTSTR)IDD_UID_DIALOG, hWnd, (DLGPROC)DlgUID); break; case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_NOTIFY: { NMHDR *pnmh; LRESULT lResult; pnmh = (LPNMHDR)lParam; if (pnmh->hwndFrom == hTreeDir) { switch (pnmh->code) { case NM_DBLCLK: OnDirDoubleClick(pnmh, &lResult); return TRUE; break; case TVN_SELCHANGED: OnSelChangedDir(pnmh, &lResult); return TRUE; break; } } } break; //WM_QUERYNEWPALETTE:about to get the focus // realize palette as foreground palette // //WM_PALETTECHANGED: another window has realized palette as forground // realize palette as background palette (color match with existing palette) // //WM_PAINT: realize palette as background // if window with focus, it first gets WM_PALETTECHANGED, realizes as foreground //case WM_SYSCOLORCHANGE: case WM_PALETTECHANGED: { if ((HWND)wParam == hWnd) break; { HDC hDC; HPALETTE hOldPal; L_UINT uRet=0; if (hPaletteGlobal != NULL) { //return TRUE if window realizes its logical palette //return FALSE otherwise hDC = GetDC(hWnd); hOldPal = SelectPalette(hDC, hPaletteGlobal, TRUE); uRet = RealizePalette(hDC); ReleaseDC(hWnd, hDC); if (uRet) InvalidateRect(hButtonImage, NULL, TRUE); } return (uRet); } } case WM_QUERYNEWPALETTE: { HDC hDC; HPALETTE hOldPal; L_UINT uRet = 0; //return TRUE if window realizes its logical palette //return FALSE otherwise if (hPaletteGlobal != NULL) { hDC = GetDC(hWnd); hOldPal = SelectPalette(hDC, hPaletteGlobal, FALSE); uRet = RealizePalette(hDC); ReleaseDC(hWnd, hDC); if (uRet) InvalidateRect(hButtonImage, NULL, TRUE); } return (uRet); } case WM_PAINT: { RECT rt; hdc = BeginPaint(hWnd , &ps); GetClientRect(hWnd, &rt); EndPaint(hWnd, &ps); } break; case WM_DRAWITEM: { UINT idCtl; LPDRAWITEMSTRUCT lpdis; idCtl = (UINT) wParam; // control identifier lpdis = (LPDRAWITEMSTRUCT) lParam; // item-drawing information if (idCtl == IDC_BUTTON_IMAGE) { if (DicomBitmap.Flags.Allocated) { PaintBitmap(lpdis->hDC, &lpdis->rcItem, &DicomBitmap); } } } return TRUE; break; case WM_DESTROY: //Free icon resources DestroyIcon(hIconRedGlobal); DestroyIcon(hIconGreen1Global); DestroyIcon(hIconGreen2Global); //Free tree views and image lists ImageList_Destroy(hImageListGlobal); DestroyWindow(hTreeMsg); DestroyWindow(hTreeDir); DestroyWindow(hTreeKey); //Free associate request and default associate objects L_DicomFreeAssociate(hAssociateRequest); L_DicomDefaultAssociate(hAssociateAll); //Free global data set L_DicomFreeDS(hDSGlobal); //Shut down the network L_DicomShutDown(); //L_DicomFreeNet frees the hAssociateAccept object switch (uSecureMode) { case DICOM_SECURE_NONE: L_DicomFreeNet(hNetGlobal); break; case DICOM_SECURE_ISCL: L_DicomFreeNet(hNetGlobalISCL); break; case DICOM_SECURE_TLS: // L_DicomFreeNet(hNetGlobalTLS); break; } L_DicomFreeNet(hNetListenGlobal); //Free the LEAD bitmap L_FreeBitmap(&DicomBitmap); if (hPaletteGlobal != NULL) { DeleteObject(hPaletteGlobal); hPaletteGlobal = NULL; } PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; break; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; } // Mesage handler for Connection Properties dialog box. LRESULT CALLBACK DlgConnectionProperties(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { pCONNECTION pConnection; L_CHAR szPort[MAX_STRING_LEN]; pConnection = (pCONNECTION)GetWindowLong(hDlg, GWL_USERDATA); switch (message) { case WM_INITDIALOG: SetWindowLong(hDlg, GWL_USERDATA, lParam); pConnection = (pCONNECTION)lParam; SetDlgItemText(hDlg, IDC_NAME, pConnection->szName); SetDlgItemText(hDlg, IDC_SERVER_IP, pConnection->szServerIP); SetDlgItemText(hDlg, IDC_SERVER_PORT, IntToString(pConnection->uServerPort, szPort)); SetDlgItemText(hDlg, IDC_CALLED_AE, pConnection->szCalledAE); SetDlgItemText(hDlg, IDC_CALLING_AE, pConnection->szCallingAE); SetDlgItemText(hDlg, IDC_CLIENT_IP, pConnection->szClientIP); SetDlgItemText(hDlg, IDC_CLIENT_PORT, IntToString(pConnection->uClientPort, szPort)); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; break; case IDOK: GetDlgItemText(hDlg, IDC_NAME, pConnection->szName, sizeof(pConnection->szName)); GetDlgItemText(hDlg, IDC_SERVER_IP, pConnection->szServerIP, sizeof(pConnection->szServerIP)); GetDlgItemText(hDlg, IDC_SERVER_PORT, szPort, sizeof(szPort)); pConnection->uServerPort = atoi(szPort); GetDlgItemText(hDlg, IDC_CALLED_AE, pConnection->szCalledAE, sizeof(pConnection->szCalledAE)); GetDlgItemText(hDlg, IDC_CALLING_AE, pConnection->szCallingAE, sizeof(pConnection->szCallingAE)); GetDlgItemText(hDlg, IDC_CLIENT_IP, pConnection->szClientIP, sizeof(pConnection->szClientIP)); GetDlgItemText(hDlg, IDC_CLIENT_PORT, szPort, sizeof(szPort)); pConnection->uClientPort = atoi(szPort); EndDialog(hDlg, IDOK); return TRUE; break; } } return FALSE; } //Dialog box that // 1. define connections // 2. modify connections // 3. connect to a server // // Mesage handler for Connections dialog box. LRESULT CALLBACK DlgConnections(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hListView; L_BOOL bHasItems; static L_BOOL bDirty; L_INT iItemCount; L_INT iIndex; L_INT nRet; HWND hWndTmp; hListView= GetDlgItem(hDlg,IDC_CONNECTIONS); if (hListView != NULL) { iItemCount = ListView_GetItemCount(hListView); bHasItems = iItemCount > 0; /* if (bHasItems) ListView_SetSelectionMark(hListView, 1); */ //Enable/disable buttons hWndTmp = GetDlgItem(hDlg,IDC_CONNECT); if (hWndTmp != NULL) EnableWindow(hWndTmp,bHasItems); hWndTmp = GetDlgItem(hDlg,IDC_DELETE); if (hWndTmp != NULL) EnableWindow(hWndTmp,bHasItems); hWndTmp = GetDlgItem(hDlg,IDC_MODIFY); if (hWndTmp != NULL) EnableWindow(hWndTmp,bHasItems); hWndTmp = GetDlgItem(hDlg,IDC_SAVE); if (hWndTmp != NULL) EnableWindow(hWndTmp,bDirty); } switch (message) { case WM_INITDIALOG: InitConnections(); ListViewInit(hDlg); bDirty = FALSE; return TRUE; case WM_NOTIFY: { NMHDR *pnmh; pnmh = (LPNMHDR)lParam; switch (pnmh->code) { case NM_DBLCLK: iIndex = ListView_GetSelectionMark(hListView); iIndex = (iIndex == -1)?0:iIndex; iIndexConnectionGlobal = iIndex; //So client can access this information on C-MOVE-RQ ConnectToServer(&connections.connection[iIndex]); SaveConnections(hDlg); EndDialog(hDlg, LOWORD(wParam)); return TRUE; break; } } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CONNECT: iIndex = ListView_GetSelectionMark(hListView); iIndex = (iIndex == -1)?0:iIndex; iIndexConnectionGlobal = iIndex; //So client can access this information on C-MOVE-RQ ConnectToServer(&connections.connection[iIndex]); SaveConnections(hDlg); EndDialog(hDlg, LOWORD(wParam)); break; case IDC_SECURITY: { } case IDC_INSERT: { L_INT nRet; CONNECTION connection; memset( &connection, 0, sizeof(CONNECTION) ); nRet = DialogBoxParam( hInst, // handle to application instance (LPCTSTR)IDD_CLTCONN1_DIALOG, // identifies dialog box template hDlg, // handle to owner window (DLGPROC)DlgConnectionProperties, // pointer to dialog box procedure (LPARAM)(&connection) // pointer to initialization data ); if (nRet == IDOK) { AddConnection(hListView, &connection); bDirty = TRUE; } } break; case IDC_DELETE: { L_INT i; iIndex = ListView_GetSelectionMark(hListView); iIndex = (iIndex == -1)?0:iIndex; if (iIndex < connections.nCount) { //delete the item at position iIndex for (i = iIndex; inType == UID_TYPE_CLASS) || (pUID->nType == UID_TYPE_META_CLASS)) { TV_INSERTSTRUCT tv; tv.hInsertAfter= TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tv.item.lParam = (LPARAM)nIDtemp; //add items to tree view tv.hParent = TVI_ROOT; tv.item.pszText = pUID->pszName; TreeView_InsertItem(hTreeView, &tv); L_DicomAddPresentation(hAssociateAll, nIDtemp, 0, pUID->pszCode); nIDtemp += 2; } pUID = L_DicomGetNextUID(pUID); } for (i = 0; i < L_DicomGetPresentationCount(hAssociateAll); i++) { nIDtemp = L_DicomGetPresentation(hAssociateAll, i); lpszAbstractSyntax = L_DicomGetAbstract(hAssociateAll, nIDtemp); nID = L_DicomFindAbstract(hAssociateRequest, lpszAbstractSyntax); //if abstract not found in hAssociateRequest, add default transfer syntaxes so that if user //checks this item, the abstract syntax will not be rejected by the server if (nID == 0) { pUID = L_DicomGetFirstUID(); while (pUID != NULL) { if (pUID->nType == UID_TYPE_TRANSFER1) { L_DicomAddTransfer(hAssociateAll, nIDtemp, pUID->pszCode); } pUID = L_DicomGetNextUID(pUID); } } //abstract found in hAssociateRequest //add transfer syntaxes for the abstract syntax found in hAssociateRequest else { for (j = 0; j < L_DicomGetTransferCount(hAssociateRequest, nID); j++) { L_CHAR *lpszTransferSyntax; lpszTransferSyntax = L_DicomGetTransfer(hAssociateRequest, nID, j); L_DicomAddTransfer(hAssociateAll, nIDtemp, lpszTransferSyntax); } L_DicomSetRoleSelect( hAssociateAll, nIDtemp, L_DicomIsRoleSelect(hAssociateRequest, nID), L_DicomGetUserRole(hAssociateRequest, nID), L_DicomGetProviderRole(hAssociateRequest, nID) ); L_DicomSetExtended( hAssociateAll, nIDtemp, L_DicomGetExtended(hAssociateRequest,nID), L_DicomGetLengthExtended(hAssociateRequest,nID)); } } SetDlgItemInt( hDlg, IDC_VERSION, L_DicomGetVersion(hAssociateRequest), FALSE //FALSE == unsigned ); SetDlgItemText( hDlg, IDC_APPLICATION, L_DicomGetApplication(hAssociateRequest) ); for (i = 0; i pszName); //User Role--build the combo box hComboBoxUser = GetDlgItem(hDlg,IDC_USER); nIndex = ComboBox_AddString(hComboBoxUser, "Non Support"); ComboBox_SetItemData(hComboBoxUser, nIndex, PDU_ROLE_NON_SUPPORT); nIndex = ComboBox_AddString(hComboBoxUser, "Support"); ComboBox_SetItemData(hComboBoxUser, nIndex, PDU_ROLE_SUPPORT); //User Role--select the combo box item that corresponds to hAssociateRequest for (i = 0; i < (L_INT)ComboBox_GetCount(hComboBoxUser); i++) { //Get lParam each combo box item--this is PDU_ROLE_SUPPORT or PDU_ROLE_NON_SUPPORT L_INT iRoleSupport; iRoleSupport = ComboBox_GetItemData(hComboBoxUser, i); if (iRoleSupport == L_DicomGetUserRole(hAssociateUse, nID)) { ComboBox_SetCurSel(hComboBoxUser, i); } } //Provider Role--build the combo box hComboBoxProvider = GetDlgItem(hDlg, IDC_PROVIDER); nIndex = ComboBox_AddString(hComboBoxProvider, "Non Support"); ComboBox_SetItemData(hComboBoxProvider, nIndex, PDU_ROLE_NON_SUPPORT); nIndex = ComboBox_AddString(hComboBoxProvider, "Support"); ComboBox_SetItemData(hComboBoxProvider, nIndex, PDU_ROLE_SUPPORT); //Provider Role--select the combo box item that corresponds to hAssociateRequest for (i = 0; i < (L_INT)ComboBox_GetCount(hComboBoxProvider); i++) { //Get lParam each combo box item--this is PDU_ROLE_SUPPORT or PDU_ROLE_NON_SUPPORT L_INT iRoleSupport; iRoleSupport = ComboBox_GetItemData(hComboBoxProvider, i); if (iRoleSupport == L_DicomGetProviderRole(hAssociateUse, nID)) { ComboBox_SetCurSel(hComboBoxProvider, i); } } //Enabled check box--check if RoleSelect is TRUE bRole = L_DicomIsRoleSelect(hAssociateUse, nID); Button_SetCheck(GetDlgItem(hDlg,IDC_B_ROLE), bRole); //Extended Data--(6 edit boxes) pExtendedData = L_DicomGetExtended(hAssociateUse, nID); uExtendedCount = L_DicomGetLengthExtended(hAssociateUse, nID); switch (uExtendedCount) {//break only on last case! case 6: SetDlgItemInt(hDlg, IDC_EXTENDED5, pExtendedData[5], FALSE); case 5: SetDlgItemInt(hDlg, IDC_EXTENDED4, pExtendedData[4], FALSE); case 4: SetDlgItemInt(hDlg, IDC_EXTENDED3, pExtendedData[3], FALSE); case 3: SetDlgItemInt(hDlg, IDC_EXTENDED2, pExtendedData[2], FALSE); case 2: SetDlgItemInt(hDlg, IDC_EXTENDED1, pExtendedData[1], FALSE); case 1: SetDlgItemInt(hDlg, IDC_EXTENDED0, pExtendedData[0], FALSE); break; } //Transfer Syntax--add all possible items (with check boxes) to TreeView nImageSize = 16; hImage = ImageList_Create( nImageSize, nImageSize, ILC_COLOR, 0, //numIcons 0 //cGrow ); hTreeTransferSyntax = GetDlgItem(hDlg, IDC_TRANSFER); if (hTreeTransferSyntax) { TreeView_SetImageList(hTreeTransferSyntax, hImage, TVSIL_NORMAL); } TreeView_DeleteAllItems(hTreeTransferSyntax); pUID = L_DicomGetFirstUID(); while (pUID != NULL) { TV_INSERTSTRUCT tv; tv.hInsertAfter= TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tv.hParent = TVI_ROOT; if ((pUID->nType == UID_TYPE_TRANSFER1) || (pUID->nType == UID_TYPE_TRANSFER2)) { //add items to tree view tv.item.lParam = (LPARAM)pUID; tv.item.pszText = pUID->pszName; hItem = TreeView_InsertItem(hTreeTransferSyntax, &tv); } pUID = L_DicomGetNextUID(pUID); } //Transfer Syntax--check the boxes if in hAssociateRequest, uncheck if not in hAssociateRequest for (i = 0; i < L_DicomGetTransferCount(hAssociateUse, nID); i++) { L_CHAR *lpszTransfer; lpszTransfer = L_DicomGetTransfer(hAssociateUse, nID, i); hItem = TreeView_GetFirstVisible(hTreeTransferSyntax); if (hItem != NULL) { while (TreeView_GetPrevSibling(hTreeTransferSyntax, hItem) != NULL) { hItem = TreeView_GetPrevSibling(hTreeTransferSyntax, hItem); } while (hItem != NULL) { //Get lParam of hItem--this is the presentation ID (1,3,5, ...) pUID = (pDICOMUID) TV_GetItemData(hTreeTransferSyntax, hItem); if (pUID == L_DicomFindUID(lpszTransfer)) { TV_SetCheckState(hTreeTransferSyntax, hItem, TRUE); break; } hItem = TreeView_GetNextSibling(hTreeTransferSyntax, hItem); } } } TreeView_Select(hTreeTransferSyntax, TreeView_GetFirstVisible(hTreeTransferSyntax),TVGN_FIRSTVISIBLE ); } L_VOID DlgPresentationContextOK(HWND hDlg, L_UCHAR nID) { HTREEITEM hItem; L_UCHAR ExtendedData[6]; L_UINT32 uExtendedCount; L_UCHAR uUserRole, uProviderRole; HWND hComboBoxUser, hComboBoxProvider; L_BOOL bRole; L_INT iIndex; L_BOOL bTranslated; HWND hTreeTransferSyntax; //Enabled check box bRole = Button_GetCheck(GetDlgItem(hDlg,IDC_B_ROLE)); //User Role Combo Box hComboBoxUser = GetDlgItem(hDlg,IDC_USER); iIndex = ComboBox_GetCurSel(hComboBoxUser); uUserRole = (L_UCHAR)ComboBox_GetItemData(hComboBoxUser, iIndex); //Provider Role Combo Box hComboBoxProvider = GetDlgItem(hDlg,IDC_PROVIDER); iIndex = ComboBox_GetCurSel(hComboBoxProvider); uProviderRole = (L_UCHAR)ComboBox_GetItemData(hComboBoxProvider, iIndex); L_DicomSetRoleSelect( hAssociateRequest, nID, bRole, uUserRole, uProviderRole ); L_DicomSetRoleSelect( hAssociateAll, nID, bRole, uUserRole, uProviderRole ); //Extended edit boxes uExtendedCount=0; ExtendedData[0] = GetDlgItemInt( hDlg, IDC_EXTENDED0, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 1; ExtendedData[1] = GetDlgItemInt( hDlg, IDC_EXTENDED1, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 2; ExtendedData[2] = GetDlgItemInt( hDlg, IDC_EXTENDED2, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 3; ExtendedData[3] = GetDlgItemInt( hDlg, IDC_EXTENDED3, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 4; ExtendedData[4] = GetDlgItemInt( hDlg, IDC_EXTENDED4, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 5; ExtendedData[5] = GetDlgItemInt( hDlg, IDC_EXTENDED5, &bTranslated, FALSE); if (bTranslated) uExtendedCount = 6; L_DicomSetExtended(hAssociateRequest, nID, ExtendedData, uExtendedCount); L_DicomSetExtended(hAssociateAll, nID, ExtendedData, uExtendedCount); //Delete all transfer syntaxes from hAssociateRequest while (L_DicomGetTransferCount(hAssociateRequest, nID) != 0) { L_DicomDelTransfer(hAssociateRequest, nID, 0); } //Add transfer syntaxes that are checked hTreeTransferSyntax = GetDlgItem(hDlg, IDC_TRANSFER); hItem = TreeView_GetFirstVisible(hTreeTransferSyntax); if (hItem == NULL) { return; } while (TreeView_GetPrevSibling(hTreeTransferSyntax, hItem) != NULL) { hItem = TreeView_GetPrevSibling(hTreeTransferSyntax, hItem); } while (hItem != NULL) { L_BOOL bChecked; bChecked = TV_GetCheckState(hTreeTransferSyntax, hItem); if (bChecked) { pDICOMUID pUID; //Get lParam of hItem--this is pUID) pUID = (pDICOMUID) TV_GetItemData(hTreeTransferSyntax, hItem); L_DicomAddTransfer(hAssociateRequest, nID, pUID->pszCode); } hItem = TreeView_GetNextSibling(hTreeTransferSyntax, hItem); } } LRESULT CALLBACK DlgPresentationContext(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static L_UCHAR nID=0; HWND hTreeView; hTreeView = GetDlgItem(hDlg, IDC_TRANSFER); switch (message) { case WM_INITDIALOG: nID = (L_UCHAR)lParam; DlgPresentationContextInit(hDlg, nID); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_SELECT_ALL: DlgTreeSelectAll(hTreeView, TRUE); return TRUE; case IDC_DESELECT_ALL: DlgTreeSelectAll(hTreeView, FALSE); break; case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: DlgPresentationContextOK(hDlg, nID); EndDialog(hDlg, LOWORD(wParam)); return TRUE; } } return FALSE; } L_VOID DlgAssociationModify(HWND hDlg) { HTREEITEM hItem; HWND hTreeAbstract; L_UCHAR nID; hTreeAbstract = GetDlgItem(hDlg, IDC_ABSTRACT); hItem = TreeView_GetSelection(hTreeAbstract); //Get lParam of hItem--this is the presentation ID (1,3,5, ...) nID = (L_UCHAR) TV_GetItemData(hTreeAbstract, hItem); DialogBoxParam( hInst, (LPCTSTR)IDD_PRESENTATION_CONTEXT_DIALOG, hDlg, (DLGPROC)DlgPresentationContext, (LPARAM)nID ); } LRESULT CALLBACK DlgAssociation(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hTreeView; hTreeView = GetDlgItem(hDlg, IDC_ABSTRACT); switch (message) { case WM_INITDIALOG: DlgAssociationInitDialog(hDlg); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_SELECT_ALL: DlgTreeSelectAll(hTreeView, TRUE); SetFocus(hTreeView); break; case IDC_DESELECT_ALL: DlgTreeSelectAll(hTreeView, FALSE); SetFocus(hTreeView); break; case IDC_DEFAULT: DlgAssociationDefault(hDlg); SetFocus(hTreeView); break; case IDC_MODIFY: DlgAssociationModify(hDlg); SetFocus(hTreeView); break; case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: DlgAssociationOK(hDlg); EndDialog(hDlg, LOWORD(wParam)); return TRUE; } } return FALSE; } LRESULT CALLBACK DlgOptions(HWND hDlg, UINT uiMessage, WPARAM wParam, LPARAM lParam) { int iLength, i; switch (uiMessage) { case WM_INITDIALOG: SetDlgItemText(hDlg, IDC_EDIT_STOREFOLDER, szStoreFolder); SetDlgItemText(hDlg, IDC_EDIT_EXTENSION, szExtension); SetDlgItemText(hDlg, IDC_EDIT_TEMPFOLDER, szTempFilesFolder); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, 0); return TRUE; case IDOK: GetDlgItemText(hDlg, IDC_EDIT_STOREFOLDER, szStoreFolder, sizeof(szStoreFolder) - 1); Trim(szStoreFolder); iLength = lstrlen(szStoreFolder); if (iLength) { if (szStoreFolder[iLength - 1] != '\\' && szStoreFolder[iLength - 1] != '/') lstrcat(szStoreFolder, "\\"); } GetDlgItemText(hDlg, IDC_EDIT_EXTENSION, szExtension, sizeof(szExtension)); iLength = lstrlen(szExtension); for (i = 0; i < iLength; i++) if (szExtension[i] == '.') szExtension[i] = ' '; Trim(szExtension); iLength = lstrlen(szExtension); for (i = 0; i < iLength; i++) if (szExtension[i] == ' ') { szExtension[i] = '\0'; break; } GetDlgItemText(hDlg, IDC_EDIT_TEMPFOLDER, szTempFilesFolder, sizeof(szTempFilesFolder)); Trim(szTempFilesFolder); EndDialog(hDlg, 0); return TRUE; } break; } return FALSE; } L_VOID DlgUIDInitDialog(HWND hDlg) { HWND hTreeView; pDICOMUID pUID; hTreeView = GetDlgItem(hDlg, IDC_LIST); pUID = L_DicomGetFirstUID(); //Fill in UID list box while (pUID != NULL) { TV_INSERTSTRUCT tv; tv.hInsertAfter= TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tv.item.lParam = (LPARAM)pUID; //add items to tree view tv.hParent = TVI_ROOT; tv.item.pszText = pUID->pszCode; TreeView_InsertItem(hTreeView, &tv); pUID = L_DicomGetNextUID(pUID); } TreeView_SelectItem(hTreeView, TreeView_GetFirstVisible(hTreeView)); } L_VOID DlgUIDInsert(HWND hDlg) { HWND hTreeViewList; DICOMUID dicomUID; pDICOMUID pUID; HTREEITEM hItem; TV_INSERTSTRUCT tv; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); dicomUID.pszCode = NULL; // Code dicomUID.pszName = NULL; // Name //(-1) is invalid type //Indicates to dialog that this is an insert instead of a modify dicomUID.nType = (-1); if (DialogBoxParam(hInst, (LPCTSTR) IDD_UID_CHANGE_DIALOG, hDlg, (DLGPROC) DlgUIDChange, (LPARAM) &dicomUID) == IDOK) { pUID = L_DicomInsertUID(dicomUID.pszCode, dicomUID.pszName, dicomUID.nType); // Add the new item to the tree view if (pUID) { tv.hInsertAfter= TVI_LAST; tv.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM; tv.item.lParam = (LPARAM) pUID; tv.hParent = TVI_ROOT; tv.item.pszText = pUID->pszCode; hItem = TreeView_InsertItem(hTreeViewList, &tv); // Select the new item TreeView_SelectItem(hTreeViewList, hItem); } } } L_VOID DlgUIDDelete(HWND hDlg) { HWND hTreeViewList; pDICOMUID pUID; HTREEITEM hItem; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); hItem = TreeView_GetSelection(hTreeViewList); if (hItem == NULL) return; //Get lParam of hItem--this is pUID pUID = (pDICOMUID) TV_GetItemData(hTreeViewList, hItem); L_DicomDeleteUID(pUID); TreeView_DeleteItem(hTreeViewList,hItem); if (TreeView_GetCount(hTreeViewList) == 0) { SetDlgItemText(hDlg, IDC_TYPE, ""); SetDlgItemText(hDlg, IDC_CODE, ""); SetDlgItemText(hDlg, IDC_NAME, ""); } } L_VOID DlgUIDDeleteAll(HWND hDlg) { HWND hTreeViewList; pDICOMUID pUID; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); pUID = L_DicomGetFirstUID(); while (pUID != NULL) { L_DicomDeleteUID(pUID); pUID = L_DicomGetNextUID(pUID); } TreeView_DeleteAllItems(hTreeViewList); SetDlgItemText(hDlg, IDC_TYPE, ""); SetDlgItemText(hDlg, IDC_CODE, ""); SetDlgItemText(hDlg, IDC_NAME, ""); } L_VOID DlgUIDModify(HWND hDlg) { HWND hTreeViewList; HTREEITEM hItem; pDICOMUID pUID; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); hItem = TreeView_GetSelection(hTreeViewList); //Get lParam of hItem--this is pUID pUID = (pDICOMUID) TV_GetItemData(hTreeViewList, hItem); DialogBoxParam(hInst, (LPCTSTR)IDD_UID_CHANGE_DIALOG, hDlg, (DLGPROC)DlgUIDChange, (LPARAM)pUID); } L_VOID DlgUIDDefault(HWND hDlg) { L_DicomDefaultUID(); DlgUIDInitDialog(hDlg); } L_VOID OnDlgUIDSelChanged(HWND hDlg) { pDICOMUID pUID; HTREEITEM hItem; HWND hTreeViewList; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); hItem = TreeView_GetSelection(hTreeViewList); if (hItem == NULL) { return; } //Get lParam of hItem--this is the presentation ID (1,3,5, ...) pUID = (pDICOMUID) TV_GetItemData(hTreeViewList, hItem); SetDlgItemText(hDlg, IDC_CODE, pUID->pszCode); SetDlgItemText(hDlg, IDC_NAME, pUID->pszName); //Fill in "TYPE" edit box switch(pUID->nType) { case UID_TYPE_APPLICATION: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_APPLICATION); break; case UID_TYPE_TRANSFER1: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_TRANSFER1); break; case UID_TYPE_TRANSFER2: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_TRANSFER2); break; case UID_TYPE_CLASS: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_CLASS); break; case UID_TYPE_META_CLASS: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_META_CLASS); break; case UID_TYPE_INSTANCE: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_INSTANCE); break; case UID_TYPE_OTHER: SetDlgItemText(hDlg, IDC_TYPE, STRING_TYPE_OTHER); break; } } LRESULT CALLBACK DlgUID(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { LPNMHDR pnmh; HTREEITEM hItem; L_BOOL bHasItems; HWND hTreeViewList; hTreeViewList = GetDlgItem(hDlg, IDC_LIST); hItem = TreeView_GetSelection(hTreeViewList); bHasItems = (hItem!=0); //Disabled Delete, Modify buttons if nothing in tree view, or nothing selected EnableWindow(GetDlgItem(hDlg,IDC_DELETE), bHasItems); EnableWindow(GetDlgItem(hDlg,IDC_DELETEALL), bHasItems); EnableWindow(GetDlgItem(hDlg,IDC_MODIFY), bHasItems); switch (message) { case WM_INITDIALOG: DlgUIDInitDialog(hDlg); return TRUE; case WM_NOTIFY: pnmh = (LPNMHDR)lParam; if (pnmh->code == TVN_SELCHANGED) { OnDlgUIDSelChanged(hDlg); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_INSERT: DlgUIDInsert(hDlg); break; case IDC_DELETE: DlgUIDDelete(hDlg); break; case IDC_DELETEALL: DlgUIDDeleteAll(hDlg); break; case IDC_MODIFY: DlgUIDModify(hDlg); break; case IDC_DEFAULT: DlgUIDDefault(hDlg); break; case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: //DlgUIDOK(hDlg); EndDialog(hDlg, LOWORD(wParam)); return TRUE; } SetFocus(GetDlgItem(hDlg,IDC_LIST)); } return FALSE; } L_VOID DlgUIDChangeInitDialog(HWND hDlg, pDICOMUID pUID) { HWND hComboBoxType; HWND hEditCode; L_INT nIndex; L_INT nCurSel; L_INT idToIndex[10]; //if pUID->nType == (-1), this is an insert hEditCode = GetDlgItem(hDlg, IDC_CODE); if (pUID->nType == -1) { // Remove ES_READONLY style SendMessage(hEditCode,EM_SETREADONLY, (WPARAM)FALSE, 0); } else //Modify { //Add ES_READONLY style SendMessage(hEditCode,EM_SETREADONLY, (WPARAM)TRUE, 0); } //Fill in Code (Read-Only) SetDlgItemText(hDlg, IDC_CODE, pUID->pszCode); //File in Name SetDlgItemText(hDlg, IDC_NAME, pUID->pszName); //Fill in "TYPE" combo box hComboBoxType = GetDlgItem(hDlg, IDC_TYPE); nCurSel = 0; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_OTHER); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_OTHER); idToIndex[UID_TYPE_OTHER] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_TRANSFER1); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_TRANSFER1); idToIndex[UID_TYPE_TRANSFER1] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_TRANSFER2); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_TRANSFER2); idToIndex[UID_TYPE_TRANSFER2] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_CLASS); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_CLASS); idToIndex[UID_TYPE_CLASS] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_META_CLASS); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_META_CLASS); idToIndex[UID_TYPE_META_CLASS] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_INSTANCE); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_INSTANCE); idToIndex[UID_TYPE_INSTANCE] = nIndex; nIndex = ComboBox_AddString(hComboBoxType, STRING_TYPE_APPLICATION); ComboBox_SetItemData(hComboBoxType, nIndex, UID_TYPE_APPLICATION); idToIndex[UID_TYPE_APPLICATION] = nIndex; ComboBox_SetCurSel(hComboBoxType, idToIndex[pUID->nType]); } L_VOID DlgUIDChangeOK(HWND hDlg, pDICOMUID pUID) { L_CHAR szName[MAX_STRING_LEN]; static L_CHAR szCode[MAX_STRING_LEN]; //static so pUID can point to szCode L_INT nType; HWND hComboBoxType; //Code is unchanged on a modify GetDlgItemText(hDlg, IDC_CODE, szCode, sizeof(szCode)); pUID->pszCode = szCode; GetDlgItemText(hDlg, IDC_NAME, szName, sizeof(szName)); L_DicomSetNameUID(pUID, szName); hComboBoxType = GetDlgItem(hDlg, IDC_TYPE); nType = ComboBox_GetItemData(hComboBoxType, ComboBox_GetCurSel(hComboBoxType)); pUID->nType = nType; } LRESULT CALLBACK DlgUIDChange(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { pDICOMUID pUID ; pUID = (pDICOMUID)GetWindowLong(hDlg, GWL_USERDATA); switch (message) { case WM_INITDIALOG: SetWindowLong(hDlg, GWL_USERDATA, lParam); pUID = (pDICOMUID)lParam; DlgUIDChangeInitDialog(hDlg, pUID); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: DlgUIDChangeOK(hDlg, pUID); EndDialog(hDlg, LOWORD(wParam)); //Update parent dialog OnDlgUIDSelChanged( GetParent(hDlg)) ; return TRUE; } } return FALSE; } L_VOID ListViewInsertString(HWND hListView, L_CHAR *szString, L_INT iItem, L_INT iSubItem) { LV_ITEM lvItem; lvItem.mask = LVIF_TEXT; lvItem.pszText = szString; lvItem.iItem = iItem; lvItem.iSubItem = iSubItem; if (iSubItem == 0) ListView_InsertItem(hListView, &lvItem); else ListView_SetItem(hListView, &lvItem); } L_VOID ListViewAddPresentation(HWND hListView, L_INT i, HDICOMPDU hAssociateRequest) { L_CHAR szTemp[MAX_STRING_LEN]; L_UCHAR nID; L_UCHAR uResult; L_CHAR *szAbstract; L_CHAR *szResult; L_CHAR *szTransferSyntax; L_UCHAR *szExtended; pDICOMUID pUID; L_INT j; //ID nID = L_DicomGetPresentation(hAssociateRequest, i); wsprintf(szTemp, "%d", nID); ListViewInsertString(hListView, szTemp, i, 0); //Abstract szAbstract = L_DicomGetAbstract(hAssociateRequest, nID); if (szAbstract != NULL) { pUID = L_DicomFindUID(szAbstract); if (pUID != NULL) ListViewInsertString(hListView, pUID->pszName, i, 1); else ListViewInsertString(hListView, szAbstract, i, 1); } else ListViewInsertString(hListView, "***Unknown", i, 1); //Result uResult = L_DicomGetResult(hAssociateRequest, nID); switch (uResult) { case PDU_ACCEPT_RESULT_SUCCESS: szResult = "Accept"; break; case PDU_ACCEPT_RESULT_USER_REJECT: szResult = "Reject(User)"; break; case PDU_ACCEPT_RESULT_PROVIDER_REJECT: szResult = "Reject(Provider)"; break; case PDU_ACCEPT_RESULT_ABSTRACT_SYNTAX: szResult = "No Support(Abstract Syntax)"; break; case PDU_ACCEPT_RESULT_TRANSFER_SYNTAX: szResult = "No Support(TransferSyntax)"; break; } ListViewInsertString(hListView, szResult, i, 2); //Transfer Syntax if (uResult == PDU_ACCEPT_RESULT_SUCCESS) { szTransferSyntax = L_DicomGetTransfer(hAssociateRequest, nID, 0); if (szTransferSyntax != NULL) { //Returns unique accepted transfer syntax (last argument 0) pUID = L_DicomFindUID(szTransferSyntax); if (pUID != NULL) ListViewInsertString(hListView, pUID->pszName, i, 3); else ListViewInsertString(hListView, szTransferSyntax, i, 3); } if (L_DicomIsRoleSelect(hAssociateRequest, nID)) { switch (L_DicomGetUserRole(hAssociateRequest, nID)) { case PDU_ROLE_NON_SUPPORT: ListViewInsertString(hListView, "Non Support", i, 4); break; case PDU_ROLE_SUPPORT: ListViewInsertString(hListView, "Support", i, 4); break; default: ListViewInsertString(hListView, "Unknown", i, 4); break; } switch (L_DicomGetProviderRole(hAssociateRequest, nID)) { case PDU_ROLE_NON_SUPPORT: ListViewInsertString(hListView, "Non Support", i, 5); break; case PDU_ROLE_SUPPORT: ListViewInsertString(hListView, "Support", i, 5); break; default: ListViewInsertString(hListView, "Unknown", i, 5); break; } } if (L_DicomGetLengthExtended(hAssociateRequest, nID) != 0) { szExtended = L_DicomGetExtended(hAssociateRequest, nID); if (szExtended != NULL) { L_CHAR szExtendedAll[MAX_STRING_LEN]; L_CHAR szTemp[MAX_STRING_LEN]; strcpy(szExtendedAll, ""); for (j = 0; j < (INT)L_DicomGetLengthExtended(hAssociateRequest, nID); j++) { wsprintf(szTemp, "%X ", szExtendedAll[j]); lstrcat(szExtendedAll, szTemp); } ListViewInsertString(hListView, szExtendedAll, i, 6); } } } } L_VOID DlgSessionInfoInitDialog(HWND hDlg) { L_INT i; L_BOOL bRet; HWND hListPresentation; LV_COLUMN lvCol; SetDlgItemText(hDlg, IDC_CALLED, L_DicomGetCalled(hAssociateRequest)); SetDlgItemText(hDlg, IDC_CALLING, L_DicomGetCalling(hAssociateRequest)); SetDlgItemText(hDlg, IDC_CALLING, L_DicomGetCalling(hAssociateRequest)); SetDlgItemInt(hDlg, IDC_VERSION, L_DicomGetVersion(hAssociateRequest), FALSE); SetDlgItemText(hDlg, IDC_APPLICATION, L_DicomGetApplication(hAssociateRequest)); bRet = L_DicomIsMaxLength(hAssociateRequest); Button_SetCheck(GetDlgItem(hDlg,IDC_B_MAX_LENGTH), bRet); if (bRet) SetDlgItemInt(hDlg, IDC_MAX_LENGTH, L_DicomGetMaxLength(hAssociateRequest), FALSE); bRet = L_DicomIsImplementClass(hAssociateRequest); Button_SetCheck(GetDlgItem(hDlg,IDC_B_IMPLEMENT_CLASS), bRet); if (bRet) SetDlgItemText(hDlg, IDC_IMPLEMENT_CLASS, L_DicomGetImplementClass(hAssociateRequest)); bRet = L_DicomIsImplementVersion(hAssociateRequest); Button_SetCheck(GetDlgItem(hDlg,IDC_B_IMPLEMENT_VERSION), bRet); if (bRet) SetDlgItemText(hDlg, IDC_IMPLEMENT_VERSION, L_DicomGetImplementVersion(hAssociateRequest)); bRet = L_DicomIsAsyncOperations(hAssociateRequest); Button_SetCheck(GetDlgItem(hDlg,IDC_B_ASYNC_OPERATIONS), bRet); if (bRet) { SetDlgItemInt(hDlg, IDC_INVOKED, L_DicomGetInvokedOperations(hAssociateRequest), FALSE); SetDlgItemInt(hDlg, IDC_PERFORMED, L_DicomGetPerformedOperations(hAssociateRequest), FALSE); } hListPresentation = GetDlgItem(hDlg, IDC_PRESENTATION); lvCol.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvCol.fmt = LVCFMT_LEFT; lvCol.iSubItem = 0; lvCol.pszText = "ID"; lvCol.cx = 30; ListView_InsertColumn(hListPresentation, 0, &lvCol); lvCol.pszText = "Abstract"; lvCol.cx = 310; ListView_InsertColumn(hListPresentation, 1, &lvCol); lvCol.pszText = "Result"; lvCol.cx = 80; ListView_InsertColumn(hListPresentation, 2, &lvCol); lvCol.pszText = "Transfer"; lvCol.cx = 150; ListView_InsertColumn(hListPresentation, 3, &lvCol); lvCol.pszText = "User"; lvCol.cx = 40; ListView_InsertColumn(hListPresentation, 4, &lvCol); lvCol.pszText = "Provider"; lvCol.cx = 60; ListView_InsertColumn(hListPresentation, 5, &lvCol); lvCol.pszText = "Extended"; lvCol.cx = 70; ListView_InsertColumn(hListPresentation, 6, &lvCol); for (i = 0; i < L_DicomGetPresentationCount(hAssociateAccept); i++) { ListViewAddPresentation(hListPresentation, i, hAssociateAccept); } } LRESULT CALLBACK DlgSessionInfo(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: DlgSessionInfoInitDialog(hDlg); return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: EndDialog(hDlg, LOWORD(wParam)); return TRUE; } } return FALSE; } LRESULT CALLBACK DlgFindPatientRoot(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { pPATIENT pPatient; pPatient = (pPATIENT)GetWindowLong(hDlg, GWL_USERDATA); switch (message) { case WM_INITDIALOG: SetWindowLong(hDlg, GWL_USERDATA, lParam); pPatient = (pPATIENT)lParam; switch (pPatient->uQueryType) { case QUERY_PATIENT_ROOT: SetWindowText(hDlg, "Find Patient Root"); break; case QUERY_PATIENT_STUDY_ONLY: SetWindowText(hDlg, "Find Patient/Study Only"); break; } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: GetDlgItemText(hDlg, IDC_PATIENT_NAME, pPatient->szPatientName, sizeof(pPatient->szPatientName)); GetDlgItemText(hDlg, IDC_PATIENT_ID, pPatient->szPatientID, sizeof(pPatient->szPatientID)); EndDialog(hDlg, LOWORD(wParam)); return TRUE; } } return FALSE; } LRESULT CALLBACK DlgFindStudyRoot(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { pSTUDY pStudy; pStudy = (pSTUDY)GetWindowLong(hDlg, GWL_USERDATA); switch (message) { case WM_INITDIALOG: SetWindowLong(hDlg, GWL_USERDATA, lParam); pStudy = (pSTUDY)lParam; return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, LOWORD(wParam)); return TRUE; case IDOK: GetDlgItemText(hDlg, IDC_STUDY_INSTANCE_UID, pStudy->szStudyInstanceUID, sizeof(pStudy->szStudyInstanceUID)); GetDlgItemText(hDlg, IDC_STUDY_ID, pStudy->szStudyID, sizeof(pStudy->szStudyID)); GetDlgItemText(hDlg, IDC_ACCESSION_NUMBER, pStudy->szAccessionNumber, sizeof(pStudy->szAccessionNumber)); GetDlgItemText(hDlg, IDC_PATIENT_NAME, pStudy->szPatientName, sizeof(pStudy->szPatientName)); GetDlgItemText(hDlg, IDC_PATIENT_ID, pStudy->szPatientID, sizeof(pStudy->szPatientID)); EndDialog(hDlg, LOWORD(wParam)); return TRUE; } } return FALSE; } L_VOID InitSecurity(HWND hWnd) { PROPSHEETPAGE psp[4]; PROPSHEETHEADER psh; L_INT hSheet; if (LoadFromFileSettings() == FALSE) { LoadDefaultSettings(); } psp[0].dwSize = sizeof(PROPSHEETPAGE); psp[0].dwFlags = PSP_USETITLE; psp[0].hInstance = hInst; psp[0].pszTemplate = MAKEINTRESOURCE(IDD_SEC_INFO); psp[0].pszIcon = NULL; psp[0].pfnDlgProc = DlgISCLInfo; psp[0].pszTitle ="Security Info"; psp[0].lParam = 0; psp[0].pfnCallback = NULL; psp[1].dwSize = sizeof(PROPSHEETPAGE); psp[1].dwFlags = PSP_USETITLE; psp[1].hInstance = hInst; psp[1].pszTemplate = MAKEINTRESOURCE(IDD_SEC_AUTH); psp[1].pszIcon = NULL; psp[1].pfnDlgProc = DlgISCLAuth; psp[1].pszTitle = "ISCL Authenticate"; psp[1].lParam = 0; psp[1].pfnCallback = NULL; psp[2].dwSize = sizeof(PROPSHEETPAGE); psp[2].dwFlags = PSP_USETITLE; psp[2].hInstance = hInst; psp[2].pszTemplate = MAKEINTRESOURCE(IDD_SEC_ENC); psp[2].pszIcon = NULL; psp[2].pfnDlgProc = DlgISCLEncr; psp[2].pszTitle = "ISCL Encryption"; psp[2].lParam = 0; psp[2].pfnCallback = NULL; psp[3].dwSize = sizeof(PROPSHEETPAGE); psp[3].dwFlags = PSP_USETITLE; psp[3].hInstance = hInst; psp[3].pszTemplate = MAKEINTRESOURCE(IDD_SEC_TLS); psp[3].pszIcon = NULL; psp[3].pfnDlgProc = DlgTLSInit; psp[3].pszTitle = "TLS Settings"; psp[3].lParam = 0; psp[3].pfnCallback = NULL; psh.dwSize = sizeof(PROPSHEETHEADER); psh.dwFlags = PSH_PROPSHEETPAGE; psh.hwndParent = hWnd; psh.hInstance = hInst; psh.pszIcon = NULL; psh.pszCaption = (LPSTR) "Security Settings"; psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE); psh.nStartPage = 0; psh.ppsp = (LPCPROPSHEETPAGE) &psp; psh.pfnCallback = NULL; hSheet = PropertySheet(&psh); } LRESULT CALLBACK DlgISCLInfo (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_SETACTIVE: { break; } case PSN_APPLY: { SaveToFileSettings(); return TRUE; break; } case PSN_QUERYCANCEL: { if (LoadFromFileSettings() == FALSE) { LoadDefaultSettings(); } break; } } } return FALSE; } LRESULT CALLBACK DlgISCLAuth (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hItem; LV_ITEM item; L_INT i, nRet, nCount; L_CHAR szBuffer[100]; HWND hListView; switch (message) { case WM_INITDIALOG: { LV_COLUMN col; hListView = GetDlgItem(hDlg,IDC_AUTH_KEYS); //L_INT i; col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; col.fmt = LVCFMT_LEFT; col.cx = 50; col.pszText = "Index"; col.iSubItem = 0; ListView_InsertColumn(hListView, 0, &col); col.pszText = "Value"; col.cx = 130; ListView_InsertColumn(hListView, 1, &col); for (i = 0; i < 8; i++) { _itoa(i, szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 0); _i64toa(uISCLAuthKeys[i], szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 1); } ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); item.iItem = uISCLAuthCurrentKey; item.iSubItem = 0; item.mask = LVIF_STATE; item.state = LVIS_FOCUSED | LVIS_SELECTED; item.stateMask = LVIS_FOCUSED | LVIS_SELECTED; ListView_SetItem(hListView, &item); hItem = GetDlgItem(hDlg, IDC_AUTH_ALG); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"MUTUAL_AUTH_3P4W"); SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"MUTUAL_AUTH_3P4W"); break; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_AUTH_EDIT: { hListView = GetDlgItem(hDlg, IDC_AUTH_KEYS); uISCLAuthCurrentKey = ListView_GetSelectionMark(hListView); ListView_GetItemText(hListView, uISCLAuthCurrentKey, 1, szBuffer, sizeof(szBuffer)); uISCLAuthKeys[uISCLAuthCurrentKey] = _atoi64(szBuffer); uKey = uISCLAuthKeys[uISCLAuthCurrentKey]; nRet = DialogBoxParam(hInst, (LPCTSTR)IDD_EDITKEY, hDlg, (DLGPROC)DlgEditKey, 0); if (nRet == IDOK) { uISCLAuthKeys[uISCLAuthCurrentKey] = uKey; _i64toa(uKey, szBuffer, 10); ListViewInsertString(hListView, szBuffer, uISCLAuthCurrentKey, 1); } return TRUE; } break; case IDC_AUTH_ADD: { hListView = GetDlgItem(hDlg, IDC_AUTH_KEYS); nCount = ListView_GetItemCount(hListView); if (nCount < 8) { nRet = DialogBoxParam(hInst, (LPCTSTR)IDD_ADDKEY, hDlg, (DLGPROC)DlgAddKey, 0); if (nRet == IDOK) { uISCLAuthKeys[nCount] = uKey; _i64toa(nCount, szBuffer, 10); ListViewInsertString(hListView, szBuffer, nCount, 0); _i64toa(uKey, szBuffer, 10); ListViewInsertString(hListView, szBuffer, nCount, 1); } } return TRUE; } break; case IDC_AUTH_GEN: { hListView = GetDlgItem(hDlg, IDC_AUTH_KEYS); ListView_DeleteAllItems(hListView); for (i = 0; i < 8; i++) { uISCLAuthKeys[i] = GetRandom(); _i64toa(i, szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 0); _i64toa(uISCLAuthKeys[i], szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 1); } return TRUE; } break; } break; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_SETACTIVE: { break; } case PSN_KILLACTIVE: { hListView = GetDlgItem(hDlg,IDC_AUTH_KEYS); for (i = 0; i < 8; i++) { _itoa(i, szBuffer, 10); ListView_GetItemText(hListView, i, 1, szBuffer, sizeof(szBuffer)); uISCLAuthKeys[i] = _atoi64(szBuffer); } uISCLAuthCurrentKey = ListView_GetSelectionMark(hListView); break; } case PSN_APPLY: { SaveToFileSettings(); return TRUE; break; } case PSN_QUERYCANCEL: { if (LoadFromFileSettings() == FALSE) { LoadDefaultSettings(); } break; } } break; } return FALSE; } LRESULT CALLBACK DlgISCLEncr (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hItem; LV_ITEM item; L_INT i, nRet, nCount; L_CHAR szBuffer[100]; HWND hListView; switch (message) { case WM_INITDIALOG: { LV_COLUMN col; hListView = GetDlgItem(hDlg,IDC_ENC_KEYS); //L_INT i; col.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; col.fmt = LVCFMT_LEFT; col.cx = 50; col.pszText = "Index"; col.iSubItem = 0; ListView_InsertColumn(hListView, 0, &col); col.pszText = "Value"; col.cx = 130; ListView_InsertColumn(hListView, 1, &col); for (i = 0; i < 8; i++) { _itoa(i, szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 0); _i64toa(uISCLEncKeys[i], szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 1); } ListView_SetExtendedListViewStyle(hListView, LVS_EX_FULLROWSELECT); item.iItem = uISCLEncCurrentKey; item.iSubItem = 0; item.mask = LVIF_STATE; item.state = LVIS_FOCUSED | LVIS_SELECTED; item.stateMask = LVIS_FOCUSED | LVIS_SELECTED; ListView_SetItem(hListView, &item); hItem = GetDlgItem(hDlg, IDC_ENC_ALG); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"ISCL_ENCRYPT_NONE"); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"ISCL_ENCRYPT_DESCBC"); switch (uISCLEncAlg) { case DICOM_ISCL_ENCRYPT_NONE: SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"ISCL_ENCRYPT_NONE"); break; case DICOM_ISCL_ENCRYPT_DESCBC: SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"ISCL_ENCRYPT_DESCBC"); break; } hItem = GetDlgItem(hDlg, IDC_ENC_SIGN); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"ISCL_MAC_NONE"); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"ISCL_MAC_MD5"); SendMessage(hItem, CB_ADDSTRING, 0, (LPARAM)"ISCL_MAC_DESMAC"); switch (uISCLEncSign) { case DICOM_ISCL_MAC_NONE: SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"ISCL_MAC_NONE"); break; case DICOM_ISCL_MAC_MD5: SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"ISCL_MAC_MD5"); break; case DICOM_ISCL_MAC_DESMAC: SendMessage(hItem, CB_SELECTSTRING, 0, (LPARAM)"ISCL_MAC_DESMAC"); break; } break; } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_ENC_EDIT: { hListView = GetDlgItem(hDlg, IDC_ENC_KEYS); uISCLEncCurrentKey = ListView_GetSelectionMark(hListView); ListView_GetItemText(hListView, uISCLEncCurrentKey, 1, szBuffer, sizeof(szBuffer)); uISCLEncKeys[uISCLEncCurrentKey] = _atoi64(szBuffer); uKey = uISCLEncKeys[uISCLEncCurrentKey]; nRet = DialogBoxParam(hInst, (LPCTSTR)IDD_EDITKEY, hDlg, (DLGPROC)DlgEditKey, 0); if (nRet == IDOK) { uISCLEncKeys[uISCLEncCurrentKey] = uKey; _i64toa(uKey, szBuffer, 10); ListViewInsertString(hListView, szBuffer, uISCLEncCurrentKey, 1); } return TRUE; } break; case IDC_ENC_ADD: { hListView = GetDlgItem(hDlg, IDC_ENC_KEYS); nCount = ListView_GetItemCount(hListView); if (nCount < 8) { nRet = DialogBoxParam(hInst, (LPCTSTR)IDD_ADDKEY, hDlg, (DLGPROC)DlgAddKey, 0); if (nRet == IDOK) { uISCLEncKeys[nCount] = uKey; _i64toa(nCount, szBuffer, 10); ListViewInsertString(hListView, szBuffer, nCount, 0); _i64toa(uKey, szBuffer, 10); ListViewInsertString(hListView, szBuffer, nCount, 1); } } return TRUE; } break; case IDC_ENC_GEN: { hListView = GetDlgItem(hDlg, IDC_ENC_KEYS); ListView_DeleteAllItems(hListView); for (i = 0; i < 8; i++) { uISCLEncKeys[i] = GetRandom(); _i64toa(i, szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 0); _i64toa(uISCLEncKeys[i], szBuffer, 10); ListViewInsertString(hListView, szBuffer, i, 1); } return TRUE; } break; } break; case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_SETACTIVE: { break; } case PSN_KILLACTIVE: { hListView = GetDlgItem(hDlg,IDC_ENC_KEYS); for (i = 0; i < 8; i++) { _itoa(i, szBuffer, 10); ListView_GetItemText(hListView, i, 1, szBuffer, sizeof(szBuffer)); uISCLEncKeys[i] = _atoi64(szBuffer); } uISCLEncCurrentKey = ListView_GetSelectionMark(hListView); GetDlgItemText(hDlg, IDC_ENC_ALG, szBuffer, 100); if (strcmp(szBuffer, "ISCL_ENCRYPT_NONE") == 0) { uISCLEncAlg = DICOM_ISCL_ENCRYPT_NONE; } if (strcmp(szBuffer, "ISCL_ENCRYPT_DESCBC") == 0) { uISCLEncAlg = DICOM_ISCL_ENCRYPT_DESCBC; } GetDlgItemText(hDlg, IDC_ENC_SIGN, szBuffer, 100); if (strcmp(szBuffer, "ISCL_MAC_NONE") == 0) { uISCLEncSign = DICOM_ISCL_MAC_NONE; } if (strcmp(szBuffer, "ISCL_MAC_MD5") == 0) { uISCLEncSign = DICOM_ISCL_MAC_MD5; } if (strcmp(szBuffer, "ISCL_MAC_DESMAC") == 0) { uISCLEncSign = DICOM_ISCL_MAC_DESMAC; } } break; case PSN_APPLY: { SaveToFileSettings(); return TRUE; } break; case PSN_QUERYCANCEL: { if (LoadFromFileSettings() == FALSE) { LoadDefaultSettings(); } } break; } break; } return FALSE; } LRESULT CALLBACK DlgTLSInit (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_NOTIFY: switch (((NMHDR FAR *) lParam)->code) { case PSN_SETACTIVE: { break; } case PSN_APPLY: { SaveToFileSettings(); return TRUE; break; } case PSN_QUERYCANCEL: { if (LoadFromFileSettings() == FALSE) { LoadDefaultSettings(); } break; } } } return FALSE; } LRESULT CALLBACK DlgEditKey (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { L_CHAR szKey[100]; switch(message) { case WM_INITDIALOG: { _i64toa(uKey, szKey, 10); SetDlgItemText(hDlg, IDC_EDIT_KEY, szKey); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; break; case IDOK: GetDlgItemText(hDlg, IDC_EDIT_KEY, szKey, 100); if (_atoi64(szKey) != 0) { uKey = _atoi64(szKey); EndDialog(hDlg, IDOK); return TRUE; } else { _i64toa(uKey, szKey, 10); SetDlgItemText(hDlg, IDC_EDIT_KEY, szKey); return TRUE; } break; } } return FALSE; } LRESULT CALLBACK DlgAddKey (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { L_CHAR szKey[100]; switch(message) { case WM_INITDIALOG: { SetDlgItemText(hDlg, IDC_ADD_DATA, ""); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; break; case IDOK: GetDlgItemText(hDlg, IDC_ADD_DATA, szKey, 100); if (_atoi64(szKey) != 0) { uKey = _atoi64(szKey); EndDialog(hDlg, IDOK); return TRUE; } else { SetDlgItemText(hDlg, IDC_ADD_DATA, ""); return TRUE; } break; } } return FALSE; } L_VOID LoadDefaultSettings() { // ISCL Auth uISCLAuthAlg = DICOM_ISCL_MUTUAL_AUTH_3P4W; uISCLAuthKeys[0] = 11619789628100321; uISCLAuthKeys[1] = 34217865672122111; uISCLAuthKeys[2] = 1605935625518899689; uISCLAuthKeys[3] = 138217077775855676; uISCLAuthKeys[4] = 9117318694593010212; uISCLAuthKeys[5] = 3485297985488245687; uISCLAuthKeys[6] = 1533287511573403981; uISCLAuthKeys[7] = 5604839976916070822; uISCLAuthCurrentKey = 1; //ISCL Encrypt uISCLEncAlg = DICOM_ISCL_ENCRYPT_DESCBC; uISCLEncSign = DICOM_ISCL_MAC_MD5; uISCLEncKeys[0] = 8079278526052745737; uISCLEncKeys[1] = 1312864321990916052; uISCLEncKeys[2] = 7190959962252002117; uISCLEncKeys[3] = 3619524191167482890; uISCLEncKeys[4] = 3466658849848898336; uISCLEncKeys[5] = 8474124475946342520; uISCLEncKeys[6] = 7725464453540259890; uISCLEncKeys[7] = 4320705344832296668; uISCLEncCurrentKey = 1; } L_BOOL LoadFromFileSettings() { FILE *file; L_CHAR szbuffer[100]; L_INT i; file = fopen(FILE_SECURITY, "r"); if (file != NULL) { // ISCL Auth Settings if (fgets(szbuffer, 100, file) != NULL) { uISCLAuthAlg = (L_UINT32) _atoi64(szbuffer); } else { return FALSE; } for (i = 0; i < 8; i++) { if (fgets(szbuffer, 100, file) != NULL) { uISCLAuthKeys[i] = _atoi64(szbuffer); } else { return FALSE; } } if (fgets(szbuffer, 100, file) != NULL) { uISCLAuthCurrentKey = (L_UINT32) _atoi64(szbuffer); } else { return FALSE; } // ISCL Encr Settings if (fgets(szbuffer, 100, file) != NULL) { uISCLEncAlg = (L_UINT32) _atoi64(szbuffer); } else { return FALSE; } if (fgets(szbuffer, 100, file) != NULL) { uISCLEncSign = (L_UINT32) _atoi64(szbuffer); } else { return FALSE; } for (i = 0; i < 8; i++) { if (fgets(szbuffer, 100, file) != NULL) { uISCLEncKeys[i] = _atoi64(szbuffer); } else { return FALSE; } } if (fgets(szbuffer, 100, file) != NULL) { uISCLEncCurrentKey = (L_UINT32) _atoi64(szbuffer); } else { return FALSE; } fclose(file); } else { return FALSE; } return TRUE; } L_BOOL SaveToFileSettings() { FILE* file; L_CHAR szbuffer[100]; L_INT i; file = fopen(FILE_SECURITY, "w"); if (file != NULL) { // ISCL Auth _i64toa(uISCLAuthAlg, szbuffer, 10); fprintf(file, "%s\n", szbuffer); for (i = 0; i < 8; i++) { _i64toa(uISCLAuthKeys[i], szbuffer, 10); fprintf(file, "%s\n", szbuffer); } _i64toa(uISCLAuthCurrentKey, szbuffer, 10); fprintf(file, "%s\n", szbuffer); //ISCL Encrypt _i64toa(uISCLEncAlg, szbuffer, 10); fprintf(file, "%s\n", szbuffer); _i64toa(uISCLEncSign, szbuffer, 10); fprintf(file, "%s\n", szbuffer); for (i = 0; i < 8; i++) { _i64toa(uISCLEncKeys[i], szbuffer, 10); fprintf(file, "%s\n", szbuffer); } _i64toa(uISCLEncCurrentKey, szbuffer, 10); fprintf(file, "%s\n", szbuffer); fclose(file); } else { return FALSE; } return TRUE; } L_UINT64 GetRandom() { L_UINT64 nRet; nRet = ((L_UINT64)(rand())<<48) + ((L_UINT64)(rand())<<32) + (rand()<<16) + (rand()<<8) + rand(); return nRet; }