Leaked source code of windows server 2003
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
8.9 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. INT_PTR 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(m_psp));
  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 = SchedWizardDailyDlgProc;
  177. m_psp.lParam = 0;
  178. m_pISyncSched = pISyncSched;
  179. m_pISyncSched->AddRef();
  180. g_pDailyPage = this;
  181. m_idSelectedRadio = 0;
  182. *phPSP = CreatePropertySheetPage(&m_psp);
  183. }
  184. //+--------------------------------------------------------------------------
  185. //
  186. // Member: CSelectDailyPage::Initialize(HWND hwnd)
  187. //
  188. // Synopsis: initialize the welcome page and set the task name to a unique
  189. // new onestop name
  190. //
  191. // History: 11-21-1997 SusiA
  192. //
  193. //---------------------------------------------------------------------------
  194. BOOL CSelectDailyPage::Initialize(HWND hwnd)
  195. {
  196. m_hwnd = hwnd;
  197. UpdateTimeFormat(m_tszTimeFormat, ARRAYSIZE(m_tszTimeFormat));
  198. DateTime_SetFormat(GetDlgItem(m_hwnd,starttime_dp), m_tszTimeFormat);
  199. m_idSelectedRadio = daily_day_rb;
  200. CheckDlgButton(m_hwnd, m_idSelectedRadio, BST_CHECKED);
  201. EnableNDaysControls(FALSE);
  202. UpDown_SetRange(GetDlgItem(m_hwnd,daily_ndays_ud), NDAYS_MIN, NDAYS_MAX);
  203. UpDown_SetPos(GetDlgItem(m_hwnd,daily_ndays_ud), 7);
  204. Edit_LimitText(GetDlgItem(m_hwnd,daily_ndays_edit), 3);
  205. return TRUE;
  206. }
  207. //+--------------------------------------------------------------------------
  208. //
  209. // Member: CSelectDailyPage::FillInTrigger
  210. //
  211. // Synopsis: Fill in the fields of the trigger structure according to the
  212. // settings specified for this type of trigger
  213. //
  214. // Arguments: [pTrigger] - trigger struct to fill in
  215. //
  216. // Modifies: *[pTrigger]
  217. //
  218. // History: 12-08-1997 SusiA Stole from the TaskScheduler
  219. //
  220. // Notes: Precondition is that trigger's cbTriggerSize member is
  221. // initialized.
  222. //
  223. //---------------------------------------------------------------------------
  224. BOOL CSelectDailyPage::SetITrigger()
  225. {
  226. TASK_TRIGGER Trigger;
  227. ITaskTrigger *pITrigger;
  228. if (FAILED(m_pISyncSched->GetTrigger(&pITrigger)))
  229. {
  230. return FALSE;
  231. }
  232. ZeroMemory(&Trigger, sizeof(Trigger));
  233. Trigger.cbTriggerSize = sizeof(TASK_TRIGGER);
  234. switch (m_idSelectedRadio)
  235. {
  236. case daily_day_rb:
  237. Trigger.TriggerType = TASK_TIME_TRIGGER_DAILY;
  238. Trigger.Type.Daily.DaysInterval = 1;
  239. break;
  240. case daily_weekday_rb:
  241. Trigger.TriggerType = TASK_TIME_TRIGGER_WEEKLY;
  242. Trigger.Type.Weekly.WeeksInterval = 1;
  243. Trigger.Type.Weekly.rgfDaysOfTheWeek = TASK_WEEKDAYS;
  244. break;
  245. case daily_ndays_rb:
  246. Trigger.TriggerType = TASK_TIME_TRIGGER_DAILY;
  247. Trigger.Type.Daily.DaysInterval =
  248. UpDown_GetPos(GetDlgItem(m_hwnd, daily_ndays_ud));
  249. break;
  250. default:
  251. break;
  252. }
  253. FillInStartDateTime(GetDlgItem(m_hwnd,startdate_dp),
  254. GetDlgItem(m_hwnd,starttime_dp), &Trigger);
  255. if (ERROR_SUCCESS == pITrigger->SetTrigger(&Trigger))
  256. {
  257. return TRUE;
  258. }
  259. else
  260. {
  261. return FALSE;
  262. }
  263. }