XTPCalendarOccurSeriesChooseDlg.cpp
上传用户:szled88
上传日期:2015-04-09
资源大小:43957k
文件大小:5k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarOccurSeriesChooseDlg.cpp: implementation of the
  2. // CXTPCalendarOccurSeriesChooseDlg class.
  3. //
  4. // This file is a part of the XTREME CALENDAR MFC class library.
  5. // (c)1998-2008 Codejock Software, All Rights Reserved.
  6. //
  7. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  8. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  9. // CONSENT OF CODEJOCK SOFTWARE.
  10. //
  11. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  12. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  13. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  14. // SINGLE COMPUTER.
  15. //
  16. // CONTACT INFORMATION:
  17. // support@codejock.com
  18. // http://www.codejock.com
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #include "stdafx.h"
  22. #include "Resource.h"
  23. #include "Common/XTPResourceManager.h"
  24. #include "Common/XTPVC50Helpers.h"
  25. #include "Common/XTPDrawHelpers.h"
  26. #include "XTPCalendarEvent.h"
  27. #include "XTPCalendarOccurSeriesChooseDlg.h"
  28. HICON XTPLoadIconEx(LPCTSTR lpszResourceIcon)
  29. {
  30. if (!lpszResourceIcon)
  31. return NULL;
  32. HICON hIcon = AfxGetApp()->LoadIcon(lpszResourceIcon);
  33. if (!hIcon)
  34. hIcon = ::LoadIcon(NULL, lpszResourceIcon);
  35. return hIcon;
  36. }
  37. // CXTPCalendarOccurSeriesChooseDlg dialog
  38. CXTPCalendarOccurSeriesChooseDlg::CXTPCalendarOccurSeriesChooseDlg(CWnd* pParent,
  39. UINT nIDResourceLabels, LPCTSTR lpszResourceIcon, UINT nIDTemplate)
  40. {
  41. InitModalIndirect(XTPResourceManager()->LoadDialogTemplate(nIDTemplate), pParent);
  42. m_bOccur = TRUE;
  43. m_nIDResourceLabels = nIDResourceLabels;
  44. m_hIcon = XTPLoadIconEx(lpszResourceIcon);
  45. SetEvent(NULL);
  46. }
  47. CXTPCalendarOccurSeriesChooseDlg::~CXTPCalendarOccurSeriesChooseDlg()
  48. {
  49. }
  50. void CXTPCalendarOccurSeriesChooseDlg::SetEvent(CXTPCalendarEvent* pEvent)
  51. {
  52. CString strDialog;
  53. VERIFY(XTPResourceManager()->LoadString(&strDialog, m_nIDResourceLabels));
  54. m_strTitle = strDialog.Left(strDialog.Find(_T('n')));
  55. VERIFY(!m_strTitle.IsEmpty());
  56. DELETE_S(strDialog, 0, m_strTitle.GetLength() + 1);
  57. m_strOccur = strDialog.Left(strDialog.Find(_T('n')));
  58. VERIFY(!m_strOccur.IsEmpty());
  59. DELETE_S(strDialog, 0, m_strOccur.GetLength() + 1);
  60. m_strSeries = strDialog.Left(strDialog.Find(_T('n')));
  61. VERIFY(!m_strSeries.IsEmpty());
  62. DELETE_S(strDialog, 0, m_strSeries.GetLength() + 1);
  63. m_strMessage.Format(strDialog, pEvent ? (LPCTSTR)pEvent->GetSubject() : _T(""));
  64. }
  65. void CXTPCalendarOccurSeriesChooseDlg::DoDataExchange(CDataExchange* pDX)
  66. {
  67. CDialog::DoDataExchange(pDX);
  68. DDX_Control(pDX, XTP_IDC_CALENDAR_STATIC_OCCUR_MESSAGE, m_ctrlMessage);
  69. DDX_Control(pDX, XTP_IDC_CALENDAR_RADIO_OCCUR, m_ctrlOccur);
  70. DDX_Control(pDX, XTP_IDC_CALENDAR_RADIO_SERIES, m_ctrlSeries);
  71. DDX_Control(pDX, XTP_IDC_CALENDAR_STATIC_ICON, m_ctrlIcon);
  72. }
  73. BEGIN_MESSAGE_MAP(CXTPCalendarOccurSeriesChooseDlg, CDialog)
  74. END_MESSAGE_MAP()
  75. // CXTPCalendarOccurSeriesChooseDlg message handlers
  76. BOOL CXTPCalendarOccurSeriesChooseDlg::OnInitDialog()
  77. {
  78. #define OFFSETWINDOW(ID, OffsetTop, OffsetHeight)
  79. GetDlgItem(ID)->GetWindowRect(rcCtrl);
  80. ScreenToClient(&rcCtrl);
  81. GetDlgItem(ID)->MoveWindow(rcCtrl.left, rcCtrl.top + OffsetTop, rcCtrl.Width(), rcCtrl.Height() + OffsetHeight);
  82. CDialog::OnInitDialog();
  83. m_ctrlOccur.SetCheck(m_bOccur ? 1 : 0);
  84. m_ctrlSeries.SetCheck(m_bOccur ? 0 : 1);
  85. if (!m_strTitle.IsEmpty())
  86. {
  87. SetWindowText(m_strTitle);
  88. }
  89. if (!m_strMessage.IsEmpty())
  90. {
  91. m_ctrlMessage.SetWindowText(m_strMessage);
  92. }
  93. if (!m_strOccur.IsEmpty())
  94. {
  95. m_ctrlOccur.SetWindowText(m_strOccur);
  96. }
  97. if (!m_strSeries.IsEmpty())
  98. {
  99. m_ctrlSeries.SetWindowText(m_strSeries);
  100. }
  101. if (m_hIcon)
  102. {
  103. m_ctrlIcon.SetIcon(m_hIcon);
  104. }
  105. CClientDC dc(&m_ctrlMessage);
  106. CFont* pOldFont = dc.SelectObject(m_ctrlMessage.GetFont());
  107. CXTPClientRect rcMessageCtrl(&m_ctrlMessage);
  108. CRect rcMessage(0, 0, rcMessageCtrl.Width(), 0);
  109. dc.DrawText(m_strMessage, rcMessage, DT_CALCRECT | DT_NOPREFIX | DT_WORDBREAK);
  110. int nOffset = rcMessage.Height() - rcMessageCtrl.Height();
  111. if (nOffset > 0)
  112. {
  113. CRect rcCtrl;
  114. GetWindowRect(rcCtrl);
  115. MoveWindow(rcCtrl.left, rcCtrl.top, rcCtrl.Width(), rcCtrl.Height() + nOffset);
  116. OFFSETWINDOW(XTP_IDC_CALENDAR_STATIC_OCCUR_MESSAGE, 0, nOffset);
  117. OFFSETWINDOW(XTP_IDC_CALENDAR_RADIO_OCCUR, nOffset, 0);
  118. OFFSETWINDOW(XTP_IDC_CALENDAR_RADIO_SERIES, nOffset, 0);
  119. OFFSETWINDOW(IDOK, nOffset, 0);
  120. OFFSETWINDOW(IDCANCEL, nOffset, 0);
  121. }
  122. dc.SelectObject(pOldFont);
  123. return TRUE;  // return TRUE unless you set the focus to a control
  124. // EXCEPTION: OCX Property Pages should return FALSE
  125. }
  126. void CXTPCalendarOccurSeriesChooseDlg::OnOK()
  127. {
  128. m_bOccur = m_ctrlOccur.GetCheck() != 0;
  129. CDialog::OnOK();
  130. }