// CMyPropertySheet.cpp : implementation file // #include "stdafx.h" #include "DicomMWL.h" #include "MyPropertySheet.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMyPropertySheet IMPLEMENT_DYNAMIC(CMyPropertySheet, CPropertySheet) CMyPropertySheet::CMyPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage) :CPropertySheet(pszCaption, pParentWnd, iSelectPage), m_page1(CPage1::CONFIGURE_MWL_SERVER), m_page2(CPage1::CONFIGURE_STORAGE_SERVER) { /**/ /**/ AddPage(&m_page0); AddPage(&m_page1); AddPage(&m_page3); AddPage(&m_page4); AddPage(&m_page5); /**/ AddPage(&m_page6); AddPage(&m_page2); /**/ AddPage(&m_page7); SetWizardMode(); // Initialize the LEAD Dicom DLL LBase::LoadLibraries(LT_ALL_LEADLIB); LDialogBase::Initialize(DLG_INIT_COLOR); //Unlock support for medical toolkit WRPUNLOCKSUPPORT(); int nRet = LDicomNet::StartUp(); m_pMyDicomNet = new LMyDicomNet(NULL, DICOM_SECURE_NONE); L_INITBITMAP(&CGlobals::m_Bitmap,sizeof(BITMAPHANDLE), 0, 0, 0); } CMyPropertySheet::~CMyPropertySheet() { LDicomNet::ShutDown(); delete m_pMyDicomNet; if (CGlobals::m_pDS) { delete CGlobals::m_pDS; CGlobals::m_pDS = NULL; } if (CGlobals::m_Bitmap.Flags.Allocated) L_FREEBITMAP(&CGlobals::m_Bitmap); } static WNDPROC gpOriginalWindowProc = NULL; // CTreeCtrl sends notifications to the original parent window, even after SetParent has // been used to change the controls parent // Sub-class and forward message to Tree Controls parent // Knowledge base article Q104069 LRESULT CALLBACK MyPropertySheetWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { HWND hwndCtl = NULL; HWND hParent = NULL; int idCtrl; LPNMTREEVIEW pnmtv; //int nCode; switch (uMsg) { case WM_CLOSE: break; case WM_NOTIFY: idCtrl = (int) wParam; pnmtv = (LPNMTREEVIEW) lParam; if (idCtrl == IDC_TREE_RESULT) { static nCount = 0; HWND hWnd1 = GetParent(CGlobals::m_TreeResult); HWND hWnd2 = CGlobals::m_TreeResult.GetParent()->GetSafeHwnd(); if (hWnd != CGlobals::m_TreeResult.GetParent()->GetSafeHwnd()) SendMessage(CGlobals::m_TreeResult.GetParent()->GetSafeHwnd(), uMsg, wParam, lParam); } break; } return CallWindowProc(gpOriginalWindowProc, hWnd, uMsg, wParam, lParam); } BOOL CMyPropertySheet::OnInitDialog() { CRect rect(0,0,0,0); //Do this before OnInitDialog() because OnInitDialog calls OnSetActive for each page // which accesses the m_TreeResult InitializeImageList(); int nRet = CGlobals::m_TreeResult.Create( WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS, rect, this, IDC_TREE_RESULT); // This is for the display of loaded image L_UseBitmapClass(); CPropertySheet::OnInitDialog(); RECT rc; GetWindowRect (&rc); // Increase the height of the CPropertySheet by 30 rc.bottom += 30; // Resize the CPropertySheet MoveWindow (rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top); // Convert to client coordinates ScreenToClient (&rc); // Subclass the window proc gpOriginalWindowProc = (WNDPROC)SetWindowLong(GetSafeHwnd(), GWL_WNDPROC, (DWORD)MyPropertySheetWindowProc); // Deactiveate the help button m_psh.dwFlags &= ~(PSH_HASHELP); // Disable the X (close) in the dialog CMenu* pSystemMenu = GetSystemMenu(FALSE); pSystemMenu->EnableMenuItem(SC_CLOSE, MF_GRAYED); return TRUE; } BEGIN_MESSAGE_MAP(CMyPropertySheet, CPropertySheet) //{{AFX_MSG_MAP(CMyPropertySheet) ON_WM_DESTROY() ON_WM_CLOSE() //}}AFX_MSG_MAP ON_MESSAGE(WM_NOTIFYFORMAT, OnNotifyFormat) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMyPropertySheet message handlers void CMyPropertySheet::OnDestroy() { CPropertySheet::OnDestroy(); // TODO: Add your message handler code here SetWindowLong(m_hWnd, GWL_WNDPROC, (LONG)gpOriginalWindowProc); CGlobals::SaveRegKeys(); } // When tree control is created, sends WM_NOTIFYFORMAT to parent // to ask whether to use UNICODE or ANSI LONG CMyPropertySheet::OnNotifyFormat(WPARAM wParam, LPARAM lParam) { return NFR_ANSI; } void CMyPropertySheet::InitializeImageList() { int nNumImages = 3; CGlobals::m_ImageList.Create(16, 16, ILC_COLOR | ILC_MASK, nNumImages, 0); CGlobals::m_nIconElement = CGlobals::m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_ELEMENT))); CGlobals::m_nIconFolder = CGlobals::m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_FOLDER))); CGlobals::m_nIconMissing = CGlobals::m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_TYPE1_MISSING))); CGlobals::m_nIconSequence= CGlobals::m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_SEQUENCE))); CGlobals::m_nIconWorklist= CGlobals::m_ImageList.Add(::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDI_ICON_WORKLIST))); }