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.

1463 lines
37 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. welcome.c
  5. Abstract:
  6. Routines for welcomong the user.
  7. Author:
  8. Ted Miller (tedm) 27-July-1995
  9. Revision History:
  10. --*/
  11. #include "setupp.h"
  12. #pragma hdrstop
  13. #define HARWARE_DETECTION_BOOT_TIMEOUT 5
  14. extern BOOLEAN
  15. AsrIsEnabled( VOID );
  16. //
  17. // Setup mode (custom, typical, laptop, etc)
  18. //
  19. UINT SetupMode = SETUPMODE_TYPICAL;
  20. //
  21. // Flag telling us whether we've already prepared for installation.
  22. //
  23. BOOL PreparedAlready;
  24. static HBRUSH s_hbrWindow = NULL;
  25. VOID AdjustAndPaintWatermarkBitmap(
  26. IN HWND hdlg,
  27. IN HDC hdc
  28. )
  29. /*
  30. Function used to adjust and paint the watermark bitmap so that it will fit correctly
  31. into the welcome and finish window, even if it is scalled differently than
  32. it would look when run on a usa build.
  33. some code borrowed from winnt32\dll\{rsrcutil,wizard}.c
  34. some code borrowed from shell\comctl32\prsht.c
  35. Arguments:
  36. hdlg, input handle for the window which the dialog shall be drawn into.
  37. hdc, input device context of the current window.
  38. Return Value:
  39. none: this is an attempt to scale the bitmap correctly for the cases
  40. where the win2k logo will be clipped. In order to get a chance to scale
  41. the bitmap, we can not let wiz97 take care of it, and thus if this function
  42. fails, there will be no watermark drawn.
  43. We treat errors in a way similarly
  44. to how property sheet would, which is that while we won't die hard, we
  45. make sure not to use any NULL resources.
  46. */
  47. {
  48. RECT rect;
  49. HBITMAP hDib;
  50. HRSRC BlockHandle;
  51. HGLOBAL MemoryHandle;
  52. BITMAPINFOHEADER *BitmapInfoHeader;
  53. BITMAPINFO *BitmapInfo;
  54. HDC MemDC;
  55. UINT ColorCount;
  56. HPALETTE PreviousPalette;
  57. HBITMAP Bitmap;
  58. BOOLEAN b;
  59. PVOID Bits;
  60. PVOID Bits2;
  61. int i;
  62. s_hbrWindow = GetSysColorBrush(COLOR_WINDOW);
  63. BlockHandle = FindResource(MyModuleHandle,MAKEINTRESOURCE(IDB_BITMAP1),RT_BITMAP);
  64. if(!BlockHandle) {
  65. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't find resource, error %d\n",
  66. GetLastError());
  67. //nothing to clean up.
  68. return;
  69. }
  70. MemoryHandle = LoadResource(MyModuleHandle,BlockHandle);
  71. if(!MemoryHandle) {
  72. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't load resource, error %d\n",
  73. GetLastError());
  74. //nothing to clean up.
  75. return;
  76. }
  77. BitmapInfoHeader = LockResource(MemoryHandle);
  78. if(BitmapInfoHeader == NULL) {
  79. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't lock resource, error %d\n",
  80. GetLastError());
  81. goto c0;
  82. }
  83. // First we have to paint the background on the right side of the window
  84. // (this is not auto done for us because we aren't using the wizard's watermark)
  85. GetClientRect(hdlg,&rect);
  86. rect.left = BitmapInfoHeader->biWidth;
  87. FillRect(hdc,&rect,s_hbrWindow);
  88. ColorCount = (BitmapInfoHeader->biBitCount <= 8)
  89. ? (1 << BitmapInfoHeader->biBitCount)
  90. : 0;
  91. BitmapInfo = MyMalloc(BitmapInfoHeader->biSize + (ColorCount * sizeof(RGBQUAD)));
  92. if (!BitmapInfo){
  93. SetupDebugPrint(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't malloc BitmapInfo.\n");
  94. goto c0;
  95. }
  96. CopyMemory(
  97. BitmapInfo,
  98. BitmapInfoHeader,
  99. BitmapInfoHeader->biSize + (ColorCount * sizeof(RGBQUAD))
  100. );
  101. BitmapInfo->bmiHeader.biHeight = rect.bottom;
  102. BitmapInfo->bmiHeader.biWidth = BitmapInfoHeader->biWidth;
  103. hDib = CreateDIBSection(NULL,BitmapInfo,DIB_RGB_COLORS,&Bits,NULL,0);
  104. if(!hDib) {
  105. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't create DIB, error %d\n",
  106. GetLastError());
  107. goto c1;
  108. }
  109. //
  110. // Create a "template" memory DC and select the DIB we created
  111. // into it. Passing NULL to CreateCompatibleDC creates a DC into which
  112. // any format bitmap can be selected. We don't want to use the dialog's
  113. // DC because if the pixel depth of the watermark bitmap differs from
  114. // the screen, we wouldn't be able to select the dib into the mem dc.
  115. //
  116. MemDC = CreateCompatibleDC(NULL);
  117. if(!MemDC) {
  118. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't create DC, error %d\n",
  119. GetLastError());
  120. goto c2;
  121. }
  122. if (!SelectObject(MemDC,hDib)){
  123. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't Select DC, error %d\n",
  124. GetLastError());
  125. goto c3;
  126. }
  127. //
  128. // Do the stretch operation from the source bitmap onto
  129. // the dib.
  130. //
  131. Bits2 = (LPBYTE)BitmapInfoHeader + BitmapInfoHeader->biSize + (ColorCount * sizeof(RGBQUAD));
  132. SetStretchBltMode(MemDC,COLORONCOLOR);
  133. i = StretchDIBits(
  134. MemDC,
  135. 0,0,
  136. BitmapInfoHeader->biWidth,
  137. rect.bottom,
  138. 0,0,
  139. BitmapInfoHeader->biWidth,
  140. BitmapInfoHeader->biHeight,
  141. Bits2,
  142. (BITMAPINFO *)BitmapInfoHeader,
  143. DIB_RGB_COLORS,
  144. SRCCOPY
  145. );
  146. if(i == GDI_ERROR) {
  147. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't stretch bitmap, error %d\n",
  148. GetLastError());
  149. goto c3;
  150. }
  151. i = BitBlt(hdc,0,0,BitmapInfoHeader->biWidth,rect.bottom,MemDC,0,0,SRCCOPY);
  152. if (0 == i){
  153. SetupDebugPrint1(L"SETUP: AdjustAndPaintWatermarkBitmap: Couldn't paint bitmap, error %d\n",
  154. GetLastError());
  155. }
  156. c3:
  157. DeleteDC(MemDC);
  158. c2:
  159. DeleteObject(hDib);
  160. c1:
  161. MyFree(BitmapInfo);
  162. c0:
  163. DeleteObject(MemoryHandle);
  164. }
  165. INT_PTR
  166. CALLBACK
  167. WelcomeDlgProc(
  168. IN HWND hdlg,
  169. IN UINT msg,
  170. IN WPARAM wParam,
  171. IN LPARAM lParam
  172. )
  173. /*++
  174. Routine Description:
  175. Dialog procedure for first wizard page of Setup.
  176. It essentially just welcomes the user.
  177. Arguments:
  178. Standard dialog procedure arguments.
  179. Return Value:
  180. Standard dialog procedure return.
  181. --*/
  182. {
  183. HFONT Font;
  184. LOGFONT LogFont;
  185. WCHAR str[20];
  186. int Height;
  187. HDC hdc;
  188. NMHDR *NotifyParams;
  189. PVOID p;
  190. static BOOL FirstInit=TRUE,FirstTime=TRUE;
  191. switch(msg) {
  192. case WM_INITDIALOG:
  193. WizardHandle = GetParent (hdlg);
  194. if((Font = (HFONT)SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_GETFONT,0,0))
  195. && GetObject(Font,sizeof(LOGFONT),&LogFont)) {
  196. LogFont.lfWeight = FW_BOLD;
  197. LoadString(MyModuleHandle,IDS_WELCOME_FONT_NAME,LogFont.lfFaceName,LF_FACESIZE);
  198. LoadString(MyModuleHandle,IDS_WELCOME_FONT_SIZE,str,sizeof(str)/sizeof(str[0]));
  199. Height = (int)wcstoul(str,NULL,10);
  200. if(hdc = GetDC(hdlg)) {
  201. LogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * Height / 72);
  202. if(Font = CreateFontIndirect(&LogFont)) {
  203. SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_SETFONT,(WPARAM)Font,MAKELPARAM(TRUE,0));
  204. }
  205. ReleaseDC(hdlg,hdc);
  206. }
  207. }
  208. if(p = MyLoadString((ProductType == PRODUCT_WORKSTATION) ?
  209. IDS_WORKSTATION_WELCOME_1 : IDS_SERVER_WELCOME_1)) {
  210. //
  211. // Use this instead of SetText because we need to pass wParam
  212. // to the control.
  213. //
  214. SendDlgItemMessage(hdlg,IDT_STATIC_2,WM_SETTEXT,0,(LPARAM)p);
  215. MyFree(p);
  216. }
  217. if(p = MyLoadString((ProductType == PRODUCT_WORKSTATION) ?
  218. IDS_WORKSTATION_WELCOME_2 : IDS_SERVER_WELCOME_2)) {
  219. //
  220. // Use this instead of SetText because we need to pass wParam
  221. // to the control.
  222. //
  223. SendDlgItemMessage(hdlg,IDT_STATIC_3,WM_SETTEXT,0,(LPARAM)p);
  224. MyFree(p);
  225. }
  226. #define SECOND 1000
  227. // Don't set the timer if we have a billboard, we don't show the page.
  228. if (FirstInit && !Unattended && (GetBBhwnd() == NULL)) {
  229. SetTimer(hdlg,1,10 * SECOND,NULL);
  230. FirstInit = FALSE;
  231. }
  232. #if 0
  233. //
  234. // Load steps text and set.
  235. //
  236. if(Preinstall) {
  237. //
  238. // Hide some text and don't display any steps.
  239. //
  240. ShowWindow(GetDlgItem(hdlg,IDT_STATIC_3),SW_HIDE);
  241. EnableWindow(GetDlgItem(hdlg,IDT_STATIC_3),FALSE);
  242. } else {
  243. if(p = MyLoadString(Upgrade ? IDS_STEPS_UPGRADE : IDS_STEPS)) {
  244. //
  245. // Use this instead of SetText because we need to pass wParam
  246. // to the control.
  247. //
  248. SendDlgItemMessage(hdlg,IDC_LIST1,WM_SETTEXT,0,(LPARAM)p);
  249. MyFree(p);
  250. }
  251. }
  252. //
  253. // Set up some of the static text on this page, which uses different
  254. // effects (boldface, different fonts, etc).
  255. //
  256. {
  257. HFONT Font;
  258. LOGFONT LogFont;
  259. WCHAR str[20];
  260. int Height;
  261. HDC hdc;
  262. //
  263. // First handle the text that "introduces" the title, which is in
  264. // the same font as the rest of the dialog, only bold.
  265. //
  266. if((Font = (HFONT)SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_GETFONT,0,0))
  267. && GetObject(Font,sizeof(LOGFONT),&LogFont)) {
  268. LogFont.lfWeight = FW_BOLD;
  269. if(Font = CreateFontIndirect(&LogFont)) {
  270. SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_SETFONT,(WPARAM)Font,MAKELPARAM(TRUE,0));
  271. }
  272. }
  273. //
  274. // Next do the title, which is in a different font, larger and in boldface.
  275. //
  276. if((Font = (HFONT)SendDlgItemMessage(hdlg,IDT_STATIC_2,WM_GETFONT,0,0))
  277. && GetObject(Font,sizeof(LOGFONT),&LogFont)) {
  278. LogFont.lfWeight = FW_BOLD;
  279. LoadString(MyModuleHandle,IDS_MSSERIF,LogFont.lfFaceName,LF_FACESIZE);
  280. LoadString(MyModuleHandle,IDS_LARGEFONTSIZE,str,sizeof(str)/sizeof(str[0]));
  281. Height = (int)wcstoul(str,NULL,10);
  282. if(hdc = GetDC(hdlg)) {
  283. LogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * Height / 72);
  284. if(Font = CreateFontIndirect(&LogFont)) {
  285. SendDlgItemMessage(hdlg,IDT_STATIC_2,WM_SETFONT,(WPARAM)Font,MAKELPARAM(TRUE,0));
  286. }
  287. ReleaseDC(hdlg,hdc);
  288. }
  289. }
  290. }
  291. #endif
  292. //
  293. // Center the wizard dialog on-screen.
  294. //
  295. // if we have the BB window, do the positioning on that. MainWindowHandle point to that window
  296. //
  297. if (GetBBhwnd())
  298. CenterWindowRelativeToWindow(GetParent(hdlg), MainWindowHandle, TRUE);
  299. else
  300. pSetupCenterWindowRelativeToParent(GetParent(hdlg));
  301. break;
  302. case WM_SIMULATENEXT:
  303. // Simulate the next button somehow
  304. PropSheet_PressButton( GetParent(hdlg), PSBTN_NEXT);
  305. break;
  306. case WMX_VALIDATE:
  307. // No data on this page, unattended should skip it
  308. return ReturnDlgResult (hdlg, VALIDATE_DATA_OK);
  309. case WM_TIMER:
  310. KillTimer(hdlg, 1);
  311. if (FirstTime) {
  312. PropSheet_PressButton( GetParent(hdlg), PSBTN_NEXT);
  313. FirstTime = FALSE;
  314. }
  315. break;
  316. case WM_CTLCOLOREDIT:
  317. case WM_CTLCOLORDLG:
  318. case WM_CTLCOLORMSGBOX:
  319. case WM_CTLCOLORLISTBOX:
  320. case WM_CTLCOLORBTN:
  321. case WM_CTLCOLORSCROLLBAR:
  322. case WM_CTLCOLORSTATIC:
  323. SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
  324. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  325. return (LRESULT)s_hbrWindow;
  326. case WM_ERASEBKGND:
  327. AdjustAndPaintWatermarkBitmap(hdlg,(HDC)wParam);
  328. break;
  329. case WM_NOTIFY:
  330. NotifyParams = (NMHDR *)lParam;
  331. switch(NotifyParams->code) {
  332. case PSN_SETACTIVE:
  333. TESTHOOK(510);
  334. BEGIN_SECTION(L"Welcome Page");
  335. SetWizardButtons(hdlg,WizPageWelcome);
  336. if(Preinstall) {
  337. //
  338. // Show unless OEMSkipWelcome = 1
  339. //
  340. if (GetPrivateProfileInt(pwGuiUnattended,L"OEMSkipWelcome",0,AnswerFile)) {
  341. FirstTime = FALSE;
  342. }
  343. SetWindowLongPtr(
  344. hdlg,
  345. DWLP_MSGRESULT,
  346. GetPrivateProfileInt(pwGuiUnattended,L"OEMSkipWelcome",0,AnswerFile) ? -1 : 0
  347. );
  348. } else {
  349. FirstTime = FALSE;
  350. if(Unattended) {
  351. UnattendSetActiveDlg(hdlg,IDD_WELCOME);
  352. }
  353. else if (GetBBhwnd() != NULL)
  354. {
  355. // If we have a billoard, don't show the page.
  356. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  357. }
  358. }
  359. break;
  360. case PSN_WIZNEXT:
  361. FirstTime = FALSE;
  362. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,0);
  363. break;
  364. case PSN_KILLACTIVE:
  365. END_SECTION(L"Welcome Page");
  366. default:
  367. break;
  368. }
  369. break;
  370. default:
  371. return(FALSE);
  372. }
  373. return(TRUE);
  374. }
  375. //
  376. // global variable used for subclassing.
  377. //
  378. WNDPROC OldEditProc;
  379. LRESULT
  380. CALLBACK
  381. EulaEditSubProc(
  382. IN HWND hwnd,
  383. IN UINT msg,
  384. IN WPARAM wParam,
  385. IN LPARAM lParam
  386. )
  387. /*++
  388. Routine Description:
  389. Edit control subclass routine, to avoid highlighting text when user
  390. tabs to the edit control.
  391. Arguments:
  392. Standard window proc arguments.
  393. Returns:
  394. Message-dependent value.
  395. --*/
  396. {
  397. //
  398. // For setsel messages, make start and end the same.
  399. //
  400. if((msg == EM_SETSEL) && ((LPARAM)wParam != lParam)) {
  401. lParam = wParam;
  402. }
  403. return(CallWindowProc(OldEditProc,hwnd,msg,wParam,lParam));
  404. }
  405. INT_PTR
  406. CALLBACK
  407. EulaDlgProc(
  408. IN HWND hdlg,
  409. IN UINT msg,
  410. IN WPARAM wParam,
  411. IN LPARAM lParam
  412. )
  413. /*++
  414. Routine Description:
  415. Dialog procedure for the wizard page that displays the End User License
  416. Agreement.
  417. Arguments:
  418. Standard dialog procedure arguments.
  419. Return Value:
  420. Standard dialog procedure return.
  421. --*/
  422. {
  423. NMHDR *NotifyParams;
  424. HWND EditControl;
  425. WCHAR EulaPath[MAX_PATH];
  426. static HANDLE hFile = NULL, hFileMapping = NULL;
  427. DWORD FileSize;
  428. static BYTE *pbFile = NULL;
  429. static PWSTR EulaText = NULL;
  430. int i;
  431. switch(msg) {
  432. case WM_INITDIALOG:
  433. //
  434. // If not preinstall then this was displayed at start of text mode
  435. // and we don't do it here.
  436. //
  437. if (EulaComplete || TextmodeEula || OemSkipEula) {
  438. break;
  439. }
  440. //
  441. // Map the file containing the licensing agreement.
  442. //
  443. GetSystemDirectory(EulaPath, MAX_PATH);
  444. pSetupConcatenatePaths (EulaPath, L"eula.txt", MAX_PATH, NULL);
  445. hFile = CreateFile (
  446. EulaPath,
  447. GENERIC_READ,
  448. 0,
  449. NULL,
  450. OPEN_EXISTING,
  451. FILE_ATTRIBUTE_NORMAL,
  452. NULL
  453. );
  454. if(hFile == INVALID_HANDLE_VALUE) {
  455. FatalError(MSG_EULA_ERROR,0,0);
  456. }
  457. hFileMapping = CreateFileMapping (
  458. hFile,
  459. NULL,
  460. PAGE_READONLY,
  461. 0, 0,
  462. NULL
  463. );
  464. if(hFileMapping == NULL) {
  465. FatalError(MSG_EULA_ERROR,0,0);
  466. }
  467. pbFile = MapViewOfFile (
  468. hFileMapping,
  469. FILE_MAP_READ,
  470. 0, 0,
  471. 0
  472. );
  473. if(pbFile == NULL) {
  474. FatalError(MSG_EULA_ERROR,0,0);
  475. }
  476. //
  477. // Translate the text from ANSI to Unicode.
  478. //
  479. FileSize = GetFileSize (hFile, NULL);
  480. if(FileSize == 0xFFFFFFFF) {
  481. FatalError(MSG_EULA_ERROR,0,0);
  482. }
  483. EulaText = MyMalloc ((FileSize+1) * sizeof(WCHAR));
  484. if(EulaText == NULL) {
  485. FatalError(MSG_EULA_ERROR,0,0);
  486. }
  487. MultiByteToWideChar (
  488. CP_ACP,
  489. 0,
  490. pbFile,
  491. FileSize,
  492. EulaText,
  493. (FileSize+1) * sizeof(WCHAR)
  494. );
  495. EulaText[FileSize] = 0;
  496. EditControl = GetDlgItem(hdlg,IDT_EDIT1);
  497. OldEditProc = (WNDPROC)GetWindowLongPtr(EditControl,GWLP_WNDPROC);
  498. SetWindowLongPtr(EditControl,GWLP_WNDPROC,(LONG_PTR)EulaEditSubProc);
  499. SetWindowText(EditControl,(PCWSTR)EulaText);
  500. break;
  501. case WM_DESTROY:
  502. //
  503. // Clean up
  504. //
  505. if( EulaText )
  506. MyFree (EulaText);
  507. if (pbFile)
  508. UnmapViewOfFile (pbFile);
  509. if (hFileMapping)
  510. CloseHandle (hFileMapping);
  511. if (hFile)
  512. CloseHandle (hFile);
  513. break;
  514. case WM_SIMULATENEXT:
  515. PropSheet_PressButton( GetParent(hdlg), PSBTN_NEXT);
  516. break;
  517. case WM_NOTIFY:
  518. NotifyParams = (NMHDR *)lParam;
  519. switch(NotifyParams->code) {
  520. case PSN_SETACTIVE:
  521. TESTHOOK(511);
  522. BEGIN_SECTION(L"Eula Page");
  523. SetWizardButtons(hdlg,WizPageEula);
  524. SetFocus(GetDlgItem(hdlg,IDYES));
  525. if (EulaComplete || TextmodeEula || OemSkipEula) {
  526. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  527. END_SECTION(L"Eula Page");
  528. } else {
  529. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,0);
  530. // Make sure we're initialized if we're going to show it.
  531. MYASSERT(EulaText);
  532. }
  533. break;
  534. case PSN_WIZBACK:
  535. case PSN_WIZNEXT:
  536. case PSN_WIZFINISH:
  537. //
  538. // Allow the next page to be activated.
  539. //
  540. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,0);
  541. break;
  542. case PSN_KILLACTIVE:
  543. if(IsDlgButtonChecked(hdlg,IDYES)) {
  544. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,0);
  545. } else {
  546. //
  547. // Are you sure you want to exit?
  548. //
  549. i = MessageBoxFromMessage(
  550. hdlg,
  551. MSG_SURE_EXIT,
  552. FALSE,
  553. IDS_WINNT_SETUP,
  554. MB_YESNO | MB_ICONQUESTION | MB_TASKMODAL | MB_DEFBUTTON2
  555. );
  556. if(i == IDYES) {
  557. FatalError(MSG_NOT_ACCEPT_EULA,0,0);
  558. } else {
  559. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  560. }
  561. END_SECTION(L"Eula Page");
  562. }
  563. break;
  564. default:
  565. break;
  566. }
  567. break;
  568. default:
  569. return(FALSE);
  570. }
  571. return(TRUE);
  572. }
  573. INT_PTR
  574. CALLBACK
  575. StepsDlgProc(
  576. IN HWND hdlg,
  577. IN UINT msg,
  578. IN WPARAM wParam,
  579. IN LPARAM lParam
  580. )
  581. /*++
  582. Routine Description:
  583. Dialog procedure for "steps" dialog page. This is the one just before
  584. we go into the network wizard.
  585. When the user clicks next to go to the next page, we have to perform
  586. some actions to prepare. So we put up a billboard telling the user
  587. that we are preparing. When preparation is done, we continue.
  588. Arguments:
  589. Standard dialog procedure arguments.
  590. Return Value:
  591. Standard dialog procedure return.
  592. --*/
  593. {
  594. NMHDR *NotifyParams;
  595. PVOID p;
  596. HWND billboard;
  597. HCURSOR OldCursor;
  598. switch(msg) {
  599. case WM_INITDIALOG:
  600. break;
  601. case WMX_VALIDATE:
  602. //
  603. // If unattended, we put up a wait cursor instead of a billboard
  604. //
  605. PropSheet_SetWizButtons(GetParent(hdlg),0);
  606. OldCursor = SetCursor (LoadCursor (NULL, IDC_WAIT));
  607. if(!UiTest) {
  608. if(Upgrade) {
  609. PrepareForNetUpgrade();
  610. } else {
  611. PrepareForNetSetup();
  612. }
  613. }
  614. SetCursor (OldCursor);
  615. return ReturnDlgResult (hdlg, VALIDATE_DATA_OK);
  616. #if 0
  617. case WM_SIMULATENEXT:
  618. PropSheet_PressButton( GetParent(hdlg), PSBTN_NEXT);
  619. break;
  620. #endif
  621. case WM_NOTIFY:
  622. NotifyParams = (NMHDR *)lParam;
  623. switch(NotifyParams->code) {
  624. case PSN_SETACTIVE:
  625. TESTHOOK(512);
  626. BEGIN_SECTION(L"Pre-Network Steps Page");
  627. // Page does not show, hide wizard
  628. SendMessage(GetParent(hdlg), WMX_BBTEXT, (WPARAM)TRUE, 0);
  629. SendDlgMessage (hdlg, WMX_VALIDATE, 0, TRUE);
  630. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  631. END_SECTION(L"Pre-Network Steps Page");
  632. break;
  633. #if 0
  634. case PSN_WIZNEXT:
  635. UnattendAdvanceIfValid (hdlg);
  636. break;
  637. #endif
  638. case PSN_KILLACTIVE:
  639. END_SECTION(L"Pre-Network Steps Page");
  640. default:
  641. break;
  642. }
  643. break;
  644. default:
  645. return(FALSE);
  646. }
  647. return(TRUE);
  648. }
  649. WNDPROC OldProgressProc;
  650. BOOL
  651. NewProgessProc(
  652. IN HWND hdlg,
  653. IN UINT msg,
  654. IN WPARAM wParam,
  655. IN LPARAM lParam
  656. )
  657. {
  658. switch (msg)
  659. {
  660. case WMX_PROGRESSTICKS:
  661. case PBM_DELTAPOS:
  662. case PBM_SETRANGE:
  663. case PBM_SETRANGE32:
  664. case PBM_STEPIT:
  665. case PBM_SETPOS:
  666. case PBM_SETSTEP:
  667. ProgressGaugeMsgWrapper(msg, wParam, lParam);
  668. break;
  669. }
  670. return (BOOL)CallWindowProc(OldProgressProc,hdlg,msg,wParam,lParam);
  671. }
  672. INT_PTR
  673. CALLBACK
  674. CopyFilesDlgProc(
  675. IN HWND hdlg,
  676. IN UINT msg,
  677. IN WPARAM wParam,
  678. IN LPARAM lParam
  679. )
  680. /*++
  681. Routine Description:
  682. Dialog procedure for the wizard page where we do all the work.
  683. Arguments:
  684. Standard dialog procedure arguments.
  685. Return Value:
  686. Standard dialog procedure return.
  687. --*/
  688. {
  689. static BOOL WorkFinished = FALSE;
  690. NMHDR *NotifyParams;
  691. static HCURSOR hcur;
  692. static FINISH_THREAD_PARAMS Context;
  693. static HWND hProgress;
  694. DWORD ThreadId;
  695. HANDLE ThreadHandle = NULL;
  696. UINT GaugeRange;
  697. switch(msg) {
  698. case WM_INITDIALOG:
  699. //
  700. // Initialize the progress indicator control.
  701. //
  702. hProgress = GetDlgItem(hdlg, IDC_PROGRESS1);
  703. OldProgressProc = (WNDPROC)SetWindowLongPtr(hProgress,GWLP_WNDPROC,(LONG_PTR)NewProgessProc);
  704. GaugeRange = 100;
  705. SendDlgItemMessage(hdlg,IDC_PROGRESS1,PBM_SETRANGE,0,MAKELPARAM(0,GaugeRange));
  706. SendDlgItemMessage(hdlg,IDC_PROGRESS1,PBM_SETPOS,0,0);
  707. SendDlgItemMessage(hdlg,IDC_PROGRESS1,PBM_SETSTEP,1,0);
  708. // Do calls into the billboard to prepare the progress there.
  709. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, SW_SHOW, 0);
  710. #ifdef _OCM
  711. //
  712. // the lparam is really the context pointer for ocm
  713. //
  714. Context.OcManagerContext = (PVOID)((PROPSHEETPAGE *)lParam)->lParam;
  715. MYASSERT(Context.OcManagerContext);
  716. #endif
  717. break;
  718. case WM_NOTIFY:
  719. NotifyParams = (NMHDR *)lParam;
  720. switch(NotifyParams->code) {
  721. case PSN_SETACTIVE:
  722. TESTHOOK(513);
  723. BEGIN_SECTION(L"Copying Files Page");
  724. SetWizardButtons(hdlg,WizPageCopyFiles);
  725. if(WorkFinished) {
  726. //
  727. // Don't activate; we've already been here before.
  728. // Nothing to do.
  729. //
  730. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  731. } else {
  732. //
  733. // Need to prepare for installation.
  734. // Want next/back buttons disabled until we're done.
  735. //
  736. PropSheet_SetWizButtons(GetParent(hdlg),0);
  737. SendMessage(GetParent(hdlg), WMX_BBTEXT, (WPARAM)TRUE, 0);
  738. PostMessage(hdlg,WM_IAMVISIBLE,0,0);
  739. WorkFinished = TRUE;
  740. }
  741. break;
  742. case PSN_KILLACTIVE:
  743. END_SECTION(L"Copying Files Page");
  744. default:
  745. break;
  746. }
  747. break;
  748. case WM_IAMVISIBLE:
  749. //
  750. // Force repainting first to make sure the page is visible.
  751. //
  752. InvalidateRect(hdlg,NULL,FALSE);
  753. UpdateWindow(hdlg);
  754. hcur = SetCursor(LoadCursor(NULL,IDC_WAIT));
  755. if(!UiTest) {
  756. Context.ThreadId = GetCurrentThreadId();
  757. Context.hdlg = hdlg;
  758. MYASSERT(Context.OcManagerContext);
  759. ThreadHandle = CreateThread(
  760. NULL,
  761. 0,
  762. FinishThread,
  763. &Context,
  764. 0,
  765. &ThreadId
  766. );
  767. if(ThreadHandle) {
  768. CloseHandle(ThreadHandle);
  769. } else {
  770. SetupDebugPrint1(
  771. L"SETUP: CreateThread() failed for FinishThread. Error = %d",
  772. GetLastError()
  773. );
  774. }
  775. }
  776. break;
  777. case WM_MY_PROGRESS:
  778. if(wParam) {
  779. SendMessage (hProgress, PBM_STEPIT, 0, 0);
  780. } else {
  781. SendMessage (hProgress, PBM_SETRANGE, 0, MAKELPARAM(0,lParam));
  782. SendMessage (hProgress, PBM_SETPOS, 0, 0);
  783. }
  784. break;
  785. case WMX_TERMINATE:
  786. //
  787. // Enable next and back buttons and move to next page.
  788. //
  789. SendMessage(GetParent(hdlg),WMX_SETPROGRESSTEXT,0,0);
  790. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, SW_HIDE, 0);
  791. SetCursor(hcur);
  792. if(!UiTest) {
  793. PropSheet_PressButton(GetParent(hdlg),PSBTN_NEXT);
  794. }
  795. break;
  796. default:
  797. return(FALSE);
  798. }
  799. return(TRUE);
  800. }
  801. INT_PTR
  802. CALLBACK
  803. LastPageDlgProc(
  804. IN HWND hdlg,
  805. IN UINT msg,
  806. IN WPARAM wParam,
  807. IN LPARAM lParam
  808. )
  809. /*++
  810. Routine Description:
  811. Dialog procedure for last wizard page of Setup.
  812. Arguments:
  813. Standard dialog procedure arguments.
  814. Return Value:
  815. Standard dialog procedure return.
  816. --*/
  817. {
  818. HFONT Font;
  819. LOGFONT LogFont;
  820. WCHAR str[20];
  821. int Height;
  822. HDC hdc;
  823. NMHDR *NotifyParams;
  824. PVOID p = NULL;
  825. switch(msg) {
  826. case WM_INITDIALOG:
  827. if((Font = (HFONT)SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_GETFONT,0,0))
  828. && GetObject(Font,sizeof(LOGFONT),&LogFont)) {
  829. LogFont.lfWeight = FW_BOLD;
  830. LoadString(MyModuleHandle,IDS_WELCOME_FONT_NAME,LogFont.lfFaceName,LF_FACESIZE);
  831. LoadString(MyModuleHandle,IDS_WELCOME_FONT_SIZE,str,sizeof(str)/sizeof(str[0]));
  832. Height = (int)wcstoul(str,NULL,10);
  833. if(hdc = GetDC(hdlg)) {
  834. LogFont.lfHeight = 0 - (GetDeviceCaps(hdc,LOGPIXELSY) * Height / 72);
  835. if(Font = CreateFontIndirect(&LogFont)) {
  836. SendDlgItemMessage(hdlg,IDT_STATIC_1,WM_SETFONT,(WPARAM)Font,MAKELPARAM(TRUE,0));
  837. }
  838. ReleaseDC(hdlg,hdc);
  839. }
  840. }
  841. break;
  842. case WM_SIMULATENEXT:
  843. // Simulate the next button somehow
  844. PropSheet_PressButton(GetParent(hdlg),PSBTN_FINISH);
  845. break;
  846. case WM_CTLCOLOREDIT:
  847. case WM_CTLCOLORDLG:
  848. case WM_CTLCOLORMSGBOX:
  849. case WM_CTLCOLORLISTBOX:
  850. case WM_CTLCOLORBTN:
  851. case WM_CTLCOLORSCROLLBAR:
  852. case WM_CTLCOLORSTATIC:
  853. SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
  854. SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
  855. return (LRESULT)s_hbrWindow;
  856. case WM_ERASEBKGND:
  857. AdjustAndPaintWatermarkBitmap(hdlg,(HDC)wParam);
  858. break;
  859. case WM_NOTIFY:
  860. NotifyParams = (NMHDR *)lParam;
  861. switch(NotifyParams->code) {
  862. case PSN_SETACTIVE:
  863. TESTHOOK(514);
  864. BEGIN_SECTION(L"Finish Page");
  865. if( AsrIsEnabled()) {
  866. if(p = MyLoadString(IDS_EMPTY_STRING)) {
  867. BB_SetTimeEstimateText(p);
  868. SendMessage(GetParent(hdlg), WMX_SETPROGRESSTEXT, 0, (LPARAM)p);
  869. SendMessage(GetParent(hdlg), WMX_BB_SETINFOTEXT, 0, (LPARAM)p);
  870. MyFree(p);
  871. }
  872. else {
  873. BB_SetTimeEstimateText(TEXT(""));
  874. SendMessage(GetParent(hdlg), WMX_SETPROGRESSTEXT, 0, (LPARAM)TEXT(""));
  875. SendMessage(GetParent(hdlg), WMX_BB_SETINFOTEXT, 0, (LPARAM)TEXT(""));
  876. }
  877. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, (WPARAM)SW_HIDE, 0);
  878. StartStopBB(FALSE);
  879. PostMessage(hdlg,WM_SIMULATENEXT,0,0);
  880. break;
  881. }
  882. SetWizardButtons(hdlg,WizPageLast);
  883. if (hinstBB)
  884. {
  885. PostMessage(hdlg,WM_SIMULATENEXT,0,0);
  886. }
  887. else
  888. {
  889. //
  890. // Don't want back button in upgrade case, since that would
  891. // land us in the middle of the network upgrade. In non-upgrade
  892. // case we only allow the user to go back if he didn't install
  893. // the net, to allow him to change his mind.
  894. //
  895. if(Upgrade || (InternalSetupData.OperationFlags & SETUPOPER_NETINSTALLED)) {
  896. PropSheet_SetWizButtons(GetParent(hdlg),PSWIZB_FINISH);
  897. }
  898. //
  899. // If NoWaitAfterGuiMode is zero, turn off Unattend mode
  900. //
  901. GetPrivateProfileString (L"Unattended", L"NoWaitAfterGuiMode", L"", str, 20, AnswerFile);
  902. if (!lstrcmp (str, L"0")) {
  903. Unattended = FALSE;
  904. }
  905. if (Unattended) {
  906. if(!UnattendSetActiveDlg(hdlg,IDD_LAST_WIZARD_PAGE))
  907. {
  908. END_SECTION(L"Finish Page");
  909. }
  910. }
  911. }
  912. break;
  913. case PSN_KILLACTIVE:
  914. END_SECTION(L"Finish Page");
  915. default:
  916. break;
  917. }
  918. break;
  919. default:
  920. return(FALSE);
  921. }
  922. return(TRUE);
  923. }
  924. INT_PTR
  925. CALLBACK
  926. PreparingDlgProc(
  927. IN HWND hdlg,
  928. IN UINT msg,
  929. IN WPARAM wParam,
  930. IN LPARAM lParam
  931. )
  932. /*++
  933. Routine Description:
  934. Dialog procedure for "preparing computer" Wizard page.
  935. When the user is viewing this page we are essentially preparing
  936. BaseWinOptions, initializing optional components stuff, and installing P&P devices.
  937. Arguments:
  938. Standard dialog procedure arguments.
  939. Return Value:
  940. Standard dialog procedure return.
  941. --*/
  942. {
  943. WCHAR str[1024];
  944. NMHDR *NotifyParams;
  945. HCURSOR hcur;
  946. switch(msg) {
  947. case WM_NOTIFY:
  948. NotifyParams = (NMHDR *)lParam;
  949. switch(NotifyParams->code) {
  950. case PSN_SETACTIVE:
  951. TESTHOOK(515);
  952. BEGIN_SECTION(L"Installing Devices Page");
  953. if(PreparedAlready) {
  954. //
  955. // Don't activate; we've already been here before.
  956. // Nothing to do.
  957. //
  958. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  959. } else {
  960. if(AsrIsEnabled()) {
  961. //
  962. // If this is ASR, load the appropriate wizard page
  963. //
  964. SetWizardButtons(hdlg, WizPagePreparingAsr);
  965. }
  966. //
  967. // Need to prepare for installation.
  968. // Want next/back buttons disabled until we're done.
  969. //
  970. PropSheet_SetWizButtons(GetParent(hdlg),0);
  971. SendMessage(GetParent(hdlg), WMX_BBTEXT, (WPARAM)TRUE, 0);
  972. PostMessage(hdlg,WM_IAMVISIBLE,0,0);
  973. PreparedAlready = TRUE;
  974. }
  975. break;
  976. case PSN_KILLACTIVE:
  977. END_SECTION(L"Installing Devices Page");
  978. default:
  979. break;
  980. }
  981. break;
  982. case WM_IAMVISIBLE:
  983. //
  984. // Force repainting first to make sure the page is visible.
  985. //
  986. InvalidateRect(hdlg,NULL,FALSE);
  987. UpdateWindow(hdlg);
  988. hcur = SetCursor(LoadCursor(NULL,IDC_WAIT));
  989. OldProgressProc = (WNDPROC)SetWindowLongPtr(GetDlgItem(hdlg, IDC_PROGRESS1),GWLP_WNDPROC,(LONG_PTR)NewProgessProc);
  990. // Do calls into the billboard to prepare the progress there.
  991. if(!LoadString(MyModuleHandle, IDS_BB_INSTALLING_DEVICES, str, SIZECHARS(str)))
  992. {
  993. *str = L'\0';
  994. }
  995. SendMessage(GetParent(hdlg), WMX_SETPROGRESSTEXT,0,(LPARAM)str);
  996. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, SW_SHOW, 0);
  997. if(!UiTest) {
  998. ULONG StartAtPercent = 0;
  999. ULONG StopAtPercent = 0;
  1000. if (AsrIsEnabled()) {
  1001. //
  1002. // Update the UI
  1003. //
  1004. SetFinishItemAttributes(hdlg,
  1005. IDC_ASR_PNP_BMP,
  1006. LoadImage (MyModuleHandle, MAKEINTRESOURCE(IDB_ARROW), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS),
  1007. IDC_ASR_PNP_TXT,
  1008. FW_BOLD
  1009. );
  1010. }
  1011. if( !MiniSetup ){
  1012. //
  1013. // Set Security use 10% of gauge
  1014. //
  1015. StopAtPercent = 30;
  1016. RemainingTime = CalcTimeRemaining(Phase_InstallSecurity);
  1017. SetRemainingTime(RemainingTime);
  1018. BEGIN_SECTION(L"Installing security");
  1019. SetupInstallSecurity(hdlg,
  1020. GetDlgItem(hdlg, IDC_PROGRESS1),
  1021. StartAtPercent,
  1022. StopAtPercent
  1023. );
  1024. END_SECTION(L"Installing security");
  1025. CallSceSetupRootSecurity();
  1026. SetupDebugPrint(L"SETUP: CallSceSetupRootSecurity started");
  1027. }
  1028. //
  1029. // Installation of PnP devices use the last 95% of the gauge
  1030. //
  1031. StartAtPercent = StopAtPercent;
  1032. StopAtPercent = 100;
  1033. BEGIN_SECTION(L"Installing PnP devices");
  1034. if (UninstallEnabled) {
  1035. //
  1036. // If uninstall mode, revert the timeout back to 5 seconds, so
  1037. // PNP can reboot for failed device detections
  1038. //
  1039. ChangeBootTimeout (HARWARE_DETECTION_BOOT_TIMEOUT);
  1040. }
  1041. InstallPnpDevices(hdlg,
  1042. SyssetupInf,
  1043. GetDlgItem(hdlg,IDC_PROGRESS1),
  1044. StartAtPercent,
  1045. StopAtPercent
  1046. );
  1047. END_SECTION(L"Installing PnP devices");
  1048. if (AsrIsEnabled()) {
  1049. //
  1050. // Update the UI
  1051. //
  1052. SetFinishItemAttributes(hdlg,
  1053. IDC_ASR_PNP_BMP,
  1054. LoadImage (MyModuleHandle, MAKEINTRESOURCE(IDB_CHECK), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS),
  1055. IDC_ASR_PNP_TXT,
  1056. FW_NORMAL
  1057. );
  1058. }
  1059. if( !MiniSetup ) {
  1060. BEGIN_SECTION(L"Loading service pack (phase 2)");
  1061. CALL_SERVICE_PACK( SVCPACK_PHASE_2, 0, 0, 0 );
  1062. END_SECTION(L"Loading service pack (phase 2)");
  1063. }
  1064. if(ScreenReader) {
  1065. InvokeExternalApplication(L"narrator.exe", L"", NULL);
  1066. }
  1067. }
  1068. SetCursor(hcur);
  1069. SetWindowLongPtr(GetDlgItem(hdlg, IDC_PROGRESS1),GWLP_WNDPROC,(LONG_PTR)OldProgressProc );
  1070. SendMessage(GetParent(hdlg),WMX_SETPROGRESSTEXT,0,0);
  1071. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, SW_HIDE, 0);
  1072. //
  1073. // Enable next and back buttons and move to next page.
  1074. //
  1075. SetWizardButtons(hdlg,WizPagePreparing);
  1076. if(!UiTest) {
  1077. PropSheet_PressButton(GetParent(hdlg),PSBTN_NEXT);
  1078. }
  1079. break;
  1080. default:
  1081. return(FALSE);
  1082. }
  1083. return(TRUE);
  1084. }
  1085. INT_PTR
  1086. CALLBACK
  1087. SetupPreNetDlgProc(
  1088. IN HWND hdlg,
  1089. IN UINT msg,
  1090. IN WPARAM wParam,
  1091. IN LPARAM lParam
  1092. )
  1093. {
  1094. NMHDR *NotifyParams;
  1095. switch(msg) {
  1096. case WM_NOTIFY:
  1097. NotifyParams = (NMHDR *)lParam;
  1098. switch(NotifyParams->code) {
  1099. case PSN_SETACTIVE:
  1100. TESTHOOK(516);
  1101. // Update time remaining.
  1102. // The network code knows how to hide the wizard pages
  1103. // and make them visible no need to do that here.
  1104. RemainingTime = CalcTimeRemaining(Phase_NetInstall);
  1105. SetRemainingTime(RemainingTime);
  1106. BEGIN_SECTION(L"Network Setup Pages");
  1107. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  1108. break;
  1109. default:
  1110. break;
  1111. }
  1112. break;
  1113. default:
  1114. return(FALSE);
  1115. }
  1116. return(TRUE);
  1117. }
  1118. INT_PTR
  1119. CALLBACK
  1120. SetupPostNetDlgProc(
  1121. IN HWND hdlg,
  1122. IN UINT msg,
  1123. IN WPARAM wParam,
  1124. IN LPARAM lParam
  1125. )
  1126. {
  1127. NMHDR *NotifyParams;
  1128. switch(msg) {
  1129. case WM_NOTIFY:
  1130. NotifyParams = (NMHDR *)lParam;
  1131. switch(NotifyParams->code) {
  1132. case PSN_SETACTIVE:
  1133. TESTHOOK(517);
  1134. END_SECTION(L"Network Setup Pages");
  1135. // Hide the progress bar when we get here.
  1136. // Just to make sure. There are scenarios where the progress bar was still visible
  1137. //
  1138. SendMessage(GetParent(hdlg), WMX_SETPROGRESSTEXT,0,0);
  1139. SendMessage(GetParent(hdlg), WMX_BBPROGRESSGAUGE, SW_HIDE, 0);
  1140. // update the time estimate display
  1141. // no need to make the wizard visible. The OC manager does this if needed.
  1142. RemainingTime = CalcTimeRemaining(Phase_OCInstall);
  1143. SetRemainingTime(RemainingTime);
  1144. SetWindowLongPtr(hdlg,DWLP_MSGRESULT,-1);
  1145. if(Win32ComputerName[0]){
  1146. SetEnvironmentVariable(L"COMPUTERNAME", Win32ComputerName);
  1147. }
  1148. break;
  1149. default:
  1150. break;
  1151. }
  1152. break;
  1153. default:
  1154. return(FALSE);
  1155. }
  1156. return(TRUE);
  1157. }