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.

244 lines
5.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: selmonth.cxx
  7. //
  8. // Contents: Implementation of class to manage simple month-selection
  9. // dialog box.
  10. //
  11. // Classes: CSelectMonth
  12. //
  13. // History: 5-05-1997 DavidMun Created
  14. //
  15. //---------------------------------------------------------------------------
  16. #include "..\pch\headers.hxx"
  17. #pragma hdrstop
  18. #include <mstask.h>
  19. #include "dll.hxx"
  20. #include "dlg.hxx"
  21. #include "selmonth.hxx"
  22. #include "rc.h"
  23. #include "uiutil.hxx"
  24. #include "defines.hxx"
  25. #include "helpids.h"
  26. // Helpids for Select Months dialog
  27. const ULONG s_aSelectMonthDlgHelpIds[] =
  28. {
  29. select_month_dlg, Hselect_month_dlg,
  30. chk_jan, Hchk_jan,
  31. chk_feb, Hchk_feb,
  32. chk_mar, Hchk_mar,
  33. chk_apr, Hchk_apr,
  34. chk_may, Hchk_may,
  35. chk_jun, Hchk_jun,
  36. chk_jul, Hchk_jul,
  37. chk_aug, Hchk_aug,
  38. chk_sep, Hchk_sep,
  39. chk_oct, Hchk_oct,
  40. chk_nov, Hchk_nov,
  41. chk_dec, Hchk_dec,
  42. lbl_sel_months, Hlbl_sel_months,
  43. 0,0
  44. };
  45. extern "C" TCHAR szMstaskHelp[];
  46. //+--------------------------------------------------------------------------
  47. //
  48. // Member: CSelectMonth::InitSelectionFromTrigger
  49. //
  50. // Synopsis: Set selected bits from monthly trigger
  51. //
  52. // Arguments: [pjt] - pointer to trigger to modify, must be of type
  53. // TASK_TIME_TRIGGER_MONTHLYDATE or
  54. // TASK_TIME_TRIGGER_MONTHLYDOW.
  55. //
  56. // History: 07-18-1997 DavidMun Created
  57. //
  58. //---------------------------------------------------------------------------
  59. VOID
  60. CSelectMonth::InitSelectionFromTrigger(
  61. const TASK_TRIGGER *pjt)
  62. {
  63. if (pjt->TriggerType == TASK_TIME_TRIGGER_MONTHLYDATE)
  64. {
  65. _rgfMonths = pjt->Type.MonthlyDate.rgfMonths;
  66. }
  67. else
  68. {
  69. Win4Assert(pjt->TriggerType == TASK_TIME_TRIGGER_MONTHLYDOW);
  70. _rgfMonths = pjt->Type.MonthlyDOW.rgfMonths;
  71. }
  72. }
  73. //+--------------------------------------------------------------------------
  74. //
  75. // Member: CSelectMonth::UpdateTrigger
  76. //
  77. // Synopsis: Copy the dialog settings into the appropriate rgfMonths
  78. // field in [pjt].
  79. //
  80. // Arguments: [pjt] - pointer to trigger to modify.
  81. //
  82. // History: 07-18-1997 DavidMun Created
  83. //
  84. //---------------------------------------------------------------------------
  85. VOID
  86. CSelectMonth::UpdateTrigger(
  87. TASK_TRIGGER *pjt)
  88. {
  89. if (!_rgfMonths)
  90. {
  91. _rgfMonths = ALL_MONTHS;
  92. }
  93. if (pjt->TriggerType == TASK_TIME_TRIGGER_MONTHLYDATE)
  94. {
  95. pjt->Type.MonthlyDate.rgfMonths = _rgfMonths;
  96. }
  97. else
  98. {
  99. Win4Assert(pjt->TriggerType == TASK_TIME_TRIGGER_MONTHLYDOW);
  100. pjt->Type.MonthlyDOW.rgfMonths = _rgfMonths;
  101. }
  102. }
  103. //+--------------------------------------------------------------------------
  104. //
  105. // Member: CSelectMonth::RealDlgProc
  106. //
  107. // Synopsis: Dispatch to methods for specific messages.
  108. //
  109. // Arguments: standard windows dlg
  110. //
  111. // Returns: standard windows dlg
  112. //
  113. // Derivation: CDlg override
  114. //
  115. // History: 5-05-1997 DavidMun Created
  116. //
  117. //---------------------------------------------------------------------------
  118. INT_PTR
  119. CSelectMonth::RealDlgProc(
  120. UINT uMsg,
  121. WPARAM wParam,
  122. LPARAM lParam)
  123. {
  124. switch (uMsg)
  125. {
  126. case WM_INITDIALOG:
  127. _OnInit();
  128. break;
  129. case WM_COMMAND:
  130. switch (GET_WM_COMMAND_ID(wParam, lParam))
  131. {
  132. case IDOK:
  133. if (!_OnOK())
  134. {
  135. // tell user at least 1 month must be selected
  136. SchedUIErrorDialog(Hwnd(), IERR_INVALID_MONTHLY_TASK, 0);
  137. break;
  138. }
  139. // else FALL THROUGH
  140. case IDCANCEL:
  141. EndDialog(Hwnd(), GET_WM_COMMAND_ID(wParam, lParam) != IDCANCEL);
  142. break;
  143. }
  144. break;
  145. case WM_HELP:
  146. WinHelp((HWND) ((LPHELPINFO) lParam)->hItemHandle,
  147. szMstaskHelp,
  148. HELP_WM_HELP,
  149. (DWORD_PTR)(LPSTR)s_aSelectMonthDlgHelpIds);
  150. return TRUE;
  151. case WM_CONTEXTMENU:
  152. WinHelp((HWND) wParam,
  153. szMstaskHelp,
  154. HELP_CONTEXTMENU,
  155. (DWORD_PTR)(LPSTR)s_aSelectMonthDlgHelpIds);
  156. return TRUE;
  157. default:
  158. return FALSE;
  159. }
  160. return TRUE;
  161. }
  162. //+--------------------------------------------------------------------------
  163. //
  164. // Member: CSelectMonth::_OnInit
  165. //
  166. // Synopsis: Check boxes so they match flags in _flMonths
  167. //
  168. // History: 5-05-1997 DavidMun Created
  169. //
  170. //---------------------------------------------------------------------------
  171. VOID
  172. CSelectMonth::_OnInit()
  173. {
  174. ULONG id;
  175. for (id = chk_jan; id <= chk_dec; id++)
  176. {
  177. if (_rgfMonths & (1 << (id - chk_jan)))
  178. {
  179. CheckDlgButton(Hwnd(), id, BST_CHECKED);
  180. }
  181. }
  182. }
  183. //+--------------------------------------------------------------------------
  184. //
  185. // Member: CSelectMonth::_OnOK
  186. //
  187. // Synopsis: Map checked boxes to TASK_<month> bits in *_prgfMonths
  188. //
  189. // Returns: TRUE if at least one month is selected
  190. //
  191. // History: 5-05-1997 DavidMun Created
  192. //
  193. //---------------------------------------------------------------------------
  194. BOOL
  195. CSelectMonth::_OnOK()
  196. {
  197. ULONG id;
  198. _rgfMonths = 0;
  199. for (id = chk_jan; id <= chk_dec; id++)
  200. {
  201. if (IsDlgButtonChecked(Hwnd(), id))
  202. {
  203. _rgfMonths |= (1 << (id - chk_jan));
  204. }
  205. }
  206. return _rgfMonths != 0;
  207. }