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

对话框与窗口

开发平台:

Visual C++

  1. // XTPCalendarEventRecurrenceDlg.cpp: implementation of the CXTPCalendarEventPropertiesDlg.
  2. //
  3. // This file is a part of the XTREME CALENDAR MFC class library.
  4. // (c)1998-2008 Codejock Software, All Rights Reserved.
  5. //
  6. // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE
  7. // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN
  8. // CONSENT OF CODEJOCK SOFTWARE.
  9. //
  10. // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED
  11. // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO
  12. // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A
  13. // SINGLE COMPUTER.
  14. //
  15. // CONTACT INFORMATION:
  16. // support@codejock.com
  17. // http://www.codejock.com
  18. //
  19. /////////////////////////////////////////////////////////////////////////////
  20. #include "stdafx.h"
  21. #include "Resource.h"
  22. #include "Common/XTPResourceManager.h"
  23. #include "Common/XTPVC50Helpers.h"
  24. #include "XTPCalendarEventRecurrenceDlg.h"
  25. #include "XTPCalendarEventPropertiesDlg.h"
  26. #include "XTPCalendarEvent.h"
  27. #include "XTPCalendarRecurrencePattern.h"
  28. #define XTP_TIMER_ID_UPDATE_TIMEOUT 100
  29. #define XTP_TIMER_ID_START_CB_CHANGED       0x01
  30. #define XTP_TIMER_ID_END_CB_CHANGED         0x02
  31. #define XTP_TIMER_ID_DURATION_CB_CHANGED    0x04
  32. #define XTP_TIMER_ID_ALL_CB_CHANGED         0x07
  33. IMPLEMENT_DYNAMIC(CXTPCalendarEventRecurrenceDlg, CDialog)
  34. /////////////////////////////////////////////////////////////////////////////
  35. CXTPCalendarEventRecurrenceDlg::CXTPCalendarEventRecurrenceDlg(CXTPCalendarEvent* pMasterEvent,
  36.    CWnd* pParent, UINT nIDTemplate)
  37. :
  38. m_nOccurNum(10),
  39. m_dtEndDate(COleDateTime::GetCurrentTime()),
  40. m_nDayInterval(1),
  41. m_nWeeklyInterval(1),
  42. m_bMonday(TRUE),
  43. m_bTuesday(FALSE),
  44. m_bWednesday(FALSE),
  45. m_bThursday(FALSE),
  46. m_bFriday(FALSE),
  47. m_bSaturday(FALSE),
  48. m_bSunday(FALSE),
  49. m_MonthDate(1),
  50. m_nMonthInterval(1),
  51. m_nMonthInterval2(1),
  52. m_nDayOfMonth(m_dtEndDate.GetDay()),
  53. m_ptrMasterEvent(pMasterEvent, TRUE),
  54. m_bDisableRemove(FALSE)
  55. {
  56. InitModalIndirect(XTPResourceManager()->LoadDialogTemplate(nIDTemplate), pParent);
  57. ASSERT(m_ptrMasterEvent);
  58. m_ptrPattern = m_ptrMasterEvent->GetRecurrencePattern();
  59. m_dtStart = m_ptrPattern->GetStartTime();
  60. m_dtEnd = m_dtStart + m_ptrPattern->GetDuration();
  61. m_dtStartDate = m_ptrPattern->GetPatternStartDate();
  62. }
  63. CXTPCalendarEventRecurrenceDlg::~CXTPCalendarEventRecurrenceDlg()
  64. {
  65. }
  66. #if _MSC_VER < 1200
  67. AFX_INLINE void DDX_DateTimeCtrl(CDataExchange* pDX, int nIDC, COleDateTime& value)
  68. {
  69. HWND hWndCtrl = pDX->PrepareCtrl(nIDC);
  70. if (pDX->m_bSaveAndValidate)
  71. CXTPDateTimeHelper::GetDateTimeCtrlTime(hWndCtrl, value);
  72. else
  73. CXTPDateTimeHelper::SetDateTimeCtrlTime(hWndCtrl, value);
  74. }
  75. #endif
  76. void CXTPCalendarEventRecurrenceDlg::DoDataExchange(CDataExchange* pDX)
  77. {
  78. CDialog::DoDataExchange(pDX);
  79. DDX_Control(pDX, XTP_IDC_COMBO_SCHEDULEID, m_wndCbStart);
  80. DDX_Control(pDX, XTP_IDC_COMBO_REC_END, m_wndCbEnd);
  81. DDX_Control(pDX, XTP_IDC_COMBO_REC_DURATION, m_wndCbDuration);
  82. DDX_DateTimeCtrl(pDX, XTP_IDC_DATETIMEPICKER_START, m_dtStartDate);
  83. DDX_DateTimeCtrl(pDX, XTP_IDC_DATETIMEPICKER_ENDDATE, m_dtEndDate);
  84. DDX_Text(pDX, XTP_IDC_EDIT_OCCUR, m_nOccurNum);
  85. DDX_Text(pDX, XTP_IDC_EDIT_DAYINTERVAL, m_nDayInterval);
  86. DDX_Text(pDX, XTP_IDC_EDIT_WEEKLY_INTERVAL, m_nWeeklyInterval);
  87. DDX_Check(pDX, XTP_IDC_CHECK_MONDAY, m_bMonday);
  88. DDX_Check(pDX, XTP_IDC_CHECK_TUESDAY, m_bTuesday);
  89. DDX_Check(pDX, XTP_IDC_CHECK_WEDNESDAY, m_bWednesday);
  90. DDX_Check(pDX, XTP_IDC_CHECK_THURSDAY, m_bThursday);
  91. DDX_Check(pDX, XTP_IDC_CHECK_FRIDAY, m_bFriday);
  92. DDX_Check(pDX, XTP_IDC_CHECK_SATURDAY, m_bSaturday);
  93. DDX_Check(pDX, XTP_IDC_CHECK_SUNDAY, m_bSunday);
  94. DDX_Text(pDX, XTP_IDC_EDIT_MONTH_DATE, m_MonthDate);
  95. DDX_Text(pDX, XTP_IDC_EDIT_MONTH_MONTH, m_nMonthInterval);
  96. DDX_Text(pDX, XTP_IDC_EDIT_MONTH_MONTH2, m_nMonthInterval2);
  97. DDX_Control(pDX, XTP_IDC_COMBO_MONTH_DAY, m_wndCbMonthDay);
  98. DDX_Control(pDX, XTP_IDC_COMBO_MONTH_CRIT, m_wndCbMonthWhich);
  99. DDX_Text(pDX, XTP_IDC_EDIT_YEAR_DATE, m_nDayOfMonth);
  100. DDX_Control(pDX, XTP_IDC_COMBO_YEAR_MONTH, m_wndYearMonth);
  101. DDX_Control(pDX, XTP_IDC_COMBO_YEAR_MONTH2, m_wndComboYearMonth2);
  102. DDX_Control(pDX, XTP_IDC_COMBO_YEAR_CRIT, m_wndCbYearWhich);
  103. DDX_Control(pDX, XTP_IDC_COMBO_YEAR_DAY, m_wndCbYearDay);
  104. }
  105. BEGIN_MESSAGE_MAP(CXTPCalendarEventRecurrenceDlg, CDialog)
  106. ON_CBN_SELCHANGE(XTP_IDC_COMBO_SCHEDULEID, OnStartComboChanged)
  107. ON_CBN_SELCHANGE(XTP_IDC_COMBO_REC_END, OnEndComboChanged)
  108. ON_CBN_SELCHANGE(XTP_IDC_COMBO_REC_DURATION, OnDurationComboChanged)
  109. ON_CBN_KILLFOCUS(XTP_IDC_COMBO_SCHEDULEID, OnStartComboChanged)
  110. ON_CBN_KILLFOCUS(XTP_IDC_COMBO_REC_END, OnEndComboChanged)
  111. ON_CBN_KILLFOCUS(XTP_IDC_COMBO_REC_DURATION, OnDurationComboChanged)
  112. ON_CBN_EDITCHANGE(XTP_IDC_COMBO_SCHEDULEID, OnStartComboEdited)
  113. ON_CBN_EDITCHANGE(XTP_IDC_COMBO_REC_END, OnEndComboEdited)
  114. ON_CBN_EDITCHANGE(XTP_IDC_COMBO_REC_DURATION, OnDurationComboEdited)
  115. ON_BN_CLICKED(XTP_IDC_BUTTON_REMOVE_RECURRENCE, OnBnClickedButtonRemoveRecurrence)
  116. ON_CONTROL_RANGE(BN_CLICKED, XTP_IDC_RADIO_DAILY, XTP_IDC_RADIO_YEARLY, OnBnClickedRadioDailyYearly)
  117. ON_WM_TIMER()
  118. END_MESSAGE_MAP()
  119. void CXTPCalendarEventRecurrenceDlg::InitStartEndCB()
  120. {
  121. BOOL bInListStart = FALSE;
  122. BOOL bInListEnd = FALSE;
  123. CString strTimeFormat_HrMin = CXTPCalendarUtils::GetTimeFormatString_HrMin();
  124. CString strTime;
  125. // initializing m_wndCbStart and m_wndCbEnd combo boxes
  126. for (int i = 0; i < 24*60; i += 30)
  127. {
  128. int nHours = i / 60;
  129. int nMinutes = i % 60;
  130. strTime = CXTPCalendarUtils::GetTimeFormat(nHours, nMinutes, strTimeFormat_HrMin);
  131. int nIndex = m_wndCbStart.AddString(strTime);
  132. if (m_dtStart.GetHour() == nHours && m_dtStart.GetMinute() == nMinutes)
  133. {
  134. m_wndCbStart.SetCurSel(nIndex);
  135. bInListStart = TRUE;
  136. }
  137. nIndex = m_wndCbEnd.AddString(strTime);
  138. if (m_dtEnd.GetHour() == nHours && m_dtEnd.GetMinute() == nMinutes)
  139. {
  140. m_wndCbEnd.SetCurSel(nIndex);
  141. bInListEnd = TRUE;
  142. }
  143. }
  144. if (!bInListStart)
  145. {
  146. strTime = CXTPCalendarUtils::GetTimeFormat(m_dtStart.GetHour(), m_dtStart.GetMinute(), strTimeFormat_HrMin);
  147. m_wndCbStart.SetWindowText(strTime);
  148. }
  149. if (!bInListEnd)
  150. {
  151. strTime = CXTPCalendarUtils::GetTimeFormat(m_dtEnd.GetHour(), m_dtEnd.GetMinute(), strTimeFormat_HrMin);
  152. m_wndCbEnd.SetWindowText(strTime);
  153. }
  154. }
  155. int CXTPCalendarEventRecurrenceDlg::_AddString(CComboBox& wndCB, UINT nStrResID, DWORD_PTR dwItemData)
  156. {
  157. int nIndex = wndCB.AddString(CXTPCalendarUtils::LoadString(nStrResID));
  158. wndCB.SetItemData(nIndex, dwItemData);
  159. return nIndex;
  160. }
  161. int CXTPCalendarEventRecurrenceDlg::_AddLocaleString(CComboBox& wndCB, LCTYPE lcidStr, DWORD_PTR dwItemData)
  162. {
  163. int nIndex = wndCB.AddString(CXTPCalendarUtils::GetLocaleString(lcidStr, 255));
  164. wndCB.SetItemData(nIndex, dwItemData);
  165. return nIndex;
  166. }
  167. void CXTPCalendarEventRecurrenceDlg::InitDurationCB()
  168. {
  169. //initializing combo m_wndCbDuration combobox
  170. int nDuration_min = m_ptrPattern->GetDurationMinutes();
  171. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_0, 0);
  172. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_1, 1);
  173. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_5, 5);
  174. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_10, 10);
  175. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_15, 15);
  176. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_MINUTES_30, 30);
  177. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_1, 1 * 60);
  178. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_2, 2 * 60);
  179. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_3, 3 * 60);
  180. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_4, 4 * 60);
  181. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_5, 5 * 60);
  182. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_6, 6 * 60);
  183. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_7, 7 * 60);
  184. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_8, 8 * 60);
  185. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_9, 9 * 60);
  186. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_10, 10 * 60);
  187. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_11, 11 * 60);
  188. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_DAYS_0_5, 12 * 60);
  189. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_HOURS_18, 18 * 60);
  190. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_DAYS_1, 1 * 24 * 60);
  191. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_DAYS_2, 2 * 24 * 60);
  192. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_DAYS_3, 3 * 24 * 60);
  193. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_WEEKS_1, 1 * 7 * 24 * 60);
  194. _AddString(m_wndCbDuration, XTP_IDS_CALENDAR_WEEKS_2, 2 * 7 * 24 * 60);
  195. int nCount = m_wndCbDuration.GetCount();
  196. for (int i = 0; i < nCount; i++)
  197. {
  198. if (nDuration_min == (int)m_wndCbDuration.GetItemData(i))
  199. {
  200. m_wndCbDuration.SetCurSel(i);
  201. return;
  202. }
  203. }
  204. CString strDuration = CXTPCalendarUtils::FormatTimeDuration(nDuration_min, FALSE);
  205. m_wndCbDuration.SetWindowText(strDuration);
  206. }
  207. void CXTPCalendarEventRecurrenceDlg::InitDayOfWeekCBs(CComboBox& wndCB)
  208. {
  209. _AddLocaleString(wndCB, LOCALE_SDAYNAME1, xtpCalendarDayMonday);
  210. _AddLocaleString(wndCB, LOCALE_SDAYNAME2, xtpCalendarDayTuesday);
  211. _AddLocaleString(wndCB, LOCALE_SDAYNAME3, xtpCalendarDayWednesday);
  212. _AddLocaleString(wndCB, LOCALE_SDAYNAME4, xtpCalendarDayThursday);
  213. _AddLocaleString(wndCB, LOCALE_SDAYNAME5, xtpCalendarDayFriday);
  214. _AddLocaleString(wndCB, LOCALE_SDAYNAME6, xtpCalendarDaySaturday);
  215. _AddLocaleString(wndCB, LOCALE_SDAYNAME7, xtpCalendarDaySunday);
  216. wndCB.SetCurSel(0);
  217. }
  218. void CXTPCalendarEventRecurrenceDlg::InitWhichDayCBs(CComboBox& wndCB)
  219. {
  220. _AddString(wndCB, XTP_IDS_CALENDAR_FIRST,   xtpCalendarWeekFirst);
  221. _AddString(wndCB, XTP_IDS_CALENDAR_SECOND,  xtpCalendarWeekSecond);
  222. _AddString(wndCB, XTP_IDS_CALENDAR_THIRD,   xtpCalendarWeekThird);
  223. _AddString(wndCB, XTP_IDS_CALENDAR_FOURTH,  xtpCalendarWeekFourth);
  224. _AddString(wndCB, XTP_IDS_CALENDAR_LAST,    xtpCalendarWeekLast);
  225. wndCB.SetCurSel(0);
  226. }
  227. void CXTPCalendarEventRecurrenceDlg::InitMonthCBs(CComboBox& wndCB)
  228. {
  229. for (int nMonth = 0; nMonth < 12; nMonth++)
  230. {
  231. _AddLocaleString(wndCB, LOCALE_SMONTHNAME1 + nMonth, nMonth + 1);
  232. }
  233. COleDateTime dtNow(COleDateTime::GetCurrentTime());
  234. wndCB.SetCurSel(dtNow.GetMonth() - 1);
  235. }
  236. // CXTPCalendarEventRecurrenceDlg message handlers
  237. BOOL CXTPCalendarEventRecurrenceDlg::OnInitDialog()
  238. {
  239. CDialog::OnInitDialog();
  240. InitStartEndCB();
  241. InitDurationCB();
  242. //initializing recurrence end properties
  243. int nRadio = XTP_IDC_RADIO_NOEND;
  244. XTPCalendarPatternEnd UseEnd = (XTPCalendarPatternEnd)
  245.  m_ptrPattern->GetUseEndMethod();
  246. switch (UseEnd)
  247. {
  248. case xtpCalendarPatternEndDate:
  249. nRadio = XTP_IDC_RADIO_ENDBY;
  250. m_dtEndDate = m_ptrPattern->GetPatternEndDate();
  251. break;
  252. case xtpCalendarPatternEndAfterOccurrences:
  253. nRadio = XTP_IDC_RADIO_ENDAFTER;
  254. m_nOccurNum = m_ptrPattern->GetEndAfterOccurrences();
  255. break;
  256. case xtpCalendarPatternEndNoDate:
  257. nRadio = XTP_IDC_RADIO_NOEND;
  258. break;
  259. }
  260. CheckRadioButton(XTP_IDC_RADIO_NOEND, XTP_IDC_RADIO_ENDBY, nRadio);
  261. if (!m_bDisableRemove)
  262. {
  263. ::EnableWindow(GetDlgItem(XTP_IDC_BUTTON_REMOVE_RECURRENCE)->GetSafeHwnd(), TRUE);
  264. }
  265. // initializing day/week/month/year recurrence settings
  266. CheckRadioButton(XTP_IDC_RADIO_EVERYDAY, XTP_IDC_RADIO_EVERYWORKDAY, XTP_IDC_RADIO_EVERYDAY);
  267. CheckRadioButton(XTP_IDC_RADIO_MONTH_RECUR, XTP_IDC_RADIO_MONTH_IN, XTP_IDC_RADIO_MONTH_RECUR);
  268. CheckRadioButton(XTP_IDC_RADIO_YEAR_RECUR, XTP_IDC_RADIO_YEAR_IN, XTP_IDC_RADIO_YEAR_RECUR);
  269. InitDayOfWeekCBs(m_wndCbMonthDay);
  270. InitDayOfWeekCBs(m_wndCbYearDay);
  271. InitWhichDayCBs(m_wndCbMonthWhich);
  272. InitWhichDayCBs(m_wndCbYearWhich);
  273. InitMonthCBs(m_wndYearMonth);
  274. InitMonthCBs(m_wndComboYearMonth2);
  275. nRadio = XTP_IDC_RADIO_WEEKLY;
  276. XTP_CALENDAR_RECURRENCE_OPTIONS opt = m_ptrPattern->GetRecurrenceOptions();
  277. int nRecType = m_ptrPattern->GetRecurrenceType();
  278. int i;
  279. switch (nRecType)
  280. {
  281. case xtpCalendarRecurrenceDaily:
  282. {
  283. nRadio = XTP_IDC_RADIO_DAILY;
  284. int nRd = XTP_IDC_RADIO_EVERYDAY;
  285. if (opt.m_Daily.bEveryWeekDayOnly)
  286. {
  287. m_nDayInterval = 1;
  288. nRd = XTP_IDC_RADIO_EVERYWORKDAY;
  289. }
  290. else
  291. {
  292. m_nDayInterval = opt.m_Daily.nIntervalDays;
  293. }
  294. CheckRadioButton(XTP_IDC_RADIO_EVERYDAY, XTP_IDC_RADIO_EVERYWORKDAY, nRd);
  295. }
  296. break;
  297. case xtpCalendarRecurrenceWeekly:
  298. nRadio = XTP_IDC_RADIO_WEEKLY;
  299. m_nWeeklyInterval = opt.m_Weekly.nIntervalWeeks;
  300. m_bMonday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDayMonday) != 0;
  301. m_bTuesday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDayTuesday) != 0;
  302. m_bWednesday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDayWednesday) != 0;
  303. m_bThursday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDayThursday) != 0;
  304. m_bFriday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDayFriday) != 0;
  305. m_bSaturday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDaySaturday) != 0;
  306. m_bSunday = (opt.m_Weekly.nDayOfWeekMask & xtpCalendarDaySunday) != 0;
  307. break;
  308. case xtpCalendarRecurrenceMonthly:
  309. nRadio = XTP_IDC_RADIO_MONTHLY;
  310. CheckRadioButton(XTP_IDC_RADIO_MONTH_RECUR, XTP_IDC_RADIO_MONTH_IN,
  311.  XTP_IDC_RADIO_MONTH_RECUR);
  312. m_nMonthInterval = opt.m_Monthly.nIntervalMonths;
  313. m_MonthDate = opt.m_Monthly.nDayOfMonth;
  314. break;
  315. case xtpCalendarRecurrenceMonthNth:
  316. {
  317. nRadio = XTP_IDC_RADIO_MONTHLY;
  318. CheckRadioButton(XTP_IDC_RADIO_MONTH_RECUR, XTP_IDC_RADIO_MONTH_IN,
  319.  XTP_IDC_RADIO_MONTH_IN);
  320. m_nMonthInterval2 = opt.m_MonthNth.nIntervalMonths;
  321. for (i = 0; i < m_wndCbMonthDay.GetCount(); i++)
  322. if (opt.m_MonthNth.nWhichDayMask & m_wndCbMonthDay.GetItemData(i))
  323. {
  324. m_wndCbMonthDay.SetCurSel(i);
  325. break;
  326. }
  327. for (i = 0; i < m_wndCbMonthWhich.GetCount(); i++)
  328. if (opt.m_MonthNth.nWhichDay == (int) m_wndCbMonthWhich.GetItemData(i))
  329. {
  330. m_wndCbMonthWhich.SetCurSel(i);
  331. break;
  332. }
  333. }
  334. break;
  335. case xtpCalendarRecurrenceYearly:
  336. {
  337. nRadio = XTP_IDC_RADIO_YEARLY;
  338. CheckRadioButton(XTP_IDC_RADIO_YEAR_RECUR, XTP_IDC_RADIO_YEAR_IN,
  339.  XTP_IDC_RADIO_YEAR_RECUR);
  340. m_nDayOfMonth = opt.m_Yearly.nDayOfMonth;
  341. for (i = 0; i < m_wndYearMonth.GetCount(); i++)
  342. {
  343. if (opt.m_Yearly.nMonthOfYear == (int) m_wndYearMonth.GetItemData(i))
  344. {
  345. m_wndYearMonth.SetCurSel(i);
  346. break;
  347. }
  348. }
  349. }
  350. break;
  351. case xtpCalendarRecurrenceYearNth:
  352. nRadio = XTP_IDC_RADIO_YEARLY;
  353. CheckRadioButton(XTP_IDC_RADIO_YEAR_RECUR, XTP_IDC_RADIO_YEAR_IN, XTP_IDC_RADIO_YEAR_IN);
  354. for (i = 0; i < m_wndComboYearMonth2.GetCount(); i++)
  355. if (opt.m_YearNth.nMonthOfYear == (int) m_wndComboYearMonth2.GetItemData(i))
  356. {
  357. m_wndComboYearMonth2.SetCurSel(i);
  358. break;
  359. }
  360. for (i = 0; i < m_wndCbYearWhich.GetCount(); i++)
  361. if (opt.m_YearNth.nWhichDay == (int) m_wndCbYearWhich.GetItemData(i))
  362. {
  363. m_wndCbYearWhich.SetCurSel(i);
  364. break;
  365. }
  366. for (i = 0; i < m_wndCbYearDay.GetCount(); i++)
  367. if (opt.m_YearNth.nWhichDayMask & m_wndCbYearDay.GetItemData(i))
  368. {
  369. m_wndCbYearDay.SetCurSel(i);
  370. break;
  371. }
  372. break;
  373. default:
  374. ASSERT(nRecType == xtpCalendarRecurrenceUnknown);
  375. }
  376. CheckRadioButton(XTP_IDC_RADIO_DAILY, XTP_IDC_RADIO_YEARLY, nRadio);
  377. OnBnClickedRadioDailyYearly(nRadio);
  378. UpdateData(FALSE);
  379. _MoveControlsBy_Y();
  380. return TRUE;
  381. }
  382. void CXTPCalendarEventRecurrenceDlg::OnTimer(UINT_PTR nIDEvent)
  383. {
  384. if (nIDEvent & XTP_TIMER_ID_ALL_CB_CHANGED)
  385. {
  386. KillTimer(nIDEvent);
  387. }
  388. else
  389. {
  390. ASSERT(FALSE);
  391. CDialog::OnTimer(nIDEvent);
  392. }
  393. if (nIDEvent & XTP_TIMER_ID_START_CB_CHANGED)
  394. {
  395. //TRACE(_T("_OnStartChanged() n"));
  396. _OnStartChanged();
  397. }
  398. if (nIDEvent & XTP_TIMER_ID_END_CB_CHANGED)
  399. {
  400. //TRACE(_T("_OnEndChanged() n"));
  401. _OnEndChanged();
  402. }
  403. if (nIDEvent & XTP_TIMER_ID_DURATION_CB_CHANGED)
  404. {
  405. //TRACE(_T("_OnDurationChanged() n"));
  406. _OnDurationChanged();
  407. }
  408. }
  409. void CXTPCalendarEventRecurrenceDlg::OnStartChanged()
  410. {
  411. SetTimer(XTP_TIMER_ID_START_CB_CHANGED, XTP_TIMER_ID_UPDATE_TIMEOUT, NULL);
  412. }
  413. void CXTPCalendarEventRecurrenceDlg::OnEndChanged()
  414. {
  415. SetTimer(XTP_TIMER_ID_END_CB_CHANGED, XTP_TIMER_ID_UPDATE_TIMEOUT, NULL);
  416. }
  417. void CXTPCalendarEventRecurrenceDlg::OnDurationChanged()
  418. {
  419. SetTimer(XTP_TIMER_ID_DURATION_CB_CHANGED, XTP_TIMER_ID_UPDATE_TIMEOUT, NULL);
  420. }
  421. int CXTPCalendarEventRecurrenceDlg::GetChangedComboTimeInMin(CComboBox& wndCb)
  422. {
  423. CString strCBtext;
  424. wndCb.GetWindowText(strCBtext);
  425. return CXTPCalendarUtils::ParceTimeString_min(strCBtext);
  426. }
  427. void CXTPCalendarEventRecurrenceDlg::OnStartComboEdited()
  428. {
  429. int nMin = GetChangedComboTimeInMin(m_wndCbStart);
  430. if (nMin >= 0)
  431. OnStartChanged();
  432. }
  433. void CXTPCalendarEventRecurrenceDlg::OnEndComboEdited()
  434. {
  435. int nMin = GetChangedComboTimeInMin(m_wndCbEnd);
  436. if (nMin >= 0)
  437. OnEndChanged();
  438. }
  439. void CXTPCalendarEventRecurrenceDlg::OnDurationComboEdited()
  440. {
  441. int nMin = GetDurationComboInMin();
  442. if (nMin >= 0)
  443. OnDurationChanged();
  444. }
  445. void CXTPCalendarEventRecurrenceDlg::OnStartComboChanged()
  446. {
  447. OnStartChanged();
  448. }
  449. void CXTPCalendarEventRecurrenceDlg::_OnStartChanged()
  450. {
  451. int nMin = GetChangedComboTimeInMin(m_wndCbStart);
  452. if (nMin == -1)
  453. {
  454. return;
  455. }
  456. m_dtStart.SetTime(nMin/60%24, nMin%60, 0);
  457. int nDurationMin = GetDurationComboInMin();
  458. if (nDurationMin < 0)
  459. {
  460. nDurationMin = 0;
  461. }
  462. COleDateTimeSpan spDiff((double)nDurationMin/((double)24*60));
  463. m_dtEnd = m_dtStart + spDiff;
  464. m_dtEnd = CXTPCalendarUtils::ResetDate(m_dtEnd);
  465. CString strTimeFormat_HrMin = CXTPCalendarUtils::GetTimeFormatString_HrMin();
  466. CString strTmp = CXTPCalendarUtils::GetTimeFormat(m_dtEnd.GetHour(), m_dtEnd.GetMinute(), strTimeFormat_HrMin);
  467. m_wndCbEnd.SetWindowText(strTmp);
  468. }
  469. void CXTPCalendarEventRecurrenceDlg::OnEndComboChanged()
  470. {
  471. OnEndChanged();
  472. }
  473. void CXTPCalendarEventRecurrenceDlg::_OnEndChanged()
  474. {
  475. int nMin = GetChangedComboTimeInMin(m_wndCbEnd);
  476. if (nMin == -1)
  477. {
  478. return;
  479. }
  480. COleDateTime dtPrevEnd = m_dtEnd;
  481. m_dtEnd.SetTime(nMin/60%24, nMin%60, 0);
  482. COleDateTimeSpan spDiff = m_dtEnd - dtPrevEnd;
  483. int nDuration = GetDurationComboInMin();
  484. if (nDuration < 0)
  485. {
  486. nDuration = 0;
  487. }
  488. nDuration += GETTOTAL_MINUTES_DTS(spDiff);
  489. if (m_dtEnd < m_dtStart && nDuration < 0)
  490. {
  491. spDiff = m_dtStart - m_dtEnd;
  492. nDuration = 24*60 - GETTOTAL_MINUTES_DTS(spDiff);
  493. }
  494. CString strDuration = CXTPCalendarUtils::FormatTimeDuration(nDuration, FALSE);
  495. m_wndCbDuration.SetWindowText(strDuration);
  496. }
  497. int CXTPCalendarEventRecurrenceDlg::GetDurationComboInMin()
  498. {
  499. CString strCBtext;
  500. m_wndCbDuration.GetWindowText(strCBtext);
  501. return CXTPCalendarUtils::ParceTimeDuration_min(strCBtext);
  502. }
  503. void CXTPCalendarEventRecurrenceDlg::OnDurationComboChanged()
  504. {
  505. OnDurationChanged();
  506. }
  507. void CXTPCalendarEventRecurrenceDlg::_OnDurationChanged()
  508. {
  509. int nDuration_min = GetDurationComboInMin();
  510. if (nDuration_min < 0)
  511. {
  512. return;
  513. }
  514. m_dtEnd = m_dtStart + CXTPCalendarUtils::Minutes2Span(nDuration_min);
  515. CString strTimeFormat_HrMin = CXTPCalendarUtils::GetTimeFormatString_HrMin();
  516. CString strTmp = CXTPCalendarUtils::GetTimeFormat(m_dtEnd.GetHour(), m_dtEnd.GetMinute(), strTimeFormat_HrMin);
  517. m_wndCbEnd.SetWindowText(strTmp);
  518. }
  519. void CXTPCalendarEventRecurrenceDlg::MsgBox_WrongValue(CWnd* pWnd)
  520. {
  521. pWnd->SetFocus();
  522. XTPResourceManager()->ShowMessageBox(XTP_IDS_CALENDAR_WRONG_VALUE);
  523. }
  524. void CXTPCalendarEventRecurrenceDlg::MsgBox_WrongValueRange(UINT nCtrlID, int nMin, int nMax)
  525. {
  526. if (GetDlgItem(nCtrlID))
  527. GetDlgItem(nCtrlID)->SetFocus();
  528. CString strFormat = CXTPCalendarUtils::LoadString(XTP_IDS_CALENDAR_WRONG_VALUE_RANGE);
  529. CString strMsg, strVal1, strVal2;
  530. strVal1.Format(_T("%d"), nMin);
  531. strVal2.Format(_T("%d"), nMax);
  532. strMsg.Format(strFormat, (LPCTSTR)strVal1, (LPCTSTR)strVal2);
  533. XTPResourceManager()->ShowMessageBox(strMsg);
  534. }
  535. void CXTPCalendarEventRecurrenceDlg::OnOK()
  536. {
  537. int nMin = GetChangedComboTimeInMin(m_wndCbStart);
  538. if (nMin == -1)
  539. {
  540. MsgBox_WrongValue(&m_wndCbStart);
  541. return;
  542. }
  543. nMin = GetChangedComboTimeInMin(m_wndCbEnd);
  544. if (nMin == -1)
  545. {
  546. MsgBox_WrongValue(&m_wndCbEnd);
  547. return;
  548. }
  549. int nDuration_min = GetDurationComboInMin();
  550. if (nDuration_min < 0)
  551. {
  552. MsgBox_WrongValue(&m_wndCbDuration);
  553. return;
  554. }
  555. UpdateData();
  556. CXTPCalendarEventsPtr ptrExceptions = m_ptrPattern->GetExceptions();
  557. if (ptrExceptions && ptrExceptions->GetCount())
  558. {
  559. // Any exceptions associated with this recurring appointment will be lost. If any of the exceptions are meetings, the attendees will not be notified. Is this OK?
  560. int nRes = XTPResourceManager()->ShowMessageBox(XTP_IDS_CALENDAR_REMOVE_EXCEPTIONS, MB_OKCANCEL);
  561. if (nRes != IDOK)
  562. {
  563. return;
  564. }
  565. m_ptrPattern->RemoveAllExceptions();
  566. }
  567. m_dtStart = CXTPCalendarUtils::ResetDate(m_dtStart);
  568. m_ptrPattern->SetStartTime(m_dtStart);
  569. m_ptrPattern->SetDurationMinutes(nDuration_min);
  570. //----------------------------------------------------------
  571. XTP_CALENDAR_RECURRENCE_OPTIONS opt;
  572. int nRadio = GetCheckedRadioButton(XTP_IDC_RADIO_DAILY, XTP_IDC_RADIO_YEARLY);
  573. switch (nRadio)
  574. {
  575. case XTP_IDC_RADIO_DAILY:
  576. {
  577. if (m_nDayInterval < 1 || m_nDayInterval > 999)
  578. {
  579. MsgBox_WrongValueRange(XTP_IDC_EDIT_DAYINTERVAL, 1, 999);
  580. return;
  581. }
  582. opt.m_nRecurrenceType = xtpCalendarRecurrenceDaily;
  583. opt.m_Daily.bEveryWeekDayOnly = GetCheckedRadioButton(XTP_IDC_RADIO_EVERYDAY,
  584.   XTP_IDC_RADIO_EVERYWORKDAY) ==
  585. XTP_IDC_RADIO_EVERYWORKDAY;
  586. if (opt.m_Daily.bEveryWeekDayOnly)
  587. opt.m_Daily.nIntervalDays = 1;
  588. else
  589. opt.m_Daily.nIntervalDays = m_nDayInterval;
  590. break;
  591. }
  592. case XTP_IDC_RADIO_WEEKLY:
  593. if (m_nWeeklyInterval < 1 || m_nWeeklyInterval > 999)
  594. {
  595. MsgBox_WrongValueRange(XTP_IDC_EDIT_WEEKLY_INTERVAL, 1, 999);
  596. return;
  597. }
  598. opt.m_nRecurrenceType = xtpCalendarRecurrenceWeekly;
  599. opt.m_Weekly.nIntervalWeeks = m_nWeeklyInterval;
  600. opt.m_Weekly.nDayOfWeekMask = 0;
  601. if (m_bMonday)
  602. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDayMonday;
  603. if (m_bTuesday)
  604. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDayTuesday;
  605. if (m_bWednesday)
  606. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDayWednesday;
  607. if (m_bThursday)
  608. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDayThursday;
  609. if (m_bFriday)
  610. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDayFriday;
  611. if (m_bSaturday)
  612. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDaySaturday;
  613. if (m_bSunday)
  614. opt.m_Weekly.nDayOfWeekMask |= xtpCalendarDaySunday;
  615. break;
  616. case XTP_IDC_RADIO_MONTHLY:
  617. if (GetCheckedRadioButton(XTP_IDC_RADIO_MONTH_RECUR, XTP_IDC_RADIO_MONTH_IN) ==
  618. XTP_IDC_RADIO_MONTH_RECUR)
  619. {
  620. if (m_nMonthInterval < 1 || m_nMonthInterval > 999)
  621. {
  622. MsgBox_WrongValueRange(XTP_IDC_EDIT_MONTH_MONTH, 1, 999);
  623. return;
  624. }
  625. if (m_MonthDate < 1 || m_MonthDate > 31)
  626. {
  627. MsgBox_WrongValueRange(XTP_IDC_EDIT_MONTH_DATE, 1, 31);
  628. return;
  629. }
  630. opt.m_nRecurrenceType = xtpCalendarRecurrenceMonthly;
  631. opt.m_Monthly.nIntervalMonths = m_nMonthInterval;
  632. opt.m_Monthly.nDayOfMonth = m_MonthDate;
  633. }
  634. else
  635. {
  636. if (m_nMonthInterval2 < 1 || m_nMonthInterval2 > 999)
  637. {
  638. MsgBox_WrongValueRange(XTP_IDC_EDIT_MONTH_MONTH2, 1, 999);
  639. return;
  640. }
  641. opt.m_MonthNth.nIntervalMonths = m_nMonthInterval2;
  642. opt.m_nRecurrenceType = xtpCalendarRecurrenceMonthNth;
  643. opt.m_MonthNth.nWhichDayMask = (int)m_wndCbMonthDay.GetItemData(m_wndCbMonthDay.GetCurSel());
  644. opt.m_MonthNth.nWhichDay = (int)m_wndCbMonthWhich.GetItemData(m_wndCbMonthWhich.GetCurSel());
  645. }
  646. break;
  647. case XTP_IDC_RADIO_YEARLY:
  648. opt.m_nRecurrenceType = xtpCalendarRecurrenceYearly;
  649. if (GetCheckedRadioButton(XTP_IDC_RADIO_YEAR_RECUR, XTP_IDC_RADIO_YEAR_IN) ==
  650. XTP_IDC_RADIO_YEAR_RECUR)
  651. {
  652. if (m_nDayOfMonth < 1 || m_nDayOfMonth > 31)
  653. {
  654. MsgBox_WrongValueRange(XTP_IDC_EDIT_YEAR_DATE, 1, 31);
  655. return;
  656. }
  657. opt.m_Yearly.nDayOfMonth = m_nDayOfMonth;
  658. opt.m_Yearly.nMonthOfYear = (int)m_wndYearMonth.GetItemData(m_wndYearMonth.GetCurSel());
  659. }
  660. else
  661. {
  662. opt.m_nRecurrenceType = xtpCalendarRecurrenceYearNth;
  663. opt.m_YearNth.nMonthOfYear = (int)m_wndComboYearMonth2.GetItemData(m_wndComboYearMonth2.GetCurSel());
  664. opt.m_YearNth.nWhichDay = (int)m_wndCbYearWhich.GetItemData(m_wndCbYearWhich.GetCurSel());
  665. opt.m_YearNth.nWhichDayMask = (int)m_wndCbYearDay.GetItemData(m_wndCbYearDay.GetCurSel());
  666. }
  667. break;
  668. }
  669. m_ptrPattern->SetRecurrenceOptions(opt);
  670. //-----------------------------------------------------------------------
  671. m_dtStartDate = CXTPCalendarUtils::ResetTime(m_dtStartDate);
  672. m_ptrPattern->SetPatternStartDate(m_dtStartDate);
  673. nRadio = GetCheckedRadioButton(XTP_IDC_RADIO_NOEND, XTP_IDC_RADIO_ENDBY);
  674. switch (nRadio)
  675. {
  676. case XTP_IDC_RADIO_ENDBY:
  677. if (m_dtEndDate < m_dtStartDate)
  678. {
  679. MsgBox_WrongValue(GetDlgItem(XTP_IDC_DATETIMEPICKER_ENDDATE));
  680. return;
  681. }
  682. m_ptrPattern->SetPatternEndDate(m_dtEndDate);
  683. break;
  684. case XTP_IDC_RADIO_ENDAFTER:
  685. if (m_nOccurNum < 1 || m_nOccurNum > 999)
  686. {
  687. MsgBox_WrongValueRange(XTP_IDC_EDIT_OCCUR, 1, 999);
  688. return;
  689. }
  690. m_ptrPattern->SetEndAfterOccurrences(m_nOccurNum);
  691. break;
  692. case XTP_IDC_RADIO_NOEND:
  693. m_ptrPattern->SetNoEndDate();
  694. break;
  695. }
  696. //-----------------------------------------------------------------------
  697. VERIFY(m_ptrMasterEvent->UpdateRecurrence(m_ptrPattern));
  698. CDialog::OnOK();
  699. }
  700. void CXTPCalendarEventRecurrenceDlg::OnBnClickedButtonRemoveRecurrence()
  701. {
  702. VERIFY(m_ptrMasterEvent->RemoveRecurrence());
  703. EndDialog(XTP_CALENDAR_DLGRESULT_REMOVE_RECURRENCE);
  704. }
  705. void CXTPCalendarEventRecurrenceDlg::OnBnClickedRadioDailyYearly(UINT nID)
  706. {
  707. ShowWindow(XTP_IDC_RADIO_EVERYDAY, FALSE);
  708. ShowWindow(XTP_IDC_RADIO_EVERYWORKDAY, FALSE);
  709. ShowWindow(XTP_IDC_EDIT_DAYINTERVAL, FALSE);
  710. ShowWindow(XTP_IDC_STATIC_DAY, FALSE);
  711. ShowWindow(XTP_IDC_STATIC_WEEKLY_RECEVERY, FALSE);
  712. ShowWindow(XTP_IDC_EDIT_WEEKLY_INTERVAL, FALSE);
  713. ShowWindow(XTP_IDC_STATIC_WEEKLY_FOLLDAYS, FALSE);
  714. ShowWindow(XTP_IDC_CHECK_MONDAY, FALSE);
  715. ShowWindow(XTP_IDC_CHECK_TUESDAY, FALSE);
  716. ShowWindow(XTP_IDC_CHECK_WEDNESDAY, FALSE);
  717. ShowWindow(XTP_IDC_CHECK_THURSDAY, FALSE);
  718. ShowWindow(XTP_IDC_CHECK_FRIDAY, FALSE);
  719. ShowWindow(XTP_IDC_CHECK_SATURDAY, FALSE);
  720. ShowWindow(XTP_IDC_CHECK_SUNDAY, FALSE);
  721. ShowWindow(XTP_IDC_RADIO_MONTH_RECUR, FALSE);
  722. ShowWindow(XTP_IDC_RADIO_MONTH_IN, FALSE);
  723. ShowWindow(XTP_IDC_EDIT_MONTH_DATE, FALSE);
  724. ShowWindow(XTP_IDC_STATIC_MONTH_NUMEVERY, FALSE);
  725. ShowWindow(XTP_IDC_EDIT_MONTH_MONTH, FALSE);
  726. ShowWindow(XTP_IDC_STATIC_MONTH_MONTH, FALSE);
  727. ShowWindow(XTP_IDC_COMBO_MONTH_CRIT, FALSE);
  728. ShowWindow(XTP_IDC_COMBO_MONTH_DAY, FALSE);
  729. ShowWindow(XTP_IDC_STATIC_MONTH_EVERY, FALSE);
  730. ShowWindow(XTP_IDC_EDIT_MONTH_MONTH2, FALSE);
  731. ShowWindow(XTP_IDC_STATIC_MONTH_MONTH2, FALSE);
  732. ShowWindow(XTP_IDC_RADIO_YEAR_RECUR, FALSE);
  733. ShowWindow(XTP_IDC_RADIO_YEAR_IN, FALSE);
  734. ShowWindow(XTP_IDC_EDIT_YEAR_DATE, FALSE);
  735. ShowWindow(XTP_IDC_COMBO_YEAR_MONTH, FALSE);
  736. ShowWindow(XTP_IDC_COMBO_YEAR_CRIT, FALSE);
  737. ShowWindow(XTP_IDC_COMBO_YEAR_DAY, FALSE);
  738. ShowWindow(XTP_IDC_COMBO_YEAR_MONTH2, FALSE);
  739. ShowWindow(XTP_IDC_STATIC_YEAR_OF, FALSE);
  740. switch (nID)
  741. {
  742. case XTP_IDC_RADIO_DAILY:
  743. ShowWindow(XTP_IDC_RADIO_EVERYDAY);
  744. ShowWindow(XTP_IDC_RADIO_EVERYWORKDAY);
  745. ShowWindow(XTP_IDC_EDIT_DAYINTERVAL);
  746. ShowWindow(XTP_IDC_STATIC_DAY);
  747. break;
  748. case XTP_IDC_RADIO_WEEKLY:
  749. ShowWindow(XTP_IDC_STATIC_WEEKLY_RECEVERY);
  750. ShowWindow(XTP_IDC_EDIT_WEEKLY_INTERVAL);
  751. ShowWindow(XTP_IDC_STATIC_WEEKLY_FOLLDAYS);
  752. ShowWindow(XTP_IDC_CHECK_MONDAY);
  753. ShowWindow(XTP_IDC_CHECK_TUESDAY);
  754. ShowWindow(XTP_IDC_CHECK_WEDNESDAY);
  755. ShowWindow(XTP_IDC_CHECK_THURSDAY);
  756. ShowWindow(XTP_IDC_CHECK_FRIDAY);
  757. ShowWindow(XTP_IDC_CHECK_SATURDAY);
  758. ShowWindow(XTP_IDC_CHECK_SUNDAY);
  759. break;
  760. case XTP_IDC_RADIO_MONTHLY:
  761. ShowWindow(XTP_IDC_RADIO_MONTH_RECUR);
  762. ShowWindow(XTP_IDC_RADIO_MONTH_IN);
  763. ShowWindow(XTP_IDC_EDIT_MONTH_DATE);
  764. ShowWindow(XTP_IDC_STATIC_MONTH_NUMEVERY);
  765. ShowWindow(XTP_IDC_EDIT_MONTH_MONTH);
  766. ShowWindow(XTP_IDC_STATIC_MONTH_MONTH);
  767. ShowWindow(XTP_IDC_COMBO_MONTH_CRIT);
  768. ShowWindow(XTP_IDC_COMBO_MONTH_DAY);
  769. ShowWindow(XTP_IDC_STATIC_MONTH_EVERY);
  770. ShowWindow(XTP_IDC_EDIT_MONTH_MONTH2);
  771. ShowWindow(XTP_IDC_STATIC_MONTH_MONTH2);
  772. break;
  773. case XTP_IDC_RADIO_YEARLY:
  774. ShowWindow(XTP_IDC_RADIO_YEAR_RECUR);
  775. ShowWindow(XTP_IDC_RADIO_YEAR_IN);
  776. ShowWindow(XTP_IDC_EDIT_YEAR_DATE);
  777. ShowWindow(XTP_IDC_COMBO_YEAR_MONTH);
  778. ShowWindow(XTP_IDC_COMBO_YEAR_CRIT);
  779. ShowWindow(XTP_IDC_COMBO_YEAR_DAY);
  780. ShowWindow(XTP_IDC_COMBO_YEAR_MONTH2);
  781. ShowWindow(XTP_IDC_STATIC_YEAR_OF);
  782. break;
  783. }
  784. }
  785. CRect CXTPCalendarEventRecurrenceDlg::GetCtrlRect(int nID)
  786. {
  787. ASSERT(GetDlgItem(nID));
  788. CRect rcRect(0, 0, 0, 0);
  789. if (GetDlgItem(nID))
  790. GetDlgItem(nID)->GetWindowRect(&rcRect);
  791. return rcRect;
  792. }
  793. void CXTPCalendarEventRecurrenceDlg::MoveWindow_Y(int nID, int nYOffset)
  794. {
  795. if (GetDlgItem(nID))
  796. {
  797. CRect rcRect = GetCtrlRect(nID);
  798. ScreenToClient(&rcRect);
  799. rcRect.top += nYOffset;
  800. rcRect.bottom += nYOffset;
  801. GetDlgItem(nID)->MoveWindow(rcRect);
  802. }
  803. else
  804. {
  805. ASSERT(FALSE);
  806. }
  807. }
  808. void CXTPCalendarEventRecurrenceDlg::_MoveControlsBy_Y()
  809. {
  810. CRect rcBase = GetCtrlRect(XTP_IDC_RADIO_DAILY);
  811. rcBase.top += 10;
  812. CRect rcBase2 = GetCtrlRect(XTP_IDC_RADIO_EVERYDAY);
  813. int nYOffset = rcBase.top - rcBase2.top;
  814. MoveWindow_Y(XTP_IDC_RADIO_EVERYDAY,    nYOffset);
  815. MoveWindow_Y(XTP_IDC_RADIO_EVERYWORKDAY,nYOffset);
  816. MoveWindow_Y(XTP_IDC_EDIT_DAYINTERVAL,  nYOffset);
  817. MoveWindow_Y(XTP_IDC_STATIC_DAY,        nYOffset);
  818. rcBase2 = GetCtrlRect(XTP_IDC_STATIC_WEEKLY_RECEVERY);
  819. nYOffset = rcBase.top - rcBase2.top;
  820. MoveWindow_Y(XTP_IDC_STATIC_WEEKLY_RECEVERY,nYOffset);
  821. MoveWindow_Y(XTP_IDC_EDIT_WEEKLY_INTERVAL,  nYOffset);
  822. MoveWindow_Y(XTP_IDC_STATIC_WEEKLY_FOLLDAYS,nYOffset);
  823. MoveWindow_Y(XTP_IDC_CHECK_MONDAY,          nYOffset);
  824. MoveWindow_Y(XTP_IDC_CHECK_TUESDAY,         nYOffset);
  825. MoveWindow_Y(XTP_IDC_CHECK_WEDNESDAY,       nYOffset);
  826. MoveWindow_Y(XTP_IDC_CHECK_THURSDAY,        nYOffset);
  827. MoveWindow_Y(XTP_IDC_CHECK_FRIDAY,          nYOffset);
  828. MoveWindow_Y(XTP_IDC_CHECK_SATURDAY,        nYOffset);
  829. MoveWindow_Y(XTP_IDC_CHECK_SUNDAY,          nYOffset);
  830. rcBase2 = GetCtrlRect(XTP_IDC_RADIO_MONTH_RECUR);
  831. nYOffset = rcBase.top - rcBase2.top;
  832. MoveWindow_Y(XTP_IDC_RADIO_MONTH_RECUR,     nYOffset);
  833. MoveWindow_Y(XTP_IDC_RADIO_MONTH_IN,        nYOffset);
  834. MoveWindow_Y(XTP_IDC_EDIT_MONTH_DATE,       nYOffset);
  835. MoveWindow_Y(XTP_IDC_STATIC_MONTH_NUMEVERY, nYOffset);
  836. MoveWindow_Y(XTP_IDC_EDIT_MONTH_MONTH,      nYOffset);
  837. MoveWindow_Y(XTP_IDC_STATIC_MONTH_MONTH,    nYOffset);
  838. MoveWindow_Y(XTP_IDC_COMBO_MONTH_CRIT,      nYOffset);
  839. MoveWindow_Y(XTP_IDC_COMBO_MONTH_DAY,       nYOffset);
  840. MoveWindow_Y(XTP_IDC_STATIC_MONTH_EVERY,    nYOffset);
  841. MoveWindow_Y(XTP_IDC_EDIT_MONTH_MONTH2,     nYOffset);
  842. MoveWindow_Y(XTP_IDC_STATIC_MONTH_MONTH2,   nYOffset);
  843. rcBase2 = GetCtrlRect(XTP_IDC_RADIO_YEAR_RECUR);
  844. nYOffset = rcBase.top - rcBase2.top;
  845. MoveWindow_Y(XTP_IDC_RADIO_YEAR_RECUR,  nYOffset);
  846. MoveWindow_Y(XTP_IDC_RADIO_YEAR_IN,     nYOffset);
  847. MoveWindow_Y(XTP_IDC_EDIT_YEAR_DATE,    nYOffset);
  848. MoveWindow_Y(XTP_IDC_COMBO_YEAR_MONTH,  nYOffset);
  849. MoveWindow_Y(XTP_IDC_COMBO_YEAR_CRIT,   nYOffset);
  850. MoveWindow_Y(XTP_IDC_COMBO_YEAR_DAY,    nYOffset);
  851. MoveWindow_Y(XTP_IDC_COMBO_YEAR_MONTH2, nYOffset);
  852. MoveWindow_Y(XTP_IDC_STATIC_YEAR_OF,    nYOffset);
  853. //------------------------------------------------------------------------
  854. CRect rcDialog;
  855. GetWindowRect(&rcDialog);
  856. CRect rcOK = GetCtrlRect(IDOK);
  857. rcDialog.bottom = rcOK.bottom + 10;
  858. SetWindowPos(NULL, 0, 0, rcDialog.Width(), rcDialog.Height(), SWP_NOMOVE | SWP_NOZORDER);
  859. }