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.

307 lines
7.4 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: daily.cxx
  7. //
  8. // Contents: Task wizard daily trigger property page implementation.
  9. //
  10. // Classes: CDailyPage
  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. // NDAYS_MIN - minimum value for daily_ndays_ud spin control
  22. // NDAYS_MAX - maximum value for daily_ndays_ud spin control
  23. //
  24. #define NDAYS_MIN 1
  25. #define NDAYS_MAX 365
  26. #define TASK_WEEKDAYS (TASK_MONDAY | \
  27. TASK_TUESDAY | \
  28. TASK_WEDNESDAY | \
  29. TASK_THURSDAY | \
  30. TASK_FRIDAY)
  31. //+--------------------------------------------------------------------------
  32. //
  33. // Member: CDailyPage::CDailyPage
  34. //
  35. // Synopsis: ctor
  36. //
  37. // Arguments: [ptszFolderPath] - full path to tasks folder with dummy
  38. // filename appended
  39. // [phPSP] - filled with prop page handle
  40. //
  41. // History: 4-28-1997 DavidMun Created
  42. //
  43. //---------------------------------------------------------------------------
  44. CDailyPage::CDailyPage(
  45. CTaskWizard *pParent,
  46. LPTSTR ptszFolderPath,
  47. HPROPSHEETPAGE *phPSP):
  48. CTriggerPage(IDD_DAILY,
  49. IDS_DAILY_HDR2,
  50. ptszFolderPath,
  51. phPSP)
  52. {
  53. TRACE_CONSTRUCTOR(CDailyPage);
  54. _idSelectedRadio = 0;
  55. }
  56. //+--------------------------------------------------------------------------
  57. //
  58. // Member: CDailyPage::~CDailyPage
  59. //
  60. // Synopsis: dtor
  61. //
  62. // History: 4-28-1997 DavidMun Created
  63. //
  64. //---------------------------------------------------------------------------
  65. CDailyPage::~CDailyPage()
  66. {
  67. TRACE_DESTRUCTOR(CDailyPage);
  68. }
  69. //===========================================================================
  70. //
  71. // CPropPage overrides
  72. //
  73. //===========================================================================
  74. //+--------------------------------------------------------------------------
  75. //
  76. // Member: CDailyPage::_OnCommand
  77. //
  78. // Synopsis: Handle user input
  79. //
  80. // Arguments: [id] - resource id of control affected
  81. // [hwndCtl] - window handle of control affected
  82. // [codeNotify] - indicates what happened to control
  83. //
  84. // Returns: 0 (handled), 1 (not handled)
  85. //
  86. // History: 5-20-1997 DavidMun Created
  87. //
  88. //---------------------------------------------------------------------------
  89. LRESULT
  90. CDailyPage::_OnCommand(
  91. INT id,
  92. HWND hwndCtl,
  93. UINT codeNotify)
  94. {
  95. LRESULT lr = 0;
  96. switch (codeNotify)
  97. {
  98. case BN_CLICKED:
  99. switch (id)
  100. {
  101. case daily_day_rb:
  102. case daily_weekday_rb:
  103. case daily_ndays_rb:
  104. _idSelectedRadio = (USHORT) id;
  105. _EnableNDaysControls(id == daily_ndays_rb);
  106. break;
  107. default:
  108. lr = 1;
  109. break;
  110. }
  111. break;
  112. case EN_UPDATE:
  113. {
  114. //
  115. // If the user just pasted non-numeric text or an illegal numeric
  116. // value, overwrite it and complain.
  117. //
  118. INT iNewPos = GetDlgItemInt(Hwnd(), daily_ndays_edit, NULL, FALSE);
  119. if (iNewPos < NDAYS_MIN || iNewPos > NDAYS_MAX)
  120. {
  121. HWND hUD = _hCtrl(daily_ndays_ud);
  122. UpDown_SetPos(hUD, UpDown_GetPos(hUD));
  123. MessageBeep(MB_ICONASTERISK);
  124. }
  125. }
  126. default:
  127. lr = 1;
  128. break;
  129. }
  130. return lr;
  131. }
  132. //===========================================================================
  133. //
  134. // CWizPage overrides
  135. //
  136. //===========================================================================
  137. //+--------------------------------------------------------------------------
  138. //
  139. // Member: CDailyPage::_OnInitDialog
  140. //
  141. // Synopsis: Perform initialization that should only occur once.
  142. //
  143. // Arguments: [lParam] - LPPROPSHEETPAGE used to create this page
  144. //
  145. // Returns: TRUE (let windows set focus)
  146. //
  147. // History: 5-20-1997 DavidMun Created
  148. //
  149. //---------------------------------------------------------------------------
  150. LRESULT
  151. CDailyPage::_OnInitDialog(
  152. LPARAM lParam)
  153. {
  154. TRACE_METHOD(CDailyPage, _OnInitDialog);
  155. _UpdateTimeFormat();
  156. _idSelectedRadio = daily_day_rb;
  157. CheckDlgButton(Hwnd(), _idSelectedRadio, BST_CHECKED);
  158. _EnableNDaysControls(FALSE);
  159. UpDown_SetRange(_hCtrl(daily_ndays_ud), NDAYS_MIN, NDAYS_MAX);
  160. UpDown_SetPos(_hCtrl(daily_ndays_ud), 1);
  161. Edit_LimitText(_hCtrl(daily_ndays_edit), 3);
  162. return TRUE;
  163. }
  164. //+--------------------------------------------------------------------------
  165. //
  166. // Member: CDailyPage::_OnPSNSetActive
  167. //
  168. // Synopsis: Enable the back and next buttons, since this page cannot
  169. // have invalid data
  170. //
  171. // History: 5-20-1997 DavidMun Created
  172. //
  173. //---------------------------------------------------------------------------
  174. LRESULT
  175. CDailyPage::_OnPSNSetActive(
  176. LPARAM lParam)
  177. {
  178. _SetWizButtons(PSWIZB_BACK | PSWIZB_NEXT);
  179. return CPropPage::_OnPSNSetActive(lParam);
  180. }
  181. //+--------------------------------------------------------------------------
  182. //
  183. // Member: CDailyPage::_EnableNDaysControls
  184. //
  185. // Synopsis: Enable or disable the 'run every n days' controls
  186. //
  187. // History: 5-20-1997 DavidMun Created
  188. //
  189. //---------------------------------------------------------------------------
  190. VOID
  191. CDailyPage::_EnableNDaysControls(
  192. BOOL fEnable)
  193. {
  194. EnableWindow(_hCtrl(daily_ndays_ud), fEnable);
  195. EnableWindow(_hCtrl(daily_ndays_edit), fEnable);
  196. EnableWindow(_hCtrl(daily_ndays_lbl), fEnable);
  197. }
  198. //===========================================================================
  199. //
  200. // CTriggerPage overrides
  201. //
  202. //===========================================================================
  203. //+--------------------------------------------------------------------------
  204. //
  205. // Member: CDailyPage::FillInTrigger
  206. //
  207. // Synopsis: Fill in the fields of the trigger structure according to the
  208. // settings specified for this type of trigger
  209. //
  210. // Arguments: [pTrigger] - trigger struct to fill in
  211. //
  212. // Modifies: *[pTrigger]
  213. //
  214. // History: 5-06-1997 DavidMun Created
  215. //
  216. // Notes: Precondition is that trigger's cbTriggerSize member is
  217. // initialized.
  218. //
  219. //---------------------------------------------------------------------------
  220. VOID
  221. CDailyPage::FillInTrigger(
  222. TASK_TRIGGER *pTrigger)
  223. {
  224. switch (_idSelectedRadio)
  225. {
  226. case daily_day_rb:
  227. pTrigger->TriggerType = TASK_TIME_TRIGGER_DAILY;
  228. pTrigger->Type.Daily.DaysInterval = 1;
  229. break;
  230. case daily_weekday_rb:
  231. pTrigger->TriggerType = TASK_TIME_TRIGGER_WEEKLY;
  232. pTrigger->Type.Weekly.WeeksInterval = 1;
  233. pTrigger->Type.Weekly.rgfDaysOfTheWeek = TASK_WEEKDAYS;
  234. break;
  235. case daily_ndays_rb:
  236. pTrigger->TriggerType = TASK_TIME_TRIGGER_DAILY;
  237. pTrigger->Type.Daily.DaysInterval =
  238. UpDown_GetPos(_hCtrl(daily_ndays_ud));
  239. break;
  240. default:
  241. DEBUG_ASSERT(FALSE);
  242. break;
  243. }
  244. FillInStartDateTime(_hCtrl(startdate_dp), _hCtrl(starttime_dp), pTrigger);
  245. }