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.

1770 lines
48 KiB

  1. #include "pch.h"
  2. #include "htmlhelp.h"
  3. #include "link.h"
  4. #pragma hdrstop
  5. HINSTANCE mshtml = NULL;
  6. HACCEL ghCurrentAccel = NULL;
  7. HHOOK ghHook = NULL;
  8. AUOPTION gWelcomeOption;
  9. extern UINT gNextDialogMsg;
  10. #ifdef TESTUI
  11. DWORD gdwScheduledInstallDay = -1;
  12. DWORD gdwScheduledInstallTime = -1;
  13. #endif
  14. CSysLink g_AutoUpdatelink;
  15. CSysLink g_ScheduledInstalllink;
  16. CSysLink g_PrivacyStatementLink;
  17. CSysLink g_EULA_Link(FALSE); //non html help
  18. SHOWHTMLDIALOGFN *pfnShowHTMLDialog;
  19. const UINT CTRLIDSTRIDMAP[][2] = {
  20. {IDC_WELCOME_NOTE, IDS_NOTE},
  21. {IDC_WELCOME_CONTINUE, IDS_WELCOME_CONTINUE},
  22. {IDC_SUMMARY_NOTE, IDS_NOTE},
  23. {IDC_WELCOME_EULA, IDS_EULA},
  24. {IDC_LEARNMORE,IDS_LEARNMORE},
  25. {IDC_STAT_LEARNAUTOUPDATE,IDS_LEARNMOREAUTO}
  26. };
  27. // A Wrapper function to first check the item handle returned from GetDlgItem for the item iIDDlgItem and then to enable or disable it depending on the flag passed
  28. inline void GetItemAndEnableIt(HWND hWnd, int iIDDlgItem, BOOL bEnable)
  29. {
  30. HWND hItem = GetDlgItem(hWnd, iIDDlgItem);
  31. if (NULL != hItem)
  32. {
  33. EnableWindow(hItem, bEnable);
  34. }
  35. }
  36. void SetButtonText(HWND button, UINT resId)
  37. {
  38. TCHAR text[50];
  39. LoadString(ghInstance, resId, text, 50);
  40. SendMessage(button, WM_SETTEXT, 0, (LPARAM)text);
  41. }
  42. void ShowRTF(HWND hWnd, WPARAM wParam)
  43. {
  44. UINT uIndex = (UINT)wParam;
  45. IMoniker *pIMon = NULL;
  46. WCHAR wszArg[200];
  47. RECT rc;
  48. if (NULL == pfnShowHTMLDialog || uIndex >= gInternals->m_ItemList.Count())
  49. {
  50. return;
  51. }
  52. HRESULT hr;
  53. if (FAILED(hr = CreateURLMoniker(NULL, L"res://wuauclt.exe/RTFWRAPPER.HTM", &pIMon)))
  54. {
  55. DEBUGMSG("WUAUCLT: ShowRTF failed to CreateURLMoniker() with error %#lx", hr);
  56. goto done;
  57. }
  58. //fixcode: check return value of GetWindowRect()
  59. GetWindowRect(hWnd, &rc);
  60. if (FAILED(StringCchPrintfExW(wszArg, ARRAYSIZE(wszArg), NULL, NULL, MISTSAFE_STRING_FLAGS,
  61. L"dialogHeight:%dpx;dialogWidth:%dpx;dialogTop:%d;dialogLeft:%d;help:no;resizable:yes",
  62. rc.bottom-rc.top, rc.right-rc.left, rc.top + 25, rc.left + 25)))
  63. {
  64. DEBUGMSG("WUAUCLT: ShowRTF insufficient buffer for HTML dialog argument");
  65. goto done;
  66. }
  67. TCHAR tszRTFLocalFile[MAX_PATH];
  68. if (FAILED(GetRTFLocalFileName(gInternals->m_ItemList[uIndex].bstrRTFPath(), tszRTFLocalFile, ARRAYSIZE(tszRTFLocalFile), GetSystemDefaultLangID())))
  69. {
  70. goto done;
  71. }
  72. DEBUGMSG("Launching RTF page from %S", T2W(tszRTFLocalFile));
  73. VARIANT varg;
  74. varg.vt = VT_BSTR;
  75. if (NULL == (varg.bstrVal = SysAllocString(T2W(tszRTFLocalFile))))
  76. {
  77. DEBUGMSG("WUAUCLT: ShowRTF failed to allocate memory for HTML dialog argument");
  78. goto done;
  79. }
  80. pfnShowHTMLDialog(hWnd, pIMon, &varg, wszArg, NULL);
  81. VariantClear(&varg);
  82. done:
  83. SafeRelease(pIMon);
  84. return;
  85. }
  86. UINT ControlId2StringId(UINT uCtrlId)
  87. {
  88. for (int i = 0 ; i< ARRAYSIZE(CTRLIDSTRIDMAP); i++)
  89. {
  90. if (CTRLIDSTRIDMAP[i][0] == uCtrlId)
  91. {
  92. return CTRLIDSTRIDMAP[i][1];
  93. }
  94. }
  95. return -1;
  96. }
  97. //////////////////////////////////////////////////////////////////
  98. // Adjust (Stretch or squeeze) the bitmap IDB_SIDEBAR to
  99. // make it fit into the control IDC_SIDEBAR
  100. // to fit in the dialog
  101. // hDlg : handle to the dialog
  102. ///////////////////////////////////////////////////////////////////
  103. void AdjustSideBar(HWND hDlg)
  104. {
  105. HBITMAP hBmp;
  106. BITMAP bmp;
  107. HDC hDC;
  108. HDC hMemDC;
  109. RECT rc ;
  110. RECT rcWhiteRect, rcBottomLine;
  111. GetWindowRect(GetDlgItem(hDlg, IDC_BOTTOMLINE), &rcBottomLine);
  112. GetWindowRect(GetDlgItem(hDlg, IDC_WHITERECT), &rcWhiteRect);
  113. MapWindowPoints(NULL, hDlg, (LPPOINT)&rcBottomLine, 2);
  114. MapWindowPoints(NULL, hDlg, (LPPOINT)&rcWhiteRect, 2);
  115. rc.right = rcWhiteRect.left;
  116. rc.bottom = rcBottomLine.top -1;
  117. hDC = GetDC(hDlg);
  118. hMemDC = CreateCompatibleDC(hDC);
  119. hBmp = (HBITMAP) LoadImage(ghInstance, MAKEINTRESOURCE(IDB_SIDEBAR), IMAGE_BITMAP,
  120. 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION);
  121. GetObject(hBmp, sizeof(bmp), &bmp);
  122. SelectObject(hMemDC, hBmp);
  123. SetStretchBltMode( hDC, COLORONCOLOR );
  124. StretchBlt(hDC, 0, 0, rc.right, rc.bottom, hMemDC, 0, 0, bmp.bmWidth, bmp.bmHeight, MERGECOPY);
  125. DeleteObject(hBmp);
  126. DeleteDC(hMemDC);
  127. ReleaseDC(hDlg, hDC);
  128. }
  129. void SetAUDialogIcon(HWND hDlg, HANDLE hIcon, HANDLE hSmIcon)
  130. {
  131. SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
  132. SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hSmIcon);
  133. }
  134. int DisplayWizardCancelWarning(HWND hWnd)
  135. {
  136. TCHAR title[80], text[300];
  137. LoadString(ghInstance, IDS_CLOSEWARNINGTITLE, title, ARRAYSIZE(title));
  138. LoadString(ghInstance, IDS_CLOSEWARNINGTEXT, text, ARRAYSIZE(text));
  139. return MessageBox(hWnd, text, title, MB_YESNO | MB_ICONQUESTION);
  140. }
  141. void LaunchHelp(
  142. HWND hwnd,
  143. LPCTSTR szURL
  144. )
  145. {
  146. HtmlHelp(NULL,szURL,HH_DISPLAY_TOPIC,NULL);
  147. }
  148. LONG SetColors(HDC hdc, HWND control)
  149. {
  150. int id = GetDlgCtrlID(control);
  151. switch (id)
  152. {
  153. case IDC_WHITERECT:
  154. {
  155. SetBkMode(hdc, OPAQUE);
  156. SetBkColor(hdc, GetSysColor(COLOR_WINDOW));
  157. return PtrToLong(GetSysColorBrush(COLOR_WINDOW));
  158. }
  159. case IDC_CHK_KEEPUPTODATE:
  160. {
  161. //DEBUGMSG("IDC_LEARNMORE Setcolors");
  162. /*
  163. SetBkMode(hdc, TRANSPARENT);
  164. return PtrToLong(GetSysColorBrush(COLOR_BTNFACE));
  165. */
  166. return FALSE;
  167. }
  168. case IDC_OPTION1:
  169. case IDC_OPTION2:
  170. case IDC_OPTION3:
  171. {
  172. return FALSE;
  173. }
  174. case IDC_GRPBOX:
  175. return FALSE;
  176. default:
  177. {
  178. SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT));
  179. SetBkMode(hdc, TRANSPARENT);
  180. return PtrToLong(GetStockObject(HOLLOW_BRUSH));
  181. }
  182. }
  183. }
  184. LRESULT CALLBACK AUTranslatorProc(int code, WPARAM wParam, LPARAM lParam)
  185. {
  186. if(code != MSGF_DIALOGBOX
  187. || ghCurrentAccel == NULL
  188. || !TranslateAccelerator(ghCurrentDialog, ghCurrentAccel, (MSG*)lParam))
  189. {
  190. return CallNextHookEx(ghHook, code, wParam, lParam);
  191. }
  192. else
  193. {
  194. return 1;
  195. }
  196. }
  197. BOOL CALLBACK WizardFrameProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  198. {
  199. switch(message)
  200. {
  201. case WM_INITDIALOG:
  202. ghCurrentMainDlg = hWnd;
  203. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_WELCOME),
  204. hWnd, (DLGPROC)WelcomeDlgProc);
  205. SetActiveWindow(ghCurrentMainDlg);
  206. SetForegroundWindow(ghCurrentMainDlg);
  207. SetAUDialogIcon(hWnd, ghAppIcon, ghAppSmIcon); //set icon for all AU dialogs
  208. gWelcomeOption.dwOption = -1;
  209. gWelcomeOption.dwSchedInstallDay = -1;
  210. gWelcomeOption.dwSchedInstallTime = -1;
  211. return TRUE;
  212. case WM_COMMAND:
  213. if(ghCurrentDialog != NULL)
  214. {
  215. PostMessage(ghCurrentDialog, WM_COMMAND, wParam, lParam);
  216. }
  217. return 0;
  218. case WM_DESTROY:
  219. ghCurrentMainDlg = NULL;
  220. return 0;
  221. case WM_HELP:
  222. LaunchHelp(hWnd, gtszAUOverviewUrl);
  223. return TRUE;
  224. default:
  225. return FALSE;
  226. }
  227. }
  228. void LaunchEula()
  229. {
  230. TCHAR szCmd[MAX_PATH+1];
  231. STARTUPINFO StartupInfo;
  232. PROCESS_INFORMATION ProcessInfo;
  233. TCHAR szEULA_TXT[] = _T(" eula.txt"); // command line string
  234. UINT ulen =GetSystemDirectory(szCmd, ARRAYSIZE(szCmd));
  235. if ( 0 == ulen ||
  236. ulen >= ARRAYSIZE(szCmd) ||
  237. FAILED(StringCchCatEx(szCmd, ARRAYSIZE(szCmd), _T("\\notepad.exe"), NULL, NULL, MISTSAFE_STRING_FLAGS)))
  238. {
  239. return;
  240. }
  241. ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
  242. ZeroMemory(&StartupInfo, sizeof(StartupInfo));
  243. StartupInfo.cb = sizeof(StartupInfo);
  244. StartupInfo.wShowWindow = SW_SHOW;
  245. CreateProcess(
  246. szCmd, // name of executable module
  247. szEULA_TXT, // command line string
  248. NULL, // SD
  249. NULL, // SD
  250. FALSE, // handle inheritance option
  251. DETACHED_PROCESS, // creation flags
  252. NULL, // new environment block
  253. NULL, // current directory name
  254. &StartupInfo, // startup information
  255. &ProcessInfo // process information
  256. );
  257. SafeCloseHandleNULL(ProcessInfo.hThread);
  258. SafeCloseHandleNULL(ProcessInfo.hProcess);
  259. }
  260. void LaunchLinkAction(HWND hwnd, UINT uCtrlId)
  261. {
  262. //#ifdef _CWU
  263. #if 0
  264. OSVERSIONINFO OsVer;
  265. OsVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  266. GetVersionEx( &OsVer );
  267. #endif
  268. //#endif
  269. switch (uCtrlId)
  270. {
  271. case IDC_WELCOME_EULA:
  272. LaunchEula();
  273. break;
  274. // case IDC_WELCOME_PRIVACY:
  275. /*#ifndef _CWU
  276. ShellExecute(NULL, NULL, gtszPrivacyUrl, NULL, NULL, SW_SHOWNORMAL);
  277. #else
  278. */
  279. // {
  280. // LaunchHelp(hwnd, (LPTSTR)gtszW2KPrivacyUrl);
  281. /* if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 0))
  282. {
  283. // NT5
  284. LaunchHelp(hwnd, (LPTSTR)gtszW2KPrivacyUrl);
  285. }
  286. else if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 1))
  287. {
  288. // Whistler
  289. ShellExecute(NULL, NULL, gtszPrivacyUrl, NULL, NULL, SW_SHOWNORMAL);
  290. }
  291. */
  292. // }
  293. //#endif
  294. break;
  295. case IDC_LEARNMORE:
  296. /*#ifndef _CWU
  297. ShellExecute(NULL, NULL, gtszLearnMoreUrl, NULL, NULL, SW_SHOWNORMAL);
  298. #else
  299. */
  300. {
  301. LaunchHelp(hwnd, gtszAUSchedInstallUrl);
  302. /* if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 0))
  303. {
  304. // NT5
  305. LaunchHelp(hwnd, (LPTSTR)gtszAUW2kSchedInstallUrl);
  306. }
  307. else if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 1))
  308. {
  309. // Whistler
  310. LaunchHelp(hwnd, (LPTSTR)gtszAUXPSchedInstallUrl);
  311. }
  312. */
  313. }
  314. break;
  315. //#endif
  316. //#ifdef _CWU
  317. case IDC_STAT_LEARNAUTOUPDATE:
  318. {
  319. LaunchHelp(hwnd, gtszAUOverviewUrl);
  320. /*
  321. if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 0))
  322. {
  323. // NT5
  324. LaunchHelp(hwnd, (LPTSTR)gtszAUOverviewUrl);
  325. }
  326. else if( (OsVer.dwMajorVersion == 5) && (OsVer.dwMinorVersion == 1))
  327. {
  328. // Whistler
  329. ShellExecute(NULL, NULL, gtszLearnMoreUrl, NULL, NULL, SW_SHOWNORMAL);
  330. }
  331. */
  332. }
  333. break;
  334. //#endif
  335. }
  336. return;
  337. }
  338. void SetDefaultCF(HWND hWndMYRE, CHARFORMAT2 *pcfDefault)
  339. {
  340. pcfDefault->cbSize = sizeof(*pcfDefault);
  341. SendMessage(hWndMYRE, EM_GETCHARFORMAT, 0, (LPARAM)pcfDefault);
  342. pcfDefault->dwMask |= CFM_BOLD | CFM_HIDDEN | CFM_ITALIC | CFM_LINK
  343. | CFM_UNDERLINE | CFM_SIZE | CFM_WEIGHT | CFM_COLOR;
  344. pcfDefault->dwEffects &= ~(CFE_BOLD | CFE_ITALIC |CFE_LINK | CFE_UNDERLINE | CFE_HIDDEN);
  345. SendMessage(hWndMYRE, EM_SETCHARFORMAT, 0, (LPARAM)pcfDefault);
  346. }
  347. /*
  348. void DbgDumpEffects(CHARFORMAT2 cf)
  349. {
  350. UINT effects[] = {
  351. CFE_BOLD,
  352. CFE_ITALIC,
  353. CFE_LINK,
  354. CFE_UNDERLINE
  355. };
  356. LPTSTR msgs[]= {
  357. _T("BOLD"),
  358. _T("ITALIC"),
  359. _T("LINK"),
  360. _T("UNDERLINE")
  361. };
  362. const UINT NUM_EFFECTS = 4;
  363. for (int i = 0; i < NUM_EFFECTS; i++)
  364. {
  365. if (cf.dwEffects & effects[i] )
  366. {
  367. DEBUGMSG("cf is %S", msgs[i]);
  368. }
  369. else
  370. {
  371. DEBUGMSG("cf is NOT %S", msgs[i]);
  372. }
  373. }
  374. }
  375. */
  376. /////////////////////////////////////////////////////////////
  377. // Format specified text in a rich edit control
  378. // e.g. make it bold, italic, link etc
  379. // hWndMYRE : Rich edit window handle
  380. // uStrId : string id for the text to format
  381. // puEffects : points to the flag specifying designed effects. e.g.
  382. // : CFE_BOLD
  383. // : CFE_ITALIC
  384. // : CFE_UNDERLINE
  385. // : if NULL, effects not changed
  386. void FormatMYREText(HWND hWndMYRE, UINT uStrId, UINT* puEffects)
  387. {
  388. FINDTEXTEXW ft;
  389. CHARRANGE cr;
  390. CHARFORMAT2 cf;
  391. INT nFTflags ;
  392. ZeroMemory(&ft, sizeof(ft));
  393. ZeroMemory(&cr, sizeof(cr));
  394. ZeroMemory(&cf, sizeof(cf));
  395. // DEBUGMSG("FormatMYREText() effects = 0x%x color = 0x%x", puEffects, ptxtColor);
  396. cf.cbSize = sizeof(cf);
  397. ft.chrg.cpMin = 0;
  398. ft.chrg.cpMax = -1;
  399. ft.lpstrText = ResStrFromId(uStrId);
  400. nFTflags = FR_MATCHCASE|FR_WHOLEWORD|FR_DOWN;
  401. cr.cpMin = (LONG)SendMessage(hWndMYRE, EM_FINDTEXTEXW, nFTflags, (LPARAM) &ft);
  402. if (-1 == cr.cpMin )
  403. {
  404. DEBUGMSG("Format Text %S not found %lu", ft.lpstrText, GetLastError());
  405. return;
  406. }
  407. cr = ft.chrgText;
  408. SendMessage(hWndMYRE, EM_EXSETSEL, 0, (LPARAM)&cr);
  409. SendMessage(hWndMYRE, EM_GETCHARFORMAT, 1, (LPARAM)&cf);
  410. if (0 != puEffects)
  411. {
  412. cf.dwEffects |= *puEffects;
  413. }
  414. SendMessage(hWndMYRE, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
  415. }
  416. /////////////////////////////////////////////////////////////////
  417. // Subclass rich edit control and format its text
  418. // hDlg : the dialog the rich edit control is in
  419. // uId : id of the rich edit control
  420. // hFont: font to set richedit control
  421. /////////////////////////////////////////////////////////////////
  422. void MYREInit(HWND hDlg, UINT uId, HFONT hFont)
  423. {
  424. CHARFORMAT2 cfDefault;
  425. HWND hWndMYRE = GetDlgItem(hDlg, uId);
  426. UINT uStrId = 0;
  427. UINT uEffects = 0;
  428. SetDefaultCF(hWndMYRE, &cfDefault);
  429. //DEBUGMSG("MYREInit() retrieving and removing text");
  430. UINT uTextLen = (LONG)SendMessage(hWndMYRE, WM_GETTEXTLENGTH, 0, 0);
  431. TCHAR *pText = (TCHAR*)malloc((uTextLen + 1)* sizeof(TCHAR));
  432. if (NULL != pText)
  433. {
  434. /* need to blank out text and reset text for new font to go into effect*/
  435. SendMessage(hWndMYRE, WM_GETTEXT, (WPARAM)(uTextLen+1), (LPARAM)pText);
  436. //DEBUGMSG("MYREInit() get text %S", pText);
  437. SendMessage(hWndMYRE, WM_SETTEXT, 0, (LPARAM)L"");
  438. //DEBUGMSG("MYREInit() removed text");
  439. LRESULT lres = SendMessage(hWndMYRE, EM_GETLANGOPTIONS, 0, 0);
  440. lres &= ~IMF_AUTOFONT; // turn off autofont
  441. SendMessage(hWndMYRE, EM_SETLANGOPTIONS, 0, (LPARAM)lres);
  442. //DEBUGMSG("MYREInit() turn off auto font");
  443. SendMessage(hWndMYRE, WM_SETFONT, (WPARAM)hFont, TRUE);
  444. //DEBUGMSG("MYREInit() setting font to %#lx", hFont);
  445. SendMessage(hWndMYRE, WM_SETTEXT, 0, (LPARAM)pText);
  446. //DEBUGMSG("MYREInit() reset text");
  447. free(pText);
  448. }
  449. switch (uId)
  450. {
  451. case IDC_WELCOME_NOTE:
  452. case IDC_SUMMARY_NOTE:
  453. case IDC_WELCOME_CONTINUE:
  454. {
  455. uStrId = ControlId2StringId(uId);
  456. uEffects = CFE_BOLD;
  457. break;
  458. }
  459. //#ifdef _CWU
  460. case IDC_WELCOME_EULA:
  461. case IDC_WELCOME_PRIVACY:
  462. case IDC_LEARNMORE:
  463. case IDC_STAT_LEARNAUTOUPDATE:
  464. uStrId = ControlId2StringId(uId);
  465. uEffects = CFE_LINK;
  466. SendMessage(hWndMYRE, EM_SETEVENTMASK, 0, ENM_LINK);
  467. break;
  468. //#endif
  469. }
  470. if (0 != uStrId)
  471. {
  472. FormatMYREText(hWndMYRE, uStrId, &uEffects);
  473. }
  474. return;
  475. }
  476. void CancelWizard(HWND hWnd)
  477. {
  478. static BOOL s_fCancelWarningShown = FALSE;
  479. if (!s_fCancelWarningShown)
  480. {
  481. s_fCancelWarningShown = TRUE;
  482. if (IDYES == DisplayWizardCancelWarning(hWnd))
  483. {
  484. #if 0
  485. #ifndef TESTUI
  486. SetTomorrowReminder(AUSTATE_NOT_CONFIGURED);
  487. #endif
  488. #endif
  489. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_SETUPCANCEL),
  490. GetParent(hWnd), (DLGPROC)SetupCancelDlgProc);
  491. DestroyWindow(hWnd);
  492. }
  493. s_fCancelWarningShown = FALSE;
  494. }
  495. }
  496. BOOL CALLBACK WelcomeDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  497. {
  498. static BOOL s_fHasFocusLastTime ;
  499. switch(message)
  500. {
  501. case WM_INITDIALOG:
  502. {
  503. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  504. ghCurrentDialog = hWnd;
  505. s_fHasFocusLastTime = FALSE;
  506. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  507. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  508. GetItemAndEnableIt(hWnd, IDC_BACK, FALSE);
  509. SetFocus(GetDlgItem(hWnd, IDC_NEXT));
  510. HFONT hFont = (HFONT) SendMessage(hWnd , WM_GETFONT, 0, 0);
  511. MYREInit(hWnd, IDC_WELCOME_NOTE, hFont);
  512. MYREInit(hWnd, IDC_WELCOME_CONTINUE, hFont);
  513. //#ifdef _CWU
  514. // MYREInit(hWnd, IDC_WELCOME_EULA, hFont);
  515. // MYREInit(hWnd, IDC_WELCOME_PRIVACY, hFont);
  516. //#endif
  517. g_PrivacyStatementLink.SetSysLinkInstanceHandle(ghInstance);
  518. g_PrivacyStatementLink.SubClassWindow(GetDlgItem(hWnd,IDC_WELCOME_PRIVACY));
  519. g_PrivacyStatementLink.SetHyperLink(gtszAUPrivacyUrl);
  520. g_PrivacyStatementLink.Invalidate();
  521. g_EULA_Link.SetSysLinkInstanceHandle(ghInstance);
  522. g_EULA_Link.SubClassWindow(GetDlgItem(hWnd,IDC_WELCOME_EULA));
  523. g_EULA_Link.SetHyperLink(_T("eula.txt"));
  524. g_EULA_Link.Invalidate();
  525. return TRUE;
  526. }
  527. case WM_COMMAND:
  528. switch(LOWORD(wParam))
  529. {
  530. case IDOK:
  531. case IDC_NEXT:
  532. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_NOTOPTIONS),
  533. GetParent(hWnd), (DLGPROC)NotificationOptionsDlgProc);
  534. DestroyWindow(hWnd);
  535. return 0;
  536. case IDCANCEL:
  537. case IDC_CANCEL:
  538. CancelWizard(hWnd);
  539. return 0;
  540. default:
  541. return 0;
  542. }
  543. case WM_CTLCOLORSTATIC:
  544. return SetColors((HDC)wParam, (HWND)lParam);
  545. case WM_SETCURSOR:
  546. {
  547. if (LOWORD(lParam) == HTCLIENT && HIWORD(lParam) == WM_MOUSEMOVE)
  548. {
  549. SetCursor(ghCursorNormal);
  550. }
  551. return TRUE;
  552. }
  553. case WM_DRAWITEM:
  554. {
  555. AdjustSideBar(hWnd);
  556. return TRUE;
  557. }
  558. case WM_NOTIFY:
  559. {
  560. UINT uId = (UINT) LOWORD(wParam);
  561. /*#ifndef _CWU
  562. LPNMHDR pNMHdr = (LPNMHDR) lParam;
  563. switch (uId)
  564. {
  565. case IDC_WELCOME_PRIVACY:
  566. case IDC_WELCOME_EULA:
  567. switch (pNMHdr->code)
  568. {
  569. case NM_RETURN:
  570. case NM_CLICK:
  571. {
  572. LaunchLinkAction(uId);
  573. }
  574. break;
  575. default:
  576. break;
  577. }
  578. default:
  579. break;
  580. }
  581. #else
  582. */
  583. switch (uId)
  584. {
  585. // case IDC_WELCOME_PRIVACY:
  586. case IDC_WELCOME_EULA:
  587. if (((NMHDR FAR *) lParam)->code == EN_LINK)
  588. {
  589. if (((ENLINK FAR *) lParam)->msg == WM_LBUTTONDOWN)
  590. {
  591. LaunchLinkAction(hWnd, uId);
  592. }
  593. }
  594. break;
  595. default:
  596. break;
  597. }
  598. //#endif
  599. return 0;
  600. }
  601. case WM_DESTROY:
  602. g_EULA_Link.Uninit();
  603. g_PrivacyStatementLink.Uninit();
  604. return 0;
  605. default:
  606. {
  607. return FALSE;
  608. }
  609. }
  610. }
  611. WNDPROC editProc;
  612. #ifdef TESTUI
  613. const TCHAR REG_AUOPTIONS[] = _T("AUOptions"); //REG_DWORD
  614. const TCHAR REG_AUSCHEDINSTALLDAY[] = _T("ScheduledInstallDay"); // REG_DWORD
  615. const TCHAR REG_AUSCHEDINSTALLTIME[] = _T("ScheduledInstallTime"); // REG_DWORD
  616. void GetServiceOption(
  617. LPDWORD lpdwOption,
  618. LPDWORD lpdwDay,
  619. LPDWORD lpdwTime
  620. )
  621. {
  622. DWORD dwResult = AUOPTION_INSTALLONLY_NOTIFY;
  623. GetRegDWordValue(REG_AUOPTIONS, &dwResult);
  624. if ((dwResult < AUOPTION_ADMIN_MIN) || (dwResult > AUOPTION_MAX))
  625. {
  626. DEBUGMSG("WUAUENG Invalid option in registry, returning installonly");
  627. dwResult = AUOPTION_INSTALLONLY_NOTIFY;
  628. }
  629. *lpdwOption = dwResult;
  630. dwResult = 0;
  631. GetRegDWordValue(REG_AUSCHEDINSTALLDAY, &dwResult);
  632. if( (dwResult <= 0) || (dwResult > 7))
  633. {
  634. dwResult = 0;
  635. }
  636. *lpdwDay = dwResult;
  637. gdwScheduledInstallDay = dwResult;
  638. dwResult = 0;
  639. GetRegDWordValue(REG_AUSCHEDINSTALLTIME, &dwResult);
  640. if( (dwResult <= 0) || (dwResult > 23))
  641. {
  642. dwResult = 3;
  643. }
  644. *lpdwTime = dwResult;
  645. gdwScheduledInstallTime = dwResult;
  646. }
  647. void SetServiceOption(
  648. DWORD dwOption,
  649. DWORD dwDay,
  650. DWORD dwTime
  651. )
  652. {
  653. SetRegDWordValue( REG_AUOPTIONS, dwOption);
  654. SetRegDWordValue( REG_AUSCHEDINSTALLDAY, dwDay);
  655. SetRegDWordValue( REG_AUSCHEDINSTALLTIME, dwTime);
  656. }
  657. #endif
  658. BOOL EnableCombo(HWND hwnd, BOOL bState)
  659. {
  660. GetItemAndEnableIt(hwnd,IDC_CMB_DAYS,bState);
  661. GetItemAndEnableIt(hwnd,IDC_CMB_HOURS,bState);
  662. // GetItemAndEnableIt(hwnd,IDC_LEARNMORE,bState); //Enable/disable the learn about schedule install
  663. //link along with the combo boxes.
  664. return TRUE;
  665. }
  666. BOOL EnableOptions(HWND hwnd, BOOL bState)
  667. {
  668. GetItemAndEnableIt(hwnd,IDC_OPTION1,bState);
  669. GetItemAndEnableIt(hwnd,IDC_OPTION2,bState);
  670. GetItemAndEnableIt(hwnd,IDC_OPTION3,bState);
  671. if (BST_CHECKED == SendMessage(GetDlgItem(hwnd,IDC_OPTION3),BM_GETCHECK,0,0))
  672. {
  673. EnableCombo(hwnd, bState);
  674. }
  675. return TRUE;
  676. }
  677. void OnKeepUptoDate(HWND hwnd)
  678. {
  679. LRESULT lResult = SendMessage(GetDlgItem(hwnd,IDC_CHK_KEEPUPTODATE),BM_GETCHECK,0,0);
  680. if (lResult == BST_CHECKED)
  681. {
  682. EnableOptions(hwnd, TRUE);
  683. }
  684. else if (lResult == BST_UNCHECKED)
  685. {
  686. EnableOptions(hwnd, FALSE);
  687. EnableCombo(hwnd, FALSE);
  688. }
  689. }
  690. void GetDayAndTimeFromUI(
  691. HWND hWnd,
  692. LPDWORD lpdwDay,
  693. LPDWORD lpdwTime
  694. )
  695. {
  696. HWND hComboDays = GetDlgItem(hWnd,IDC_CMB_DAYS);
  697. HWND hComboHrs = GetDlgItem(hWnd,IDC_CMB_HOURS);
  698. LRESULT nDayIndex = SendMessage(hComboDays,CB_GETCURSEL,0,(LPARAM)0);
  699. LRESULT nTimeIndex = SendMessage(hComboHrs,CB_GETCURSEL,0,(LPARAM)0);
  700. *lpdwDay = (DWORD)SendMessage(hComboDays,CB_GETITEMDATA, nDayIndex, (LPARAM)0);
  701. *lpdwTime = (DWORD)SendMessage(hComboHrs,CB_GETITEMDATA, nTimeIndex, (LPARAM)0);
  702. }
  703. BOOL CALLBACK NotificationOptionsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  704. {
  705. switch(message)
  706. {
  707. case WM_INITDIALOG:
  708. {
  709. ghCurrentDialog = hWnd;
  710. EnableCombo(hWnd, FALSE); //Initially disabled
  711. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  712. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  713. if(-1 == gWelcomeOption.dwOption)
  714. {
  715. #ifndef TESTUI
  716. gInternals->m_getServiceOption(&gWelcomeOption);
  717. #else
  718. GetServiceOption(&(gWelcomeOption.dwOption), &(gWelcomeOption.dwSchedInstallDay), &(gWelcomeOption.dwSchedInstallTime));
  719. #endif
  720. }
  721. g_AutoUpdatelink.SetSysLinkInstanceHandle(ghInstance);
  722. g_AutoUpdatelink.SubClassWindow(GetDlgItem(hWnd,IDC_STAT_LEARNAUTOUPDATE));
  723. g_AutoUpdatelink.SetHyperLink(gtszAUOverviewUrl);
  724. g_AutoUpdatelink.Invalidate();
  725. g_ScheduledInstalllink.SetSysLinkInstanceHandle(ghInstance);
  726. g_ScheduledInstalllink.SubClassWindow(GetDlgItem(hWnd,IDC_LEARNMORE));
  727. g_ScheduledInstalllink.SetHyperLink(gtszAUSchedInstallUrl);
  728. g_ScheduledInstalllink.Invalidate();
  729. switch(gWelcomeOption.dwOption)
  730. {
  731. case AUOPTION_AUTOUPDATE_DISABLE:
  732. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_UNCHECKED);
  733. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  734. EnableOptions( hWnd, FALSE );
  735. break;
  736. case AUOPTION_PREDOWNLOAD_NOTIFY:
  737. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  738. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION1);
  739. EnableOptions( hWnd, TRUE );
  740. break;
  741. case AUOPTION_INSTALLONLY_NOTIFY:
  742. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  743. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  744. EnableOptions( hWnd, TRUE );
  745. break;
  746. case AUOPTION_SCHEDULED:
  747. CheckDlgButton( hWnd, IDC_CHK_KEEPUPTODATE, BST_CHECKED);
  748. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION3);
  749. EnableOptions( hWnd, TRUE );
  750. break;
  751. }
  752. SetFocus(GetDlgItem(hWnd, IDC_NEXT));
  753. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  754. HFONT hFont = (HFONT) SendMessage(hWnd , WM_GETFONT, 0, 0);
  755. MYREInit(hWnd, IDC_STAT_LEARNAUTOUPDATE, hFont);
  756. MYREInit(hWnd, IDC_LEARNMORE, hFont);
  757. FillDaysCombo(ghInstance, hWnd, gWelcomeOption.dwSchedInstallDay, IDS_STR_EVERYDAY, IDS_STR_SATURDAY );
  758. FillHrsCombo( hWnd, gWelcomeOption.dwSchedInstallTime );
  759. if (gWelcomeOption.fDomainPolicy)
  760. {
  761. DisableUserInput(hWnd);
  762. }
  763. return TRUE;
  764. }
  765. case WM_COMMAND:
  766. switch(LOWORD(wParam))
  767. {
  768. case IDOK:
  769. case IDC_NEXT:
  770. //#ifndef _CWU
  771. #if 0
  772. if(IsDlgButtonChecked(hWnd, IDC_OPTION1) == BST_CHECKED)
  773. {
  774. gdwWelcomeOption = AUOPTION_INSTALLONLY_NOTIFY;
  775. }
  776. else if(IsDlgButtonChecked(hWnd, IDC_OPTION2) == BST_CHECKED)
  777. {
  778. gdwWelcomeOption = AUOPTION_PREDOWNLOAD_NOTIFY;
  779. }
  780. else if(IsDlgButtonChecked(hWnd, IDC_OPTION3) == BST_CHECKED)
  781. {
  782. gdwWelcomeOption = AUOPTION_AUTOUPDATE_DISABLE;
  783. }
  784. #endif
  785. //#else
  786. if(IsDlgButtonChecked(hWnd, IDC_CHK_KEEPUPTODATE) == BST_UNCHECKED)
  787. {
  788. gWelcomeOption.dwOption = AUOPTION_AUTOUPDATE_DISABLE;
  789. }
  790. else if(IsDlgButtonChecked(hWnd, IDC_OPTION1) == BST_CHECKED)
  791. {
  792. gWelcomeOption.dwOption = AUOPTION_PREDOWNLOAD_NOTIFY;
  793. }
  794. else if(IsDlgButtonChecked(hWnd, IDC_OPTION2) == BST_CHECKED)
  795. {
  796. gWelcomeOption.dwOption = AUOPTION_INSTALLONLY_NOTIFY;
  797. }
  798. else if(IsDlgButtonChecked(hWnd, IDC_OPTION3) == BST_CHECKED)
  799. {
  800. gWelcomeOption.dwOption = AUOPTION_SCHEDULED;
  801. EnableCombo( hWnd, TRUE );
  802. GetDayAndTimeFromUI( hWnd, &(gWelcomeOption.dwSchedInstallDay), &(gWelcomeOption.dwSchedInstallTime));
  803. }
  804. //#endif
  805. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_SETUPCOMPLETE),
  806. GetParent(hWnd), (DLGPROC)SetupCompleteDlgProc);
  807. DestroyWindow(hWnd);
  808. return 0;
  809. case IDC_BACK:
  810. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_WELCOME),
  811. GetParent(hWnd), (DLGPROC)WelcomeDlgProc);
  812. DestroyWindow(hWnd);
  813. return 0;
  814. case IDCANCEL:
  815. case IDC_CANCEL:
  816. CancelWizard(hWnd);
  817. return 0;
  818. //#ifndef _CWU
  819. #if 0
  820. case IDC_OPTION1:
  821. gdwWelcomeOption = AUOPTION_INSTALLONLY_NOTIFY;
  822. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION1);
  823. return 0;
  824. case IDC_OPTION2:
  825. gdwWelcomeOption = AUOPTION_PREDOWNLOAD_NOTIFY;
  826. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  827. return 0;
  828. case IDC_OPTION3:
  829. gdwWelcomeOption = AUOPTION_AUTOUPDATE_DISABLE;
  830. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION3);
  831. return 0;
  832. #endif
  833. //#else
  834. case IDC_OPTION1:
  835. gWelcomeOption.dwOption = AUOPTION_PREDOWNLOAD_NOTIFY;
  836. EnableCombo( hWnd, FALSE );
  837. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION1);
  838. return 0;
  839. case IDC_OPTION2:
  840. gWelcomeOption.dwOption = AUOPTION_INSTALLONLY_NOTIFY;
  841. EnableCombo( hWnd, FALSE );
  842. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION2);
  843. return 0;
  844. case IDC_OPTION3:
  845. gWelcomeOption.dwOption = AUOPTION_SCHEDULED;
  846. EnableCombo( hWnd, TRUE );
  847. //GetDayAndTimeFromUI( hWnd, &(gWelcomeOption.dwSchedInstallDay), &(gWelcomeOption.dwSchedInstallTime));
  848. CheckRadioButton(hWnd, IDC_OPTION1, IDC_OPTION3, IDC_OPTION3);
  849. return 0;
  850. case IDC_CHK_KEEPUPTODATE:
  851. if( BN_CLICKED == HIWORD(wParam) )
  852. {
  853. OnKeepUptoDate( hWnd );
  854. }
  855. return 0;
  856. //#endif
  857. default:
  858. return 0;
  859. }
  860. case WM_NOTIFY:
  861. //#ifndef _CWU
  862. #if 0
  863. {
  864. UINT uId = (UINT) wParam;
  865. LPNMHDR pNMHdr = (LPNMHDR) lParam;
  866. if (IDC_LEARNMORE == uId && (NM_RETURN == pNMHdr->code || NM_CLICK == pNMHdr->code))
  867. {
  868. LaunchLinkAction(hWnd, uId);
  869. }
  870. return 0;
  871. }
  872. #endif
  873. //#else
  874. {
  875. UINT uId = (UINT) LOWORD(wParam);
  876. switch (uId)
  877. {
  878. case IDC_LEARNMORE:
  879. case IDC_STAT_LEARNAUTOUPDATE:
  880. if (((NMHDR FAR *) lParam)->code == EN_LINK)
  881. {
  882. if (((ENLINK FAR *) lParam)->msg == WM_LBUTTONDOWN)
  883. {
  884. LaunchLinkAction(hWnd, uId);
  885. }
  886. }
  887. break;
  888. default:
  889. break;
  890. }
  891. }
  892. return 0;
  893. //#endif
  894. case WM_SETCURSOR:
  895. {
  896. if (LOWORD(lParam) == HTCLIENT && HIWORD(lParam) == WM_MOUSEMOVE)
  897. {
  898. SetCursor(ghCursorNormal);
  899. }
  900. return TRUE;
  901. }
  902. case WM_CTLCOLORSTATIC:
  903. {
  904. return SetColors((HDC)wParam, (HWND)lParam);
  905. }
  906. case WM_DESTROY:
  907. g_ScheduledInstalllink.Uninit();
  908. g_AutoUpdatelink.Uninit();
  909. return 0;
  910. default:
  911. return FALSE;
  912. }
  913. }
  914. BOOL CALLBACK SetupCompleteDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  915. {
  916. switch(message)
  917. {
  918. case WM_INITDIALOG:
  919. {
  920. ghCurrentDialog = hWnd;
  921. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  922. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  923. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  924. GetItemAndEnableIt(hWnd, IDC_BACK, TRUE);
  925. GetItemAndEnableIt(hWnd, IDC_CANCEL, TRUE);
  926. SetFocus(GetDlgItem(hWnd, IDC_FINISH));
  927. return TRUE;
  928. }
  929. case WM_COMMAND:
  930. switch(LOWORD(wParam))
  931. {
  932. case IDC_BACK:
  933. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_NOTOPTIONS),
  934. GetParent(hWnd), (DLGPROC)NotificationOptionsDlgProc);
  935. DestroyWindow(hWnd);
  936. return 0;
  937. case IDCANCEL:
  938. case IDC_CANCEL:
  939. CancelWizard(hWnd);
  940. return 0;
  941. case IDOK:
  942. case IDC_FINISH:
  943. EndDialog(GetParent(hWnd), S_OK);
  944. DestroyWindow(hWnd);
  945. #ifdef TESTUI
  946. SetServiceOption(gWelcomeOption.dwOption, gWelcomeOption.dwSchedInstallDay, gWelcomeOption.dwSchedInstallTime);
  947. PostMessage(ghMainWindow, AUMSG_SHOW_DOWNLOAD, 0, 0);
  948. #else
  949. gInternals->m_setServiceOption(gWelcomeOption);
  950. gInternals->m_configureAU();
  951. QUITAUClient();
  952. #endif
  953. return 0;
  954. default:
  955. return 0;
  956. }
  957. case WM_CTLCOLORSTATIC:
  958. return SetColors((HDC)wParam, (HWND)lParam);
  959. case WM_DRAWITEM:
  960. AdjustSideBar(hWnd);
  961. return TRUE;
  962. default:
  963. return FALSE;
  964. }
  965. }
  966. void SetRemindMeLaterState(HWND hWnd)
  967. {
  968. #ifndef TESTUI
  969. AUOPTION auopt;
  970. if (SUCCEEDED(gInternals->m_getServiceOption(&auopt)))
  971. {
  972. GetItemAndEnableIt(hWnd, IDC_REMINDLATER,AUOPTION_SCHEDULED != auopt.dwOption);
  973. }
  974. #endif
  975. }
  976. BOOL CALLBACK DownloadDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  977. {
  978. switch(message)
  979. {
  980. case WM_INITDIALOG:
  981. {
  982. ghCurrentMainDlg = hWnd;
  983. ghCurrentDialog = hWnd;
  984. SetAUDialogIcon(hWnd, ghAppIcon, ghAppSmIcon);
  985. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  986. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  987. #ifndef TESTUI
  988. if ( gInternals->m_ItemList.GetNumSelected() == 0)
  989. {
  990. SetButtonText(GetDlgItem(hWnd, IDC_OK), IDS_CLOSEBUTTONTXT);
  991. }
  992. #endif
  993. SetRemindMeLaterState(hWnd);
  994. SetActiveWindow(ghCurrentMainDlg);
  995. SetForegroundWindow(ghCurrentMainDlg);
  996. if(mshtml == NULL)
  997. {
  998. // fixcode: we already have a static ref to mshtml.
  999. mshtml = LoadLibraryFromSystemDir(_T("MSHTML.DLL"));
  1000. pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)GetProcAddress(mshtml, "ShowHTMLDialog");
  1001. }
  1002. SetFocus(GetDlgItem(hWnd, IDC_UPDATELIST));
  1003. #ifdef DBG
  1004. DebugCheckForAutoPilot(hWnd);
  1005. #endif // DBG
  1006. return TRUE;
  1007. }
  1008. case WM_COMMAND:
  1009. switch(LOWORD(wParam))
  1010. {
  1011. case IDC_OK:
  1012. {
  1013. #ifdef TESTUI
  1014. PostMessage(ghMainWindow, AUMSG_SHOW_INSTALL, 0, 0);
  1015. #else
  1016. long lSelected = gInternals->m_ItemList.GetNumSelected();
  1017. if (FAILED(gInternals->m_startDownload()) || 0 == lSelected)
  1018. {
  1019. QUITAUClient();
  1020. }
  1021. else
  1022. {
  1023. RemoveTrayIcon();
  1024. }
  1025. #endif
  1026. EndDialog(hWnd, S_OK);
  1027. return 0;
  1028. }
  1029. case IDC_REMINDLATER:
  1030. if(DialogBox(ghInstance, MAKEINTRESOURCE(IDD_REMIND),
  1031. hWnd, (DLGPROC)ReminderDlgProc) == S_OK)
  1032. {
  1033. #ifndef TESTUI
  1034. gInternals->m_setReminderState(AUSTATE_DETECT_COMPLETE);
  1035. EndDialog(hWnd, S_FALSE);
  1036. #endif
  1037. }
  1038. return 0;
  1039. case IDC_SETTINGS:
  1040. {
  1041. ShowSettingsDlg(hWnd);
  1042. SetRemindMeLaterState(hWnd);
  1043. return 0;
  1044. }
  1045. case IDCANCEL:
  1046. //CancelDialog(hWnd, AUSTATE_DETECT_COMPLETE, TRUE);
  1047. EndDialog(hWnd, S_OK);
  1048. gNextDialogMsg = AUMSG_SHOW_DOWNLOAD;
  1049. return 0;
  1050. default:
  1051. return 0;
  1052. }
  1053. case WM_CTLCOLORSTATIC:
  1054. return SetColors((HDC)wParam, (HWND)lParam);
  1055. case AUMSG_SELECTION_CHANGED:
  1056. #ifndef TESTUI
  1057. if ( gInternals->m_ItemList.GetNumSelected() == 0)
  1058. {
  1059. SetButtonText(GetDlgItem(hWnd, IDC_OK), IDS_CLOSEBUTTONTXT);
  1060. }
  1061. else
  1062. {
  1063. SetButtonText(GetDlgItem(hWnd, IDC_OK), IDS_DOWNLOADBUTTONTXT);
  1064. }
  1065. #endif
  1066. return TRUE;
  1067. case AUMSG_SHOW_RTF:
  1068. {
  1069. #ifdef TESTUI
  1070. TCHAR tszMsg[100];
  1071. (void)StringCchPrintfEx(tszMsg, ARRAYSIZE(tszMsg), NULL, NULL, MISTSAFE_STRING_FLAGS, _T("SHOW RTF for item %d"), (UINT)wParam);
  1072. MessageBox(0, tszMsg, _T("Show RTF"), 0);
  1073. #else
  1074. ShowRTF(hWnd, wParam);
  1075. #endif
  1076. return TRUE;
  1077. }
  1078. break;
  1079. case WM_DESTROY:
  1080. ghCurrentMainDlg = NULL;
  1081. return FALSE;
  1082. case WM_MOVE:
  1083. return (LONG)SendMessage(GetDlgItem(hWnd, IDC_UPDATELIST), message, wParam, lParam);
  1084. case WM_HELP:
  1085. LaunchHelp(hWnd, gtszAUOverviewUrl);
  1086. return TRUE;
  1087. default:
  1088. return FALSE;
  1089. }
  1090. }
  1091. BOOL CALLBACK InstallDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1092. {
  1093. switch(message)
  1094. {
  1095. case WM_INITDIALOG:
  1096. SetAUDialogIcon(hWnd, ghAppIcon, ghAppSmIcon);
  1097. ghCurrentMainDlg = hWnd;
  1098. #ifdef TESTUI
  1099. ghCurrentDialog = CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_SUMMARY),
  1100. hWnd, (DLGPROC)SummaryDlgProc);
  1101. #else
  1102. if ( 0 == gInternals->m_ItemList.GetNumUnselected())
  1103. {
  1104. ghCurrentDialog = CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_SUMMARY),
  1105. hWnd, (DLGPROC)SummaryDlgProc);
  1106. }
  1107. else
  1108. {
  1109. ghCurrentDialog = CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_DETAILS),
  1110. hWnd, (DLGPROC)DetailsDlgProc);
  1111. }
  1112. #endif
  1113. ShowWindow(hWnd, SW_HIDE);
  1114. SetActiveWindow(ghCurrentMainDlg);
  1115. SetForegroundWindow(ghCurrentMainDlg);
  1116. SetFocus(ghCurrentDialog);
  1117. return FALSE;
  1118. case WM_MOVE:
  1119. return (LONG)SendMessage(ghCurrentDialog, message, wParam, lParam);
  1120. break;
  1121. case WM_COMMAND:
  1122. if(ghCurrentDialog != NULL)
  1123. {
  1124. PostMessage(ghCurrentDialog, WM_COMMAND, wParam, lParam);
  1125. }
  1126. return 0;
  1127. break;
  1128. case WM_HELP:
  1129. LaunchHelp(hWnd, gtszAUOverviewUrl);
  1130. return TRUE;
  1131. case WM_DESTROY:
  1132. ghCurrentMainDlg = NULL;
  1133. ghCurrentDialog = NULL;
  1134. // QUITAUClient(); // if we are getting destroyed, install is over //QUITAUClient() where we know we need to quit
  1135. break;
  1136. default:
  1137. break;
  1138. }
  1139. return FALSE;
  1140. }
  1141. BOOL CALLBACK SummaryDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1142. {
  1143. static HANDLE hIcon = NULL;
  1144. switch(message)
  1145. {
  1146. case WM_INITDIALOG:
  1147. {
  1148. //DEBUGMSG("SummaryDlg Get Initialized");
  1149. ghCurrentDialog = hWnd;
  1150. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1151. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1152. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1153. if (NULL == hIcon)
  1154. {
  1155. hIcon = LoadImage(ghInstance, MAKEINTRESOURCE(IDI_INFOICON), IMAGE_ICON, 16, 16, LR_LOADTRANSPARENT | LR_CREATEDIBSECTION);
  1156. }
  1157. HWND hInfoIcon = GetDlgItem(hWnd, IDC_INFOICON);
  1158. SendMessage( hInfoIcon, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
  1159. HFONT hFont = (HFONT) SendMessage(hWnd , WM_GETFONT, 0, 0);
  1160. MYREInit(hWnd, IDC_SUMMARY_NOTE, hFont);
  1161. SetRemindMeLaterState(hWnd);
  1162. SetFocus(GetDlgItem(hWnd, IDC_OK));
  1163. #ifdef DBG
  1164. DebugCheckForAutoPilot(hWnd);
  1165. #endif // DBG
  1166. return TRUE;
  1167. }
  1168. case WM_COMMAND:
  1169. switch(LOWORD(wParam))
  1170. {
  1171. case IDOK:
  1172. case IDC_OK:
  1173. {
  1174. RemoveTrayIcon();
  1175. #ifdef TESTUI
  1176. CreateDialogParam(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),
  1177. GetParent(hWnd), (DLGPROC)ProgressDlgProc, 2);
  1178. DestroyWindow(hWnd);
  1179. #else
  1180. int num;
  1181. if ( 0 != (num = gInternals->m_ItemList.GetNumSelected() ))
  1182. {
  1183. // CreateDialogParam(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),
  1184. // GetParent(hWnd), (DLGPROC)ProgressDlgProc, gInternals->m_ItemList.GetNumSelected());
  1185. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),GetParent(hWnd), (DLGPROC)ProgressDlgProc);
  1186. }
  1187. HRESULT hr;
  1188. if (FAILED(hr = gInternals->m_startInstall()) || 0 == num)
  1189. {
  1190. EndDialog(GetParent(hWnd), S_OK);
  1191. }
  1192. else
  1193. {
  1194. DestroyWindow(hWnd);
  1195. }
  1196. if (FAILED(hr))
  1197. {
  1198. QUITAUClient();
  1199. }
  1200. #endif
  1201. return 0;
  1202. }
  1203. case IDC_DETAILS:
  1204. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_DETAILS),
  1205. GetParent(hWnd), (DLGPROC)DetailsDlgProc);
  1206. DestroyWindow(hWnd);
  1207. return 0;
  1208. case IDC_REMINDLATER:
  1209. if(DialogBox(ghInstance, MAKEINTRESOURCE(IDD_REMIND),
  1210. hWnd, (DLGPROC)ReminderDlgProc) == S_OK)
  1211. {
  1212. #ifdef TESTUI
  1213. #else
  1214. gInternals->m_setReminderState(AUSTATE_DOWNLOAD_COMPLETE);
  1215. EndDialog(GetParent(hWnd), S_FALSE);
  1216. // QUITAUClient();
  1217. #endif
  1218. }
  1219. return 0;
  1220. case IDCANCEL:
  1221. //CancelDialog(hWnd, AUSTATE_DOWNLOAD_COMPLETE);
  1222. EndDialog(GetParent(hWnd), S_OK);
  1223. gNextDialogMsg = AUMSG_SHOW_INSTALL;
  1224. return 0;
  1225. default:
  1226. return 0;
  1227. }
  1228. case WM_CTLCOLORSTATIC:
  1229. return SetColors((HDC)wParam, (HWND)lParam);
  1230. case WM_DRAWITEM:
  1231. AdjustSideBar(hWnd);
  1232. return TRUE;
  1233. default:
  1234. return FALSE;
  1235. }
  1236. }
  1237. // peterwi can this and Summary dialog proc essentially be combined?
  1238. BOOL CALLBACK DetailsDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1239. {
  1240. switch(message)
  1241. {
  1242. case WM_INITDIALOG:
  1243. {
  1244. ghCurrentDialog = hWnd;
  1245. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1246. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1247. #ifndef TESTUI
  1248. if ( gInternals->m_ItemList.GetNumSelected() == 0 )
  1249. {
  1250. SetButtonText(GetDlgItem(hWnd, IDC_OK), IDS_CLOSEBUTTONTXT);
  1251. }
  1252. #endif
  1253. SetRemindMeLaterState(hWnd);
  1254. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1255. if(mshtml == NULL)
  1256. {
  1257. mshtml = LoadLibraryFromSystemDir(_T("MSHTML.DLL"));
  1258. pfnShowHTMLDialog = (SHOWHTMLDIALOGFN*)GetProcAddress(mshtml, "ShowHTMLDialog");
  1259. }
  1260. SetFocus(GetDlgItem(hWnd, IDC_OK));
  1261. return TRUE;
  1262. }
  1263. case WM_COMMAND:
  1264. switch(LOWORD(wParam))
  1265. {
  1266. case IDC_OK:
  1267. {
  1268. #ifdef TESTUI
  1269. CreateDialogParam(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),
  1270. GetParent(hWnd), (DLGPROC)ProgressDlgProc, 2);
  1271. DestroyWindow(hWnd);
  1272. #else
  1273. RemoveTrayIcon();
  1274. //(void)gpClientCatalog->PruneInstallListAccordingToSelections();
  1275. int num;
  1276. if ( 0 != (num = gInternals->m_ItemList.GetNumSelected()) )
  1277. {
  1278. DEBUGMSG("WUAUCLT details dialog had %d items selected", num);
  1279. // CreateDialogParam(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),
  1280. // GetParent(hWnd), (DLGPROC)ProgressDlgProc, gInternals->m_ItemList.GetNumSelected());
  1281. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_PROGRESS),GetParent(hWnd), (DLGPROC)ProgressDlgProc);
  1282. }
  1283. HRESULT hr ;
  1284. if (FAILED(hr = gInternals->m_startInstall()) || 0 == num)
  1285. {
  1286. EndDialog(GetParent(hWnd), S_OK);
  1287. }
  1288. else
  1289. {
  1290. DestroyWindow(hWnd);
  1291. }
  1292. if (FAILED(hr))
  1293. {
  1294. QUITAUClient();
  1295. }
  1296. #endif
  1297. return 0;
  1298. }
  1299. case IDC_REMINDLATER:
  1300. if(DialogBox(ghInstance, MAKEINTRESOURCE(IDD_REMIND),
  1301. hWnd, (DLGPROC)ReminderDlgProc) == S_OK)
  1302. {
  1303. #ifndef TESTUI
  1304. gInternals->m_setReminderState(AUSTATE_DOWNLOAD_COMPLETE);
  1305. EndDialog(GetParent(hWnd), S_FALSE);
  1306. //QUITAUClient();
  1307. #endif
  1308. }
  1309. return 0;
  1310. case IDC_SETTINGS:
  1311. ShowSettingsDlg(hWnd);
  1312. SetRemindMeLaterState(hWnd);
  1313. return 0;
  1314. case IDCANCEL:
  1315. //CancelDialog(hWnd, AUSTATE_DETECT_COMPLETE);
  1316. EndDialog(GetParent(hWnd), S_OK);
  1317. gNextDialogMsg = AUMSG_SHOW_INSTALL;
  1318. return 0;
  1319. default:
  1320. return 0;
  1321. }
  1322. case AUMSG_SELECTION_CHANGED:
  1323. UINT uBtnTxt;
  1324. if ( gInternals->m_ItemList.GetNumSelected() == 0 )
  1325. {
  1326. uBtnTxt = IDS_CLOSEBUTTONTXT;
  1327. }
  1328. else
  1329. {
  1330. uBtnTxt = IDS_INSTALLBUTTONTXT;
  1331. }
  1332. SetButtonText(GetDlgItem(hWnd, IDC_OK), uBtnTxt);
  1333. return TRUE;
  1334. case AUMSG_SHOW_RTF:
  1335. {
  1336. #ifdef TESTUI
  1337. TCHAR tszMsg[100];
  1338. (void)StringCchPrintfEx(tszMsg, ARRAYSIZE(tszMsg), NULL, NULL, MISTSAFE_STRING_FLAGS, _T("SHOW RTF for item %d"), (UINT)wParam);
  1339. MessageBox(0, tszMsg, _T("Show RTF"), 0);
  1340. #else
  1341. ShowRTF(hWnd, wParam);
  1342. #endif
  1343. return TRUE;
  1344. }
  1345. break;
  1346. case WM_CTLCOLORSTATIC:
  1347. return SetColors((HDC)wParam, (HWND)lParam);
  1348. case WM_MOVE:
  1349. return (LONG)SendMessage(GetDlgItem(hWnd, IDC_UPDATELIST), message, wParam, lParam);
  1350. default:
  1351. return FALSE;
  1352. }
  1353. }
  1354. BOOL CALLBACK ProgressDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1355. {
  1356. #ifdef TESTUI
  1357. static DWORD dwProgress = 0;
  1358. #endif
  1359. switch(message)
  1360. {
  1361. case WM_INITDIALOG:
  1362. {
  1363. ghCurrentDialog = hWnd;
  1364. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1365. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1366. #ifdef TESTUI
  1367. HWND hProgress = GetDlgItem(hWnd, IDC_PROGRESS);
  1368. dwProgress = 0;
  1369. SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, 3));
  1370. SendMessage(hProgress, PBM_SETSTEP, (WPARAM) 1, 0);
  1371. SetTimer(hWnd, 1, 1000, NULL);
  1372. #else
  1373. // HWND hProgress = GetDlgItem(hWnd, IDC_PROGRESS);
  1374. // DEBUGMSG("WUAUCLT ProgressDlg total %d items to be installed ", lParam);
  1375. // SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, lParam));
  1376. // SendMessage(hProgress, PBM_SETSTEP, (WPARAM) 1, 0);
  1377. #endif
  1378. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1379. EnableMenuItem (GetSystemMenu(GetParent(hWnd), FALSE), SC_CLOSE, MF_GRAYED);
  1380. return TRUE;
  1381. }
  1382. case WM_CTLCOLORSTATIC:
  1383. return SetColors((HDC)wParam, (HWND)lParam);
  1384. case AUMSG_INSTALL_COMPLETE:
  1385. DEBUGMSG("WUAUCLT ProgDlg gets AUMSG_INSTALL_COMPLETE");
  1386. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_COMPLETE),
  1387. GetParent(hWnd), (DLGPROC)InstallCompleteDlgProc);
  1388. DestroyWindow(hWnd);
  1389. return TRUE;
  1390. case AUMSG_REBOOT_REQUIRED:
  1391. DEBUGMSG("WUAUCLT ProgDlg gets AUMSG_REBOOT_REQUIRED");
  1392. CreateDialog(ghInstance, MAKEINTRESOURCE(IDD_RESTART),
  1393. GetParent(hWnd), (DLGPROC)RestartDlgProc);
  1394. DestroyWindow(hWnd);
  1395. return TRUE;
  1396. case AUMSG_INSTALL_PROGRESS:
  1397. {
  1398. HWND hProgress = GetDlgItem(hWnd, IDC_PROGRESS);
  1399. SendMessage(hProgress, PBM_STEPIT, 0, 0);
  1400. return TRUE;
  1401. }
  1402. case AUMSG_SET_INSTALL_ITEMSNUM:
  1403. {
  1404. HWND hProgress = GetDlgItem(hWnd, IDC_PROGRESS);
  1405. DEBUGMSG("WUAUCLT ProgressDlg total %d items to be installed ", lParam);
  1406. SendMessage(hProgress, PBM_SETRANGE, 0, MAKELPARAM(0, lParam));
  1407. SendMessage(hProgress, PBM_SETSTEP, (WPARAM) 1, 0);
  1408. }
  1409. #ifdef TESTUI
  1410. case WM_TIMER:
  1411. {
  1412. dwProgress ++;
  1413. PostMessage(hWnd, AUMSG_INSTALL_PROGRESS, 0, 0);
  1414. if (dwProgress >= 3)
  1415. {
  1416. KillTimer(hWnd, 1);
  1417. if(fCheckRebootFlag())
  1418. {
  1419. PostMessage(hWnd, AUMSG_REBOOT_REQUIRED, 0, 0);
  1420. }
  1421. else
  1422. {
  1423. PostMessage(hWnd, AUMSG_INSTALL_COMPLETE, 0, 0);
  1424. }
  1425. }
  1426. return 0;
  1427. }
  1428. #endif
  1429. default:
  1430. return FALSE;
  1431. }
  1432. }
  1433. BOOL CALLBACK InstallCompleteDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1434. {
  1435. switch(message)
  1436. {
  1437. case WM_INITDIALOG:
  1438. {
  1439. ghCurrentDialog = hWnd;
  1440. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1441. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1442. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1443. #ifdef DBG
  1444. DebugCheckForAutoPilot(hWnd);
  1445. DebugUninstallDemoPackages();
  1446. #endif // DBG
  1447. EnableMenuItem (GetSystemMenu(GetParent(hWnd), FALSE), SC_CLOSE, MF_ENABLED); //reset system menu
  1448. return TRUE;
  1449. }
  1450. case WM_CTLCOLORSTATIC:
  1451. return SetColors((HDC)wParam, (HWND)lParam);
  1452. case WM_COMMAND:
  1453. switch(LOWORD(wParam))
  1454. {
  1455. case IDOK:
  1456. case IDC_OK:
  1457. case IDCANCEL:
  1458. EndDialog(GetParent(hWnd), S_OK);
  1459. QUITAUClient();
  1460. return 0;
  1461. default:
  1462. return 0;
  1463. }
  1464. case WM_DESTROY:
  1465. // ghCurrentMainDlg = NULL;
  1466. return FALSE;
  1467. case WM_DRAWITEM:
  1468. AdjustSideBar(hWnd);
  1469. return TRUE;
  1470. default:
  1471. return FALSE;
  1472. }
  1473. }
  1474. BOOL CALLBACK RestartDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1475. {
  1476. switch(message)
  1477. {
  1478. case WM_INITDIALOG:
  1479. {
  1480. ghCurrentDialog = hWnd;
  1481. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1482. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1483. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1484. SetFocus(GetDlgItem(hWnd, IDC_RESTARTNOW));
  1485. EnableMenuItem (GetSystemMenu(GetParent(hWnd), FALSE), SC_CLOSE, MF_ENABLED); //reset system menu
  1486. return TRUE;
  1487. }
  1488. case WM_CTLCOLORSTATIC:
  1489. return SetColors((HDC)wParam, (HWND)lParam);
  1490. case WM_COMMAND:
  1491. switch(LOWORD(wParam))
  1492. {
  1493. case IDOK:
  1494. case IDC_RESTARTNOW:
  1495. SetClientExitCode(CDWWUAUCLT_REBOOTNOW);
  1496. EndDialog(GetParent(hWnd),S_OK);
  1497. QUITAUClient();
  1498. return 0;
  1499. case IDCANCEL:
  1500. case IDC_RESTARTLATER:
  1501. //DestroyWindow(hWnd);
  1502. EndDialog(GetParent(hWnd), S_OK);
  1503. SetClientExitCode(CDWWUAUCLT_REBOOTLATER);
  1504. QUITAUClient();
  1505. return 0;
  1506. default:
  1507. return 0;
  1508. }
  1509. case WM_DRAWITEM:
  1510. AdjustSideBar(hWnd);
  1511. return TRUE;
  1512. default:
  1513. return FALSE;
  1514. }
  1515. }
  1516. BOOL CALLBACK SetupCancelDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  1517. {
  1518. switch(message)
  1519. {
  1520. case WM_INITDIALOG:
  1521. {
  1522. ghCurrentDialog = hWnd;
  1523. HWND hHeader = GetDlgItem(hWnd, IDC_HEADER);
  1524. SendMessage(hHeader, WM_SETFONT, (WPARAM)ghHeaderFont, 0);
  1525. SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
  1526. GetItemAndEnableIt(hWnd, IDC_BACK, FALSE);
  1527. GetItemAndEnableIt(hWnd, IDC_CANCEL, FALSE);
  1528. SetFocus(GetDlgItem(hWnd, IDC_FINISH));
  1529. return TRUE;
  1530. }
  1531. case WM_COMMAND:
  1532. switch(LOWORD(wParam))
  1533. {
  1534. case IDOK:
  1535. case IDCANCEL:
  1536. case IDC_FINISH:
  1537. {
  1538. // bug 493734
  1539. // Remove the dialog (frame) but keep the icon.
  1540. EndDialog(GetParent(hWnd), S_OK);
  1541. gNextDialogMsg = AUMSG_SHOW_WELCOME;
  1542. // QUITAUClient();
  1543. // RemoveTrayIcon();
  1544. return 0;
  1545. }
  1546. default:
  1547. return 0;
  1548. }
  1549. case WM_CTLCOLORSTATIC:
  1550. return SetColors((HDC)wParam, (HWND)lParam);
  1551. case WM_DRAWITEM:
  1552. AdjustSideBar(hWnd);
  1553. return TRUE;
  1554. default:
  1555. return FALSE;
  1556. }
  1557. }