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.

312 lines
8.5 KiB

  1. #include "pch.h"
  2. #include "link.h"
  3. #pragma hdrstop
  4. #define AU_ITEMS TEXT("AutoUpdateItems")
  5. void EnableRestoreControls(HWND hWnd, BOOL fEnable)
  6. {
  7. EnableWindow(GetDlgItem(hWnd, IDC_RESTOREHIDDEN), fEnable);
  8. EnableWindow(GetDlgItem(hWnd, IDC_TEXT_HIDDEN1), fEnable);
  9. EnableWindow(GetDlgItem(hWnd, IDC_TEXT_HIDDEN2), fEnable);
  10. }
  11. CSysLink g_SettingsAutoUpdatelink;
  12. CSysLink g_SettingsScheduledInstalllink;
  13. BOOL EnableCombo(HWND hwnd, BOOL bState);
  14. BOOL EnableOptions(HWND hwnd, BOOL bState);
  15. //BOOL FillDaysCombo(HWND hwnd, DWORD dwSchedInstallDay);
  16. //BOOL FillHrsCombo(HWND hwnd, DWORD dwSchedInstallTime);
  17. void OnKeepUptoDate(HWND hwnd);
  18. void MYREInit(HWND hDlg, UINT uId, HFONT hFont);
  19. void LaunchLinkAction(HWND hwnd, UINT uCtrlId);
  20. #ifdef TESTUI
  21. #if 0
  22. void SetServiceOption(
  23. DWORD dwOption,
  24. DWORD dwDay,
  25. DWORD dwTime
  26. );
  27. void GetServiceOption(
  28. LPDWORD lpdwOption,
  29. LPDWORD lpdwDay,
  30. LPDWORD lpdwTime
  31. );
  32. #endif
  33. #endif
  34. void GetDayAndTimeFromUI(
  35. HWND hWnd,
  36. LPDWORD lpdwDay,
  37. LPDWORD lpdwTime
  38. );
  39. INT_PTR CALLBACK _DlgRestoreProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  40. {
  41. switch(message)
  42. {
  43. case WM_INITDIALOG:
  44. {
  45. HWND hwndOwner;
  46. RECT rc, rcDlg, rcOwner;
  47. // Get the owner window and dialog box rectangles.
  48. if ((hwndOwner = GetParent(hwnd)) == NULL)
  49. {
  50. hwndOwner = GetDesktopWindow();
  51. }
  52. GetWindowRect(hwndOwner, &rcOwner);
  53. GetWindowRect(hwnd, &rcDlg);
  54. CopyRect(&rc, &rcOwner);
  55. // Offset the owner and dialog box rectangles so that
  56. // right and bottom values represent the width and
  57. // height, and then offset the owner again to discard
  58. // space taken up by the dialog box.
  59. OffsetRect(&rcDlg, -rcDlg.left, -rcDlg.top);
  60. OffsetRect(&rc, -rc.left, -rc.top);
  61. OffsetRect(&rc, -rcDlg.right, -rcDlg.bottom);
  62. // The new position is the sum of half the remaining
  63. // space and the owner's original position.
  64. SetWindowPos(hwnd,
  65. HWND_TOP,
  66. rcOwner.left + (rc.right / 2),
  67. rcOwner.top + (rc.bottom / 2),
  68. 0, 0, // ignores size arguments
  69. SWP_NOSIZE);
  70. }
  71. return TRUE;
  72. case WM_COMMAND:
  73. switch(LOWORD(wParam))
  74. {
  75. case IDOK:
  76. EndDialog(hwnd, TRUE);
  77. return TRUE;
  78. case IDCANCEL:
  79. EndDialog(hwnd, FALSE);
  80. return TRUE;
  81. }
  82. }
  83. return FALSE;
  84. }
  85. LONG SetSettingsColors(HDC hdc, HWND control)
  86. {
  87. SetBkMode(hdc, TRANSPARENT);
  88. return PtrToLong(GetStockObject( HOLLOW_BRUSH ));
  89. }
  90. INT_PTR CALLBACK SettingsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  91. {
  92. static HWND oldCurrentDialog;
  93. // DWORD dwOption = AUOPTION_INSTALLONLY_NOTIFY;
  94. // DWORD dwScheduledInstallDay = -1;
  95. // DWORD dwScheduledInstallTime = -1;
  96. AUOPTION auopt;
  97. auopt.dwOption = AUOPTION_INSTALLONLY_NOTIFY;
  98. auopt.dwSchedInstallDay = -1;
  99. auopt.dwSchedInstallTime = -1;
  100. switch(message)
  101. {
  102. case WM_INITDIALOG:
  103. {
  104. oldCurrentDialog = ghCurrentDialog;
  105. ghCurrentDialog = hWnd;
  106. gTopWins.Add(hWnd);
  107. EnableCombo(hWnd, FALSE); //Initially disabled
  108. #ifndef TESTUI
  109. if (FAILED(gInternals->m_getServiceOption(&auopt)))
  110. {
  111. QUITAUClient();
  112. return TRUE;
  113. }
  114. #else
  115. #endif
  116. g_SettingsAutoUpdatelink.SetSysLinkInstanceHandle(ghInstance);
  117. g_SettingsAutoUpdatelink.SubClassWindow(GetDlgItem(hWnd,IDC_STAT_LEARNAUTOUPDATE));
  118. g_SettingsAutoUpdatelink.SetHyperLink(gtszAUOverviewUrl);
  119. g_SettingsAutoUpdatelink.Invalidate();
  120. g_SettingsScheduledInstalllink.SetSysLinkInstanceHandle(ghInstance);
  121. g_SettingsScheduledInstalllink.SubClassWindow(GetDlgItem(hWnd,IDC_LEARNMORE));
  122. g_SettingsScheduledInstalllink.SetHyperLink(gtszAUSchedInstallUrl);
  123. g_SettingsScheduledInstalllink.Invalidate();
  124. switch(auopt.dwOption)
  125. {
  126. case AUOPTION_AUTOUPDATE_DISABLE:
  127. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_UNCHECKED);
  128. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  129. EnableOptions( hWnd, FALSE );
  130. break;
  131. case AUOPTION_PREDOWNLOAD_NOTIFY:
  132. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  133. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION1);
  134. EnableOptions( hWnd, TRUE );
  135. break;
  136. case AUOPTION_INSTALLONLY_NOTIFY:
  137. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  138. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  139. EnableOptions( hWnd, TRUE );
  140. break;
  141. case AUOPTION_SCHEDULED:
  142. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  143. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION3);
  144. EnableOptions( hWnd, TRUE );
  145. break;
  146. }
  147. // HFONT hFont = (HFONT) SendMessage(hWnd , WM_GETFONT, 0, 0);
  148. // MYREInit(hWnd, IDC_STAT_LEARNAUTOUPDATE, hFont);
  149. // MYREInit(hWnd, IDC_LEARNMORE, hFont);
  150. FillDaysCombo(ghInstance, hWnd, auopt.dwSchedInstallDay, IDS_STR_EVERYDAY, IDS_STR_SATURDAY );
  151. FillHrsCombo( hWnd, auopt.dwSchedInstallTime );
  152. #ifndef TESTUI
  153. EnableRestoreControls(hWnd, FHiddenItemsExist());
  154. if (auopt.fDomainPolicy)
  155. {
  156. DisableUserInput(hWnd);
  157. }
  158. #else
  159. EnableRestoreControls(hWnd, TRUE);
  160. #endif
  161. SetFocus(GetDlgItem(hWnd,IDC_OK));
  162. return TRUE;
  163. }
  164. case WM_COMMAND:
  165. switch(LOWORD(wParam))
  166. {
  167. case IDC_OK:
  168. if(IsDlgButtonChecked(hWnd, IDC_CHK_KEEPUPTODATE) == BST_UNCHECKED)
  169. {
  170. auopt.dwOption = AUOPTION_AUTOUPDATE_DISABLE;
  171. QUITAUClient();
  172. EndDialog(GetParent(hWnd), S_OK);
  173. }
  174. else if(IsDlgButtonChecked(hWnd, IDC_OPTION1) == BST_CHECKED)
  175. {
  176. auopt.dwOption = AUOPTION_PREDOWNLOAD_NOTIFY;
  177. }
  178. else if(IsDlgButtonChecked(hWnd, IDC_OPTION2) == BST_CHECKED)
  179. {
  180. auopt.dwOption = AUOPTION_INSTALLONLY_NOTIFY;
  181. }
  182. else //if(IsDlgButtonChecked(hWnd, IDC_OPTION3) == BST_CHECKED)
  183. {
  184. GetDayAndTimeFromUI( hWnd, &(auopt.dwSchedInstallDay), &(auopt.dwSchedInstallTime));
  185. auopt.dwOption = AUOPTION_SCHEDULED;
  186. EnableCombo( hWnd, TRUE );
  187. }
  188. #ifndef TESTUI
  189. gInternals->m_setServiceOption(auopt);
  190. #else
  191. // SetServiceOption(auopt.dwOption, auopt.dwScheduledInstallDay, auopt.dwScheduledInstallTime);
  192. #endif
  193. EndDialog(hWnd, S_OK);
  194. return 0;
  195. case IDC_OPTION1:
  196. EnableCombo( hWnd, FALSE );
  197. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION1);
  198. return 0;
  199. case IDC_OPTION2:
  200. EnableCombo( hWnd, FALSE );
  201. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  202. return 0;
  203. case IDC_OPTION3:
  204. EnableCombo( hWnd, TRUE );
  205. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION3);
  206. return 0;
  207. case IDC_CHK_KEEPUPTODATE:
  208. if( BN_CLICKED == HIWORD(wParam) )
  209. {
  210. OnKeepUptoDate( hWnd );
  211. }
  212. return 0;
  213. case IDC_RESTOREHIDDEN:
  214. {
  215. extern HINSTANCE ghInstance;
  216. INT Result = (INT)DialogBoxParam(ghInstance,
  217. MAKEINTRESOURCE(IDD_RESTOREUPDATE),
  218. hWnd,
  219. _DlgRestoreProc,
  220. (LPARAM)NULL);
  221. if (Result == TRUE)
  222. {
  223. #ifndef TESTUI
  224. if (RemoveHiddenItems())
  225. {
  226. EnableRestoreControls(hWnd, FALSE);
  227. }
  228. #else
  229. MessageBoxW(NULL,L"Said Yes",NULL,MB_OK);
  230. EnableRestoreControls(hWnd, FALSE);
  231. #endif
  232. }
  233. }
  234. return 0;
  235. case IDCANCEL:
  236. case IDC_CANCEL:
  237. EndDialog(hWnd, S_OK);
  238. return 0;
  239. default:
  240. return FALSE;
  241. }
  242. case WM_CLOSE:
  243. EndDialog(hWnd, S_OK);
  244. return FALSE;
  245. case WM_DESTROY:
  246. g_SettingsAutoUpdatelink.Uninit();
  247. g_SettingsScheduledInstalllink.Uninit();
  248. ghCurrentDialog = oldCurrentDialog;
  249. gTopWins.Remove(hWnd);
  250. return 0;
  251. case WM_CTLCOLORSTATIC:
  252. {
  253. if (((HWND)lParam == GetDlgItem(hWnd, IDC_STAT_LEARNAUTOUPDATE)) || ((HWND)lParam == GetDlgItem(hWnd, IDC_LEARNMORE)))
  254. return SetSettingsColors((HDC)wParam, (HWND)lParam);
  255. }
  256. /*
  257. case WM_NOTIFY:
  258. {
  259. UINT uId = (UINT) LOWORD(wParam);
  260. switch (uId)
  261. {
  262. case IDC_LEARNMORE:
  263. case IDC_STAT_LEARNAUTOUPDATE:
  264. if (((NMHDR FAR *) lParam)->code == EN_LINK)
  265. {
  266. if (((ENLINK FAR *) lParam)->msg == WM_LBUTTONDOWN)
  267. {
  268. LaunchLinkAction(hWnd, uId);
  269. }
  270. }
  271. break;
  272. default:
  273. break;
  274. }
  275. }
  276. return 0;*/
  277. default:
  278. return FALSE;
  279. }
  280. }