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.

324 lines
7.7 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1996.
  5. //
  6. // File: daily.cxx
  7. //
  8. // Contents: Task wizard Onestop daily selection property page implementation.
  9. //
  10. // Classes: CSelectDailyPage
  11. //
  12. // History: 11-21-1997 SusiA
  13. //
  14. //---------------------------------------------------------------------------
  15. #include "precomp.h"
  16. CSelectDailyPage *g_pDailyPage = NULL;
  17. extern CSelectItemsPage *g_pSelectItemsPage;
  18. //+-------------------------------------------------------------------------------
  19. // FUNCTION: SchedWizardDailyDlgProc(HWND, UINT, WPARAM, LPARAM)
  20. //
  21. // PURPOSE: Callback dialog procedure for the property page
  22. //
  23. // PARAMETERS:
  24. // hDlg - Dialog box window handle
  25. // uMessage - current message
  26. // wParam - depends on message
  27. // lParam - depends on message
  28. //
  29. // RETURN VALUE:
  30. //
  31. // Depends on message. In general, return TRUE if we process it.
  32. //
  33. // COMMENTS:
  34. //
  35. // HISTORY: 12-08-1997 SusiA Created
  36. //
  37. //--------------------------------------------------------------------------------
  38. BOOL CALLBACK SchedWizardDailyDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
  39. {
  40. WORD wNotifyCode = HIWORD(wParam); // notification code
  41. switch (uMessage)
  42. {
  43. case WM_INITDIALOG:
  44. if (g_pDailyPage)
  45. g_pDailyPage->Initialize(hDlg);
  46. InitPage(hDlg,lParam);
  47. break;
  48. case WM_PAINT:
  49. WmPaint(hDlg, uMessage, wParam, lParam);
  50. break;
  51. case WM_PALETTECHANGED:
  52. WmPaletteChanged(hDlg, wParam);
  53. break;
  54. case WM_QUERYNEWPALETTE:
  55. return( WmQueryNewPalette(hDlg) );
  56. break;
  57. case WM_ACTIVATE:
  58. return( WmActivate(hDlg, wParam, lParam) );
  59. break;
  60. case WM_COMMAND:
  61. return g_pDailyPage->OnCommand(hDlg,
  62. LOWORD(wParam), // item, control, or acce
  63. HIWORD(wParam)); // notification code
  64. break;
  65. case WM_NOTIFY:
  66. switch (((NMHDR FAR *) lParam)->code)
  67. {
  68. case PSN_KILLACTIVE:
  69. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
  70. return 1;
  71. break;
  72. case PSN_RESET:
  73. // reset to the original values
  74. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
  75. break;
  76. case PSN_SETACTIVE:
  77. PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  78. break;
  79. case PSN_WIZNEXT:
  80. break;
  81. default:
  82. return FALSE;
  83. }
  84. break;
  85. default:
  86. return FALSE;
  87. }
  88. return TRUE;
  89. }
  90. //+--------------------------------------------------------------------------
  91. //
  92. // Member: CSelectDailyPage::OnCommand
  93. //
  94. // Synopsis: Handle the WM_COMMAND for the daily page
  95. //
  96. // History: 12-08-1997 SusiA
  97. //
  98. //---------------------------------------------------------------------------
  99. BOOL CSelectDailyPage::OnCommand(HWND hwnd, WORD wID, WORD wNotifyCode)
  100. {
  101. switch (wNotifyCode)
  102. {
  103. case BN_CLICKED:
  104. switch (wID)
  105. {
  106. case daily_day_rb:
  107. case daily_weekday_rb:
  108. case daily_ndays_rb:
  109. m_idSelectedRadio = (USHORT) wID;
  110. EnableNDaysControls(wID == daily_ndays_rb);
  111. break;
  112. default:
  113. break;
  114. }
  115. break;
  116. case EN_UPDATE:
  117. {
  118. //
  119. // If the user just pasted non-numeric text or an illegal numeric
  120. // value, overwrite it and complain.
  121. //
  122. if (IsWindowEnabled(GetDlgItem(hwnd,daily_ndays_edit)))
  123. {
  124. INT iNewPos = GetDlgItemInt(hwnd, daily_ndays_edit, NULL, FALSE);
  125. if (iNewPos < NDAYS_MIN || iNewPos > NDAYS_MAX)
  126. {
  127. HWND hUD = GetDlgItem(hwnd,daily_ndays_ud);
  128. UpDown_SetPos(hUD, UpDown_GetPos(hUD));
  129. MessageBeep(MB_ICONASTERISK);
  130. }
  131. }
  132. }
  133. default:
  134. break;
  135. break;
  136. }
  137. return TRUE;
  138. }
  139. //+--------------------------------------------------------------------------
  140. //
  141. // Member: CSelectDailyPage::EnableNDaysControls
  142. //
  143. // Synopsis: Enable or disable the 'run every n days' controls
  144. //
  145. // History: 12-05-1997 SusiA Created
  146. //
  147. //---------------------------------------------------------------------------
  148. VOID CSelectDailyPage::EnableNDaysControls(BOOL fEnable)
  149. {
  150. EnableWindow(GetDlgItem(m_hwnd,daily_ndays_ud), fEnable);
  151. EnableWindow(GetDlgItem(m_hwnd,daily_ndays_edit), fEnable);
  152. EnableWindow(GetDlgItem(m_hwnd,daily_ndays_lable), fEnable);
  153. }
  154. //+--------------------------------------------------------------------------
  155. //
  156. // Member: CSelectDailyPage::CSelectDailyPage
  157. //
  158. // Synopsis: ctor
  159. //
  160. // [phPSP] - filled with prop page handle
  161. //
  162. // History: 11-21-1997 SusiA
  163. //
  164. //---------------------------------------------------------------------------
  165. CSelectDailyPage::CSelectDailyPage(
  166. HINSTANCE hinst,
  167. ISyncSchedule *pISyncSched,
  168. HPROPSHEETPAGE *phPSP)
  169. {
  170. ZeroMemory(&m_psp, sizeof(PROPSHEETPAGE));
  171. m_psp.dwSize = sizeof (PROPSHEETPAGE);
  172. m_psp.hInstance = hinst;
  173. m_psp.dwFlags = PSP_DEFAULT;
  174. m_psp.pszTemplate = MAKEINTRESOURCE(IDD_SCHEDWIZ_DAILY);
  175. m_psp.pszIcon = NULL;
  176. m_psp.pfnDlgProc = (DLGPROC) SchedWizardDailyDlgProc;
  177. m_psp.lParam = 0;
  178. m_pISyncSched = pISyncSched;
  179. m_pISyncSched->AddRef();
  180. g_pDailyPage = this;
  181. #ifdef WIZARD97
  182. m_psp.dwFlags |= PSP_HIDEHEADER;
  183. #endif // WIZARD97
  184. m_idSelectedRadio = 0;
  185. *phPSP = CreatePropertySheetPage(&m_psp);
  186. }
  187. //+--------------------------------------------------------------------------
  188. //
  189. // Member: CSelectDailyPage::Initialize(HWND hwnd)
  190. //
  191. // Synopsis: initialize the welcome page and set the task name to a unique
  192. // new onestop name
  193. //
  194. // History: 11-21-1997 SusiA
  195. //
  196. //---------------------------------------------------------------------------
  197. BOOL CSelectDailyPage::Initialize(HWND hwnd)
  198. {
  199. m_hwnd = hwnd;
  200. UpdateTimeFormat(m_tszTimeFormat, ARRAYLEN(m_tszTimeFormat));
  201. DateTime_SetFormat(GetDlgItem(m_hwnd,starttime_dp), m_tszTimeFormat);
  202. m_idSelectedRadio = daily_day_rb;
  203. CheckDlgButton(m_hwnd, m_idSelectedRadio, BST_CHECKED);
  204. EnableNDaysControls(FALSE);
  205. UpDown_SetRange(GetDlgItem(m_hwnd,daily_ndays_ud), NDAYS_MIN, NDAYS_MAX);
  206. UpDown_SetPos(GetDlgItem(m_hwnd,daily_ndays_ud), 7);
  207. Edit_LimitText(GetDlgItem(m_hwnd,daily_ndays_edit), 3);
  208. return TRUE;
  209. }
  210. //+--------------------------------------------------------------------------
  211. //
  212. // Member: CSelectDailyPage::FillInTrigger
  213. //
  214. // Synopsis: Fill in the fields of the trigger structure according to the
  215. // settings specified for this type of trigger
  216. //
  217. // Arguments: [pTrigger] - trigger struct to fill in
  218. //
  219. // Modifies: *[pTrigger]
  220. //
  221. // History: 12-08-1997 SusiA Stole from the TaskScheduler
  222. //
  223. // Notes: Precondition is that trigger's cbTriggerSize member is
  224. // initialized.
  225. //
  226. //---------------------------------------------------------------------------
  227. BOOL CSelectDailyPage::SetITrigger()
  228. {
  229. TASK_TRIGGER Trigger;
  230. ITaskTrigger *pITrigger;
  231. if (FAILED(m_pISyncSched->GetTrigger(&pITrigger)))
  232. {
  233. return FALSE;
  234. }
  235. ZeroMemory(&Trigger, sizeof(Trigger));
  236. Trigger.cbTriggerSize = sizeof(TASK_TRIGGER);
  237. switch (m_idSelectedRadio)
  238. {
  239. case daily_day_rb:
  240. Trigger.TriggerType = TASK_TIME_TRIGGER_DAILY;
  241. Trigger.Type.Daily.DaysInterval = 1;
  242. break;
  243. case daily_weekday_rb:
  244. Trigger.TriggerType = TASK_TIME_TRIGGER_WEEKLY;
  245. Trigger.Type.Weekly.WeeksInterval = 1;
  246. Trigger.Type.Weekly.rgfDaysOfTheWeek = TASK_WEEKDAYS;
  247. break;
  248. case daily_ndays_rb:
  249. Trigger.TriggerType = TASK_TIME_TRIGGER_DAILY;
  250. Trigger.Type.Daily.DaysInterval =
  251. UpDown_GetPos(GetDlgItem(m_hwnd, daily_ndays_ud));
  252. break;
  253. default:
  254. break;
  255. }
  256. FillInStartDateTime(GetDlgItem(m_hwnd,startdate_dp),
  257. GetDlgItem(m_hwnd,starttime_dp), &Trigger);
  258. if (ERROR_SUCCESS == pITrigger->SetTrigger(&Trigger))
  259. {
  260. return TRUE;
  261. }
  262. else
  263. {
  264. return FALSE;
  265. }
  266. }