// Page4.cpp : implementation file // #include "stdafx.h" #include "DicomMWL.h" #include "Page4.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CPage4 property page IMPLEMENT_DYNCREATE(CPage4, CPropertyPage) CPage4::CPage4() : CPropertyPage(CPage4::IDD, IDS_PAGE4) { //{{AFX_DATA_INIT(CPage4) m_strStaticInstructions = _T(""); m_strValue = _T(""); //}}AFX_DATA_INIT m_pSheet = NULL; m_pOldWndTree = NULL; m_bWaitCursor = FALSE; NO_PAGE_HELP(); } CPage4::~CPage4() { } LRESULT CPage4::OnDicomMsg(WPARAM wParam, LPARAM lParam) { CString strMsg; int nNext; EnableQueryServer(TRUE); switch (wParam) { case LMyDicomNet::DICOM_MSG_TIMEOUT: MessageBox(STR_TIMEOUT_MSG, "Warning", MB_ICONEXCLAMATION | MB_OK); nNext = 0; break; default: int nCount = CGlobals::m_TreeResult.GetCount(); if (nCount == 0) MessageBox("No items match the query. Press the button to change your query.", "Warning", MB_ICONEXCLAMATION | MB_OK); else CGlobals::m_TreeResult.SetFocus(); GetDlgItem(IDC_BUTTON_SAVE_DS)->EnableWindow(CGlobals::m_TreeResult.GetCount()); nNext = ((nCount > 0) && (wParam == LMyDicomNet::DICOM_MSG_SUCCESS)) ? PSWIZB_NEXT : 0; break; } m_pSheet->SetWizardButtons(PSWIZB_BACK | nNext); return 0; } void CPage4::DoDataExchange(CDataExchange* pDX) { CPropertyPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPage4) DDX_Control(pDX, IDC_EDIT_QUERY, m_Query); DDX_Control(pDX, IDC_EDIT_LOG, m_Log); DDX_Text(pDX, IDC_STATIC_INSTRUCTIONS, m_strStaticInstructions); DDX_Text(pDX, IDC_EDIT_VALUE, m_strValue); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPage4, CPropertyPage) //{{AFX_MSG_MAP(CPage4) ON_BN_CLICKED(IDC_BUTTON_QUERY_SERVER, OnButtonQueryServer) ON_WM_SETCURSOR() ON_BN_CLICKED(IDC_BUTTON_SAVE_DS, OnButtonSaveDs) //}}AFX_MSG_MAP ON_MESSAGE(WM_DICOM_MSG, OnDicomMsg) ON_NOTIFY(TVN_SELCHANGED, IDC_TREE_RESULT, OnSelchanged) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPage4 message handlers BOOL CPage4::OnSetActive() { m_strStaticInstructions.LoadString(IDS_PAGE4_INSTR); UpdateData(FALSE); m_pSheet = (CMyPropertySheet *)GetParent(); m_Query.Clear(); if (CGlobals::m_nQueryType == CPage3::QUERY_PATIENT_BASE) { m_Query.Append("Patient Based Query"); m_Query.Append("\tPatient Name: " + CGlobals::m_strPatientName); m_Query.Append("\tPatient ID: " + CGlobals::m_strPatientID); m_Query.Append("\tAccession Number: " + CGlobals::m_strAccessionNumber); m_Query.Append("\tRequested Procedure ID: " + CGlobals::m_strRequestedProcedureID); } else //QUERY_BROAD_MODALITY_WORK_LIST { m_Query.Append("Broad Modality Work List Query"); m_Query.Append("\tScheduled Procedure Step Start Date: " + CGlobals::m_strScheduleDate); m_Query.Append("\tModality: " + CGlobals::m_strModality); } // IDC_TREE_PLACEHOLDER is just a dummy rect that indicates where the tree should be placed. RECT rcWin, rcTree; GetDlgItem(IDC_TREE_PLACEHOLDER)->GetWindowRect(&rcTree); GetWindowRect(&rcWin); GetDlgItem(IDC_TREE_PLACEHOLDER)->ShowWindow(SW_HIDE); // change parent and reposition and size m_pOldWndTree = CGlobals::m_TreeResult.SetParent(this); CGlobals::m_TreeResult.SetWindowPos( NULL, rcTree.left-rcWin.left, rcTree.top-rcWin.top, rcTree.right-rcTree.left, rcTree.bottom-rcTree.top, SWP_NOZORDER); CGlobals::m_TreeResult.ShowWindow(SW_SHOWNORMAL); m_pSheet->SetWizardButtons(CGlobals::m_TreeResult.GetCount() ? PSWIZB_BACK | PSWIZB_NEXT : PSWIZB_BACK); GetDlgItem(IDC_BUTTON_SAVE_DS)->EnableWindow(CGlobals::m_TreeResult.GetCount()); return CPropertyPage::OnSetActive(); } BOOL CPage4::OnKillActive() { CGlobals::m_TreeResult.SetParent(m_pOldWndTree); CGlobals::m_TreeResult.ShowWindow(SW_HIDE); return CPropertyPage::OnKillActive(); } LRESULT CPage4::OnWizardNext() { // TODO: Add your specialized code here and/or call the base class if (UpdateData(TRUE) == 0) return FALSE; return CPropertyPage::OnWizardNext(); } void CPage4::OnButtonQueryServer() { L_INT nRet; m_pSheet->SetWizardButtons(0); m_Log.Clear(); CGlobals::m_TreeResult.DeleteAllItems(); LMyDicomNet *pMyDicomNet = m_pSheet->m_pMyDicomNet; if (pMyDicomNet) { pMyDicomNet->m_nCommandType = LMyDicomNet::MODALITY_WORKLIST_FIND; pMyDicomNet->m_pTreeResult = &CGlobals::m_TreeResult; pMyDicomNet->m_pWnd = this; pMyDicomNet->m_pLog = &m_Log; pMyDicomNet->m_strServerAE = (LPSTR)(LPCSTR)CGlobals::m_strMWLServerAE; pMyDicomNet->m_strClientAE = (LPSTR)(LPCSTR)CGlobals::m_strMWLClientAE; CString strMWLServerIP = CMyIPAddressCtrl::IPtoString(CGlobals::m_lMWLServerIP); nRet = pMyDicomNet->Connect( NULL, 0, (LPSTR)(LPCSTR)strMWLServerIP, CGlobals::m_nMWLServerPort); } EnableQueryServer(FALSE); } void CPage4::EnableQueryServer(int bEnable) { m_bWaitCursor = !bEnable; SendMessage(WM_SETCURSOR); GetDlgItem(IDC_BUTTON_QUERY_SERVER)->EnableWindow(bEnable); GetDlgItem(IDC_BUTTON_SAVE_DS)->EnableWindow(bEnable); } BOOL CPage4::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if (m_bWaitCursor) { SetCursor(LoadCursor(NULL, IDC_WAIT)); return TRUE; } else SetCursor(LoadCursor(NULL, IDC_ARROW)); return CPropertyPage::OnSetCursor(pWnd, nHitTest, message); } void CPage4::UpdateEditBox(HTREEITEM hItem) { CMyTreeData *pMyTreeData = (CMyTreeData *)CGlobals::m_TreeResult.GetItemData(hItem); if (pMyTreeData) m_strValue = pMyTreeData->m_strValue; else m_strValue = ""; UpdateData(FALSE); } void CPage4::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult) { NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR; // TODO: Add your control notification handler code here if (pNMTreeView->itemNew.hItem != pNMTreeView->itemOld.hItem) { UpdateEditBox(pNMTreeView->itemNew.hItem); } *pResult = 0; } void CPage4::OnButtonSaveDs() { HTREEITEM hItem = CGlobals::m_TreeResult.GetSelectedItem(); if (!hItem) return; CMyTreeData *pMyTreeData = (CMyTreeData *)CGlobals::m_TreeResult.GetItemData(hItem); if (!pMyTreeData) return; CPage1::StoreLocally(pMyTreeData->m_pDS); }