Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

320 lines
7.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: weekly.cxx
  7. //
  8. // Contents: Task wizard weekly trigger property page implementation.
  9. //
  10. // Classes: CWeeklyPage
  11. //
  12. // History: 4-28-1997 DavidMun Created
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "..\pch\headers.hxx"
  16. #pragma hdrstop
  17. #include "myheaders.hxx"
  18. //
  19. // Constants
  20. //
  21. // NWEEKS_MIN - minimum value for weekly_nweeks_ud spin control
  22. // NWEEKS_MAX - maximum value for weekly_nweeks_ud spin control
  23. //
  24. #define NWEEKS_MIN 1
  25. #define NWEEKS_MAX 52
  26. //+--------------------------------------------------------------------------
  27. //
  28. // Member: CWeeklyPage::CWeeklyPage
  29. //
  30. // Synopsis: ctor
  31. //
  32. // Arguments: [ptszFolderPath] - full path to tasks folder with dummy
  33. // filename appended
  34. // [phPSP] - filled with prop page handle
  35. //
  36. // History: 4-28-1997 DavidMun Created
  37. //
  38. //---------------------------------------------------------------------------
  39. CWeeklyPage::CWeeklyPage(
  40. CTaskWizard *pParent,
  41. LPTSTR ptszFolderPath,
  42. HPROPSHEETPAGE *phPSP):
  43. CTriggerPage(IDD_WEEKLY,
  44. IDS_WEEKLY_HDR2,
  45. ptszFolderPath,
  46. phPSP)
  47. {
  48. TRACE_CONSTRUCTOR(CWeeklyPage);
  49. _flDaysOfTheWeek = 0;
  50. }
  51. //+--------------------------------------------------------------------------
  52. //
  53. // Member: CWeeklyPage::~CWeeklyPage
  54. //
  55. // Synopsis: dtor
  56. //
  57. // History: 4-28-1997 DavidMun Created
  58. //
  59. //---------------------------------------------------------------------------
  60. CWeeklyPage::~CWeeklyPage()
  61. {
  62. TRACE_DESTRUCTOR(CWeeklyPage);
  63. }
  64. //===========================================================================
  65. //
  66. // CWizPage overrides
  67. //
  68. //===========================================================================
  69. //+--------------------------------------------------------------------------
  70. //
  71. // Member: CWeeklyPage::_OnCommand
  72. //
  73. // Synopsis: Update internal state to match user's control changes
  74. //
  75. // Arguments: [id] - id of control changed
  76. // [hwndCtl] - hwnd of control changed
  77. // [codeNotify] - what happened to control
  78. //
  79. // Returns: 0 (handled) or 1 (not handled)
  80. //
  81. // History: 5-20-1997 DavidMun Created
  82. //
  83. //---------------------------------------------------------------------------
  84. LRESULT
  85. CWeeklyPage::_OnCommand(
  86. INT id,
  87. HWND hwndCtl,
  88. UINT codeNotify)
  89. {
  90. LRESULT lr = 0;
  91. switch (codeNotify)
  92. {
  93. case BN_CLICKED:
  94. switch (id)
  95. {
  96. case weekly_sunday_ckbox:
  97. _flDaysOfTheWeek ^= TASK_SUNDAY;
  98. break;
  99. case weekly_monday_ckbox:
  100. _flDaysOfTheWeek ^= TASK_MONDAY;
  101. break;
  102. case weekly_tuesday_ckbox:
  103. _flDaysOfTheWeek ^= TASK_TUESDAY;
  104. break;
  105. case weekly_wednesday_ckbox:
  106. _flDaysOfTheWeek ^= TASK_WEDNESDAY;
  107. break;
  108. case weekly_thursday_ckbox:
  109. _flDaysOfTheWeek ^= TASK_THURSDAY;
  110. break;
  111. case weekly_friday_ckbox:
  112. _flDaysOfTheWeek ^= TASK_FRIDAY;
  113. break;
  114. case weekly_saturday_ckbox:
  115. _flDaysOfTheWeek ^= TASK_SATURDAY;
  116. break;
  117. default:
  118. lr = 1;
  119. break;
  120. }
  121. _UpdateWizButtons();
  122. break;
  123. case EN_UPDATE:
  124. {
  125. //
  126. // If the user just pasted non-numeric text or an illegal numeric
  127. // value, overwrite it and complain.
  128. //
  129. INT iNewPos = GetDlgItemInt(Hwnd(), weekly_nweeks_edit, NULL, FALSE);
  130. if (iNewPos < NWEEKS_MIN || iNewPos > NWEEKS_MAX)
  131. {
  132. HWND hUD = _hCtrl(weekly_nweeks_ud);
  133. UpDown_SetPos(hUD, UpDown_GetPos(hUD));
  134. MessageBeep(MB_ICONASTERISK);
  135. }
  136. }
  137. default:
  138. lr = 1;
  139. break;
  140. }
  141. return lr;
  142. }
  143. //+--------------------------------------------------------------------------
  144. //
  145. // Member: CWeeklyPage::_OnInitDialog
  146. //
  147. // Synopsis: Perform initialization that should only occur once.
  148. //
  149. // Arguments: [lParam] - LPPROPSHEETPAGE used to create this page
  150. //
  151. // Returns: TRUE (let windows set focus)
  152. //
  153. // History: 5-20-1997 DavidMun Created
  154. //
  155. //---------------------------------------------------------------------------
  156. LRESULT
  157. CWeeklyPage::_OnInitDialog(
  158. LPARAM lParam)
  159. {
  160. TRACE_METHOD(CWeeklyPage, _OnInitDialog);
  161. _UpdateTimeFormat();
  162. UpDown_SetRange(_hCtrl(weekly_nweeks_ud), NWEEKS_MIN, NWEEKS_MAX);
  163. UpDown_SetPos(_hCtrl(weekly_nweeks_ud), 1);
  164. Edit_LimitText(_hCtrl(weekly_nweeks_edit), 2);
  165. Button_SetCheck(_hCtrl(_idSelectedRadio), BST_CHECKED);
  166. return TRUE;
  167. }
  168. //+--------------------------------------------------------------------------
  169. //
  170. // Member: CWeeklyPage::_OnPSNSetActive
  171. //
  172. // Synopsis: Enable the Next button only if this page has valid data
  173. //
  174. // History: 5-20-1997 DavidMun Created
  175. //
  176. //---------------------------------------------------------------------------
  177. LRESULT
  178. CWeeklyPage::_OnPSNSetActive(
  179. LPARAM lParam)
  180. {
  181. _UpdateWizButtons();
  182. return CPropPage::_OnPSNSetActive(lParam);
  183. }
  184. //===========================================================================
  185. //
  186. // CTriggerPage overrides
  187. //
  188. //===========================================================================
  189. //+--------------------------------------------------------------------------
  190. //
  191. // Member: CWeeklyPage::FillInTrigger
  192. //
  193. // Synopsis: Fill in the fields of the trigger structure according to the
  194. // settings specified for this type of trigger
  195. //
  196. // Arguments: [pTrigger] - trigger struct to fill in
  197. //
  198. // Modifies: *[pTrigger]
  199. //
  200. // History: 5-06-1997 DavidMun Created
  201. //
  202. // Notes: Precondition is that trigger's cbTriggerSize member is
  203. // initialized.
  204. //
  205. //---------------------------------------------------------------------------
  206. VOID
  207. CWeeklyPage::FillInTrigger(
  208. TASK_TRIGGER *pTrigger)
  209. {
  210. pTrigger->TriggerType = TASK_TIME_TRIGGER_WEEKLY;
  211. pTrigger->Type.Weekly.WeeksInterval =
  212. UpDown_GetPos(_hCtrl(weekly_nweeks_ud));
  213. DEBUG_ASSERT(pTrigger->Type.Weekly.WeeksInterval);
  214. DEBUG_ASSERT(_flDaysOfTheWeek);
  215. pTrigger->Type.Weekly.rgfDaysOfTheWeek = _flDaysOfTheWeek;
  216. SYSTEMTIME st;
  217. GetLocalTime(&st);
  218. pTrigger->wBeginYear = st.wYear;
  219. pTrigger->wBeginMonth = st.wMonth;
  220. pTrigger->wBeginDay = st.wDay;
  221. DateTime_GetSystemtime(_hCtrl(starttime_dp), &st);
  222. pTrigger->wStartHour = st.wHour;
  223. pTrigger->wStartMinute = st.wMinute;
  224. }
  225. //===========================================================================
  226. //
  227. // New methods
  228. //
  229. //===========================================================================
  230. //+--------------------------------------------------------------------------
  231. //
  232. // Member: CWeeklyPage::_UpdateWizButtons
  233. //
  234. // Synopsis: Enable the Next control if page data is valid
  235. //
  236. // History: 5-20-1997 DavidMun Created
  237. //
  238. //---------------------------------------------------------------------------
  239. VOID
  240. CWeeklyPage::_UpdateWizButtons()
  241. {
  242. //
  243. // Enable Next if user has selected which weeks to run on and picked
  244. // days of the week to run on.
  245. //
  246. if (_flDaysOfTheWeek)
  247. {
  248. _SetWizButtons(PSWIZB_BACK | PSWIZB_NEXT);
  249. }
  250. else
  251. {
  252. _SetWizButtons(PSWIZB_BACK);
  253. }
  254. }