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.

2035 lines
54 KiB

  1. /****************************************************************************\
  2. WIZARD.C / OPK Wizard (OPKWIZ.EXE)
  3. Microsoft Confidential
  4. Copyright (c) Microsoft Corporation 1999
  5. All rights reserved
  6. Wizard source file for wizard functions used in the OPK Wizard.
  7. 4/99 - Jason Cohen (JCOHEN)
  8. Added this new source file for the OPK Wizard as part of the
  9. Millennium rewrite.
  10. 09/2000 - Stephen Lodwick (STELO)
  11. Ported OPK Wizard to Whistler
  12. \****************************************************************************/
  13. //
  14. // Include file(s)
  15. //
  16. #include "setupmgr.h"
  17. #include "allres.h"
  18. #include "sku.h"
  19. #include "appver.h"
  20. //
  21. // Internal Function(s):
  22. //
  23. // TreeView Helper Functions
  24. //
  25. static void ShowTreeDialog(HWND, LPTREEDLG);
  26. static void ShowSplashDialog(HWND, DWORD);
  27. static void FillTreeDialog(HWND);
  28. static void UpdateTreeVisibility(HWND);
  29. static LPTREEDLG GetTreeItem(HWND, HTREEITEM);
  30. static BOOL SelectTreeItem(HWND, HTREEITEM, UINT);
  31. static BOOL SelectFirstMaintenanceDlg(HWND);
  32. // Configuration/Profile Helper Functions
  33. //
  34. static BOOL CloseProfile(HWND, BOOL);
  35. static void OpenProfile(HWND, BOOL);
  36. static void SaveProfile(HWND);
  37. // Miscellaneous Helper Functions
  38. //
  39. static void OnCommand(HWND, INT, HWND, UINT);
  40. static void EnableControls(HWND);
  41. void SetWizardButtons(HWND, DWORD);
  42. BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  43. //
  44. // Page arrays: There are four total arrays
  45. // OEM/System Builder Pages
  46. // vdpOEMWizardDialogs - Starting Wizard Pages
  47. // vdpOEMTreeDialogs - Tree Dialogs
  48. // Corporate Deployment
  49. // vdpCDWizardDialogs - Starting Wizard Pages
  50. // vdpCDTreeDialogs - Tree Dialogs
  51. //
  52. static WIZDLG vdpOEMWizardDialogs[]=
  53. {
  54. {
  55. IDD_WELCOME,
  56. WelcomeDlgProc,
  57. 0,
  58. 0,
  59. PSP_DEFAULT | PSP_HIDEHEADER
  60. },
  61. #ifndef NO_LICENSE
  62. {
  63. IDD_LICENSE,
  64. LicenseDlgProc,
  65. IDS_LICENSE_TITLE,
  66. IDS_LICENSE_SUBTITLE,
  67. DEFAULT_PAGE_FLAGS
  68. },
  69. #endif // NO_LICENSE
  70. {
  71. IDD_CONFIG,
  72. ConfigDlgProc,
  73. IDS_CONFIG_TITLE,
  74. IDS_CONFIG_SUBTITLE,
  75. DEFAULT_PAGE_FLAGS
  76. },
  77. {
  78. IDD_LANG,
  79. LangDlgProc,
  80. IDS_LANG_TITLE,
  81. IDS_LANG_SUBTITLE,
  82. DEFAULT_PAGE_FLAGS
  83. },
  84. {
  85. IDD_CREATE,
  86. CreateDlgProc,
  87. IDS_CREATE_TITLE,
  88. IDS_CREATE_SUBTITLE,
  89. DEFAULT_PAGE_FLAGS
  90. },
  91. {
  92. IDD_MODE,
  93. ModeDlgProc,
  94. IDS_MODE_TITLE,
  95. IDS_MODE_SUBTITLE,
  96. DEFAULT_PAGE_FLAGS
  97. },
  98. {
  99. IDD_SKU,
  100. SkuDlgProc,
  101. IDS_SKU_TITLE,
  102. IDS_SKU_SUBTITLE,
  103. DEFAULT_PAGE_FLAGS
  104. },
  105. {
  106. IDD_OEMINFO,
  107. OemInfoDlgProc,
  108. IDS_OEMINFO_TITLE,
  109. IDS_OEMINFO_SUBTITLE,
  110. DEFAULT_PAGE_FLAGS
  111. },
  112. };
  113. static WIZDLG vdpCDWizardDialogs[]=
  114. {
  115. {
  116. IDD_WELCOME,
  117. DlgWelcomePage,
  118. 0,
  119. 0,
  120. PSP_DEFAULT | PSP_HIDEHEADER
  121. },
  122. {
  123. IDD_NEWOREDIT,
  124. DlgEditOrNewPage,
  125. IDS_NEWOREDIT_TITLE,
  126. IDS_NEWOREDIT_SUBTITLE,
  127. DEFAULT_PAGE_FLAGS
  128. },
  129. {
  130. IDD_PRODUCT,
  131. DlgProductPage,
  132. IDS_PRODUCT_TITLE,
  133. IDS_PRODUCT_SUBTITLE,
  134. DEFAULT_PAGE_FLAGS
  135. },
  136. {
  137. IDD_PLATFORM,
  138. DlgPlatformPage,
  139. IDS_PLATFORM_TITLE,
  140. IDS_PLATFORM_SUBTITLE,
  141. DEFAULT_PAGE_FLAGS
  142. },
  143. {
  144. IDD_UNATTENDMODE,
  145. DlgUnattendModePage,
  146. IDS_UNATTENDMODE_TITLE,
  147. IDS_UNATTENDMODE_SUBTITLE,
  148. DEFAULT_PAGE_FLAGS
  149. },
  150. {
  151. IDD_STANDALONE,
  152. DlgStandAlonePage,
  153. IDS_STANDALONE_TITLE,
  154. IDS_STANDALONE_SUBTITLE,
  155. DEFAULT_PAGE_FLAGS
  156. },
  157. {
  158. IDD_COPYFILES1,
  159. DlgCopyFiles1Page,
  160. IDS_COPYFILES1_TITLE,
  161. IDS_COPYFILES1_SUBTITLE,
  162. DEFAULT_PAGE_FLAGS
  163. },
  164. {
  165. IDD_DISTFOLDER,
  166. DlgDistFolderPage,
  167. IDS_DISTFOLD_TITLE,
  168. IDS_DISTFOLD_SUBTITLE,
  169. DEFAULT_PAGE_FLAGS
  170. },
  171. {
  172. IDD_LICENSEAGREEMENT,
  173. DlgLicensePage,
  174. IDS_LICENSEAGREEMENT_TITLE,
  175. IDS_LICENSEAGREEMENT_SUBTITLE,
  176. DEFAULT_PAGE_FLAGS
  177. },
  178. {
  179. IDD_SYSPREPLICENSEAGREEMENT,
  180. DlgSysprepLicensePage,
  181. IDS_LICENSEAGREEMENT_TITLE,
  182. IDS_LICENSEAGREEMENT_SUBTITLE,
  183. DEFAULT_PAGE_FLAGS
  184. },
  185. };
  186. static TREEDLG vdpOEMTreeDialogs[] =
  187. {
  188. {
  189. 0,
  190. NULL,
  191. IDS_DLG_GENERAL,
  192. IDS_DLG_GENERAL,
  193. NULL,
  194. NULL,
  195. TRUE
  196. },
  197. {
  198. IDD_MODE,
  199. ModeDlgProc,
  200. IDS_MODE_TITLE,
  201. IDS_MODE_SUBTITLE,
  202. NULL,
  203. NULL,
  204. TRUE
  205. },
  206. {
  207. IDD_SKU,
  208. SkuDlgProc,
  209. IDS_SKU_TITLE,
  210. IDS_SKU_SUBTITLE,
  211. NULL,
  212. NULL,
  213. TRUE
  214. },
  215. {
  216. IDD_OEMINFO,
  217. OemInfoDlgProc,
  218. IDS_OEMINFO_TITLE,
  219. IDS_OEMINFO_SUBTITLE,
  220. NULL,
  221. NULL,
  222. TRUE
  223. },
  224. {
  225. IDD_PRODUCTKEY,
  226. ProductKeyDlgProc,
  227. IDS_PRODUCTKEY_TITLE,
  228. IDS_PRODUCTKEY_SUBTITLE,
  229. NULL,
  230. NULL,
  231. TRUE
  232. },
  233. {
  234. IDD_APPINSTALL,
  235. AppInstallDlgProc,
  236. IDS_APPINSTALL_TITLE,
  237. IDS_APPINSTALL_SUBTITLE,
  238. NULL,
  239. NULL,
  240. TRUE
  241. },
  242. {
  243. IDD_LOGO,
  244. LogoDlgProc,
  245. IDS_LOGO_TITLE,
  246. IDS_LOGO_SUBTITLE,
  247. NULL,
  248. NULL,
  249. TRUE
  250. },
  251. {
  252. 0,
  253. NULL,
  254. IDS_DLG_OOBE,
  255. IDS_DLG_OOBE,
  256. NULL,
  257. NULL,
  258. TRUE
  259. },
  260. {
  261. IDD_OOBECUST,
  262. OobeCustDlgProc,
  263. IDS_OOBECUST_TITLE,
  264. IDS_OOBECUST_SUBTITLE,
  265. NULL,
  266. NULL,
  267. TRUE
  268. },
  269. {
  270. IDD_SCREENSTWO,
  271. ScreensTwoDlgProc,
  272. IDS_SCREENSTWO_TITLE,
  273. IDS_SCREENSTWO_SUBTITLE,
  274. NULL,
  275. NULL,
  276. TRUE
  277. },
  278. {
  279. IDD_SCREENS,
  280. ScreensDlgProc,
  281. IDS_SCREENS_TITLE,
  282. IDS_SCREENS_SUBTITLE,
  283. NULL,
  284. NULL,
  285. TRUE
  286. },
  287. {
  288. IDD_OOBEUSB,
  289. OobeUSBDlgProc,
  290. IDS_OOBEUSB_TITLE,
  291. IDS_OOBEUSB_SUBTITLE,
  292. NULL,
  293. NULL,
  294. TRUE
  295. },
  296. {
  297. IDD_ISP,
  298. IspDlgProc,
  299. IDS_ISP_TITLE,
  300. IDS_ISP_SUBTITLE,
  301. NULL,
  302. NULL,
  303. TRUE
  304. },
  305. #ifdef HELPCENTER
  306. {
  307. IDD_HELPCENT,
  308. HelpCenterDlgProc,
  309. IDS_HELPCENT_TITLE,
  310. IDS_HELPCENT_SUBTITLE,
  311. NULL,
  312. NULL,
  313. TRUE
  314. },
  315. #endif
  316. {
  317. 0,
  318. NULL,
  319. IDS_DLG_IEAK,
  320. IDS_DLG_IEAK,
  321. NULL,
  322. NULL,
  323. TRUE
  324. },
  325. #ifdef OEMCUST
  326. {
  327. IDD_OEMCUST,
  328. OemCustDlgProc,
  329. IDS_OEMCUST_TITLE,
  330. IDS_OEMCUST_SUBTITLE,
  331. NULL,
  332. NULL,
  333. TRUE
  334. },
  335. #endif // OEMCUST
  336. #ifdef BRANDTITLE
  337. {
  338. IDD_BTITLE,
  339. BrandTitleDlgProc,
  340. IDS_BTITLE_TITLE,
  341. IDS_BTITLE_SUBTITLE,
  342. NULL,
  343. NULL,
  344. TRUE
  345. },
  346. #endif // BRANDTITLE
  347. {
  348. IDD_BTOOLBARS,
  349. BToolbarsDlgProc,
  350. IDS_BTOOLBARS_TITLE,
  351. IDS_BTOOLBARS_SUBTITLE,
  352. NULL,
  353. NULL,
  354. TRUE
  355. },
  356. {
  357. IDD_STARTSEARCH,
  358. StartSearchDlgProc,
  359. IDS_STARTSEARCH_TITLE,
  360. IDS_STARTSEARCH_SUBTITLE,
  361. NULL,
  362. NULL,
  363. TRUE
  364. },
  365. {
  366. IDD_FAVORITES,
  367. FavoritesDlgProc,
  368. IDS_FAVORITES_TITLE,
  369. IDS_FAVORITES_SUBTITLE,
  370. NULL,
  371. NULL,
  372. TRUE
  373. },
  374. {
  375. 0,
  376. NULL,
  377. IDS_DLG_SHELLSETTINGS,
  378. IDS_DLG_SHELLSETTINGS,
  379. NULL,
  380. NULL,
  381. TRUE
  382. },
  383. {
  384. IDD_STARTMENU,
  385. StartMenuDlgProc,
  386. IDS_STARTMENU_TITLE,
  387. IDS_STARTMENU_SUBTITLE,
  388. NULL,
  389. NULL,
  390. TRUE
  391. },
  392. {
  393. IDD_OEMLINK,
  394. OemLinkDlgProc,
  395. IDS_OEMLINK_TITLE,
  396. IDS_OEMLINK_SUBTITLE,
  397. NULL,
  398. NULL,
  399. TRUE
  400. },
  401. };
  402. static TREEDLG vdpCDTreeDialogs[] =
  403. {
  404. {
  405. 0,
  406. NULL,
  407. IDS_DLG_GENERAL,
  408. IDS_DLG_GENERAL,
  409. NULL,
  410. NULL,
  411. TRUE
  412. },
  413. {
  414. IDD_NAMEORG,
  415. DlgNameOrgPage,
  416. IDS_NAMEORG_TITLE,
  417. IDS_NAMEORG_SUBTITLE,
  418. NULL,
  419. NULL,
  420. TRUE
  421. },
  422. {
  423. IDD_DISPLAY,
  424. DlgDisplayPage,
  425. IDS_DISPLAY_TITLE,
  426. IDS_DISPLAY_SUBTITLE,
  427. NULL,
  428. NULL,
  429. TRUE
  430. },
  431. {
  432. IDD_TIMEZONE,
  433. DlgTimeZonePage,
  434. IDS_TIMEZONE_TITLE,
  435. IDS_TIMEZONE_SUBTITLE,
  436. NULL,
  437. NULL,
  438. TRUE
  439. },
  440. {
  441. IDD_PID_CD,
  442. DlgProductIdPage,
  443. IDS_PID_TITLE,
  444. IDS_PID_SUBTITLE,
  445. NULL,
  446. NULL,
  447. TRUE
  448. },
  449. {
  450. 0,
  451. NULL,
  452. IDS_DLG_NETWORK,
  453. IDS_DLG_NETWORK,
  454. NULL,
  455. NULL,
  456. TRUE
  457. },
  458. {
  459. IDD_SRVLICENSE,
  460. DlgSrvLicensePage,
  461. IDS_SRVLICENSE_TITLE,
  462. IDS_SRVLICENSE_SUBTITLE,
  463. NULL,
  464. NULL,
  465. FALSE
  466. },
  467. {
  468. IDD_COMPUTERNAME,
  469. DlgComputerNamePage,
  470. IDS_COMPNAME_TITLE,
  471. IDS_COMPNAME_SUBTITLE,
  472. NULL,
  473. NULL,
  474. TRUE
  475. },
  476. {
  477. IDD_SYSPREPCOMPUTERNAME,
  478. DlgSysprepComputerNamePage,
  479. IDS_SYSPREP_COMPNAME_TITLE,
  480. IDS_SYSPREP_COMPNAME_SUBTITLE,
  481. NULL,
  482. NULL,
  483. TRUE
  484. },
  485. {
  486. IDD_ADMINPASSWORD,
  487. DlgAdminPasswordPage,
  488. IDS_ADMINPASSWD_TITLE,
  489. IDS_ADMINPASSWD_SUBTITLE,
  490. NULL,
  491. NULL,
  492. TRUE
  493. },
  494. {
  495. IDD_LANWIZ_DLG,
  496. DlgLANWizardPage,
  497. IDS_LANWIZ_TITLE,
  498. IDS_LANWIZ_SUBTITLE,
  499. NULL,
  500. NULL,
  501. TRUE
  502. },
  503. {
  504. IDD_DOMAINJ,
  505. DlgDomainJoinPage,
  506. IDS_DOMAINJ_TITLE,
  507. IDS_DOMAINJ_SUBTITLE,
  508. NULL,
  509. NULL,
  510. TRUE
  511. },
  512. {
  513. 0,
  514. NULL,
  515. IDS_DLG_ADVANCED,
  516. IDS_DLG_ADVANCED,
  517. NULL,
  518. NULL,
  519. TRUE
  520. },
  521. // If we define OPTCOMP we will display the optional components page otherwise this will be hidden. This page was removed
  522. // for ISSUE: 628520
  523. //
  524. #ifdef OPTCOMP
  525. {
  526. IDD_OPTCOMP,
  527. OptionalCompDlgProc,
  528. IDS_OPTCOMP_TITLE,
  529. IDS_OPTCOMP_SUBTITLE,
  530. NULL,
  531. NULL,
  532. TRUE
  533. },
  534. #endif
  535. {
  536. IDD_TAPI,
  537. DlgTapiPage,
  538. IDS_TAPI_TITLE,
  539. IDS_TAPI_SUBTITLE,
  540. NULL,
  541. NULL,
  542. TRUE
  543. },
  544. {
  545. IDD_REGIONALSETTINGS,
  546. DlgRegionalSettingsPage,
  547. IDS_REGIONAL_TITLE,
  548. IDS_REGIONAL_SUBTITLE,
  549. NULL,
  550. NULL,
  551. TRUE
  552. },
  553. {
  554. IDD_LANGUAGESETTINGS,
  555. DlgLangSettingsPage,
  556. IDS_LANGUAGES_TITLE,
  557. IDS_LANGUAGES_SUBTITLE,
  558. NULL,
  559. NULL,
  560. TRUE
  561. },
  562. {
  563. IDD_IE,
  564. DlgIePage,
  565. IDS_IE_TITLE,
  566. IDS_IE_SUBTITLE,
  567. NULL,
  568. NULL,
  569. TRUE
  570. },
  571. {
  572. IDD_TARGETPATH,
  573. DlgTargetPathPage,
  574. IDS_TARGETPATH_TITLE,
  575. IDS_TARGETPATH_SUBTITLE,
  576. NULL,
  577. NULL,
  578. TRUE
  579. },
  580. {
  581. IDD_PRINTERS,
  582. DlgPrintersPage,
  583. IDS_PRINTERS_TITLE,
  584. IDS_PRINTERS_SUBTITLE,
  585. NULL,
  586. NULL,
  587. TRUE
  588. },
  589. {
  590. IDD_RUNONCE,
  591. DlgRunOncePage,
  592. IDS_RUNONCE_TITLE,
  593. IDS_RUNONCE_SUBTITLE,
  594. NULL,
  595. NULL,
  596. TRUE
  597. },
  598. {
  599. IDD_CMDLINES,
  600. DlgCommandLinesPage,
  601. IDS_CMDLINES_TITLE,
  602. IDS_CMDLINES_SUBTITLE,
  603. NULL,
  604. NULL,
  605. TRUE
  606. },
  607. {
  608. IDD_SIFTEXT,
  609. DlgSifTextSettingsPage,
  610. IDS_SIF_TEXT_TITLE,
  611. IDS_SIF_TEXT_SUBTITLE,
  612. NULL,
  613. NULL,
  614. TRUE
  615. },
  616. {
  617. IDD_OEMDUPSTRING,
  618. DlgOemDuplicatorStringPage,
  619. IDS_OEM_DUP_STRING_TITLE,
  620. IDS_OEM_DUP_STRING_SUBTITLE,
  621. NULL,
  622. NULL,
  623. TRUE
  624. },
  625. };
  626. static SPLASHDLG vdpSplashDialogs[] =
  627. {
  628. {
  629. IDD_COMPLETE,
  630. CompleteDlgProc,
  631. NULL
  632. },
  633. {
  634. IDD_FINISH,
  635. DlgFinishPage,
  636. NULL
  637. },
  638. };
  639. //
  640. // Global Variable(s):
  641. //
  642. HWND g_hCurrentDialog; // Current dialog being displayed by the tree view
  643. DWORD g_dwWizardPages; // Total number of wizard pages for initial wizard
  644. DWORD g_dwTreePages; // Total number of pages for tree view control
  645. //----------------------------------------------------------------------------
  646. //
  647. // Function: CreateWizard
  648. //
  649. // Purpose: This function is responsible for creating the initial wizard
  650. //
  651. //----------------------------------------------------------------------------
  652. int CreateWizard(HINSTANCE hInstance, HWND hWndParent)
  653. {
  654. // Local variables.
  655. //
  656. PROPSHEETHEADER PropSheetHeader;
  657. PROPSHEETPAGE PropPage;
  658. HPROPSHEETPAGE *PageHandles;
  659. WIZDLG *pPage;
  660. DWORD nIndex = 0;
  661. int nReturn = 0;
  662. // Zero out this memory we are going to use
  663. //
  664. ZeroMemory(&PropSheetHeader, sizeof(PROPSHEETHEADER));
  665. ZeroMemory(&PropPage, sizeof(PROPSHEETPAGE));
  666. // Allocate the buffer for the handles to the wizard pages
  667. //
  668. if ((PageHandles = MALLOC(g_dwWizardPages * sizeof(HPROPSHEETPAGE))) != NULL )
  669. {
  670. // Setup all the property sheet pages.
  671. //
  672. for ( nIndex=0; nIndex<g_dwWizardPages; nIndex++ )
  673. {
  674. // Assign all the values for this property sheet.
  675. //
  676. pPage = (GET_FLAG(OPK_OEM) ? &vdpOEMWizardDialogs[nIndex] : &vdpCDWizardDialogs[nIndex]);
  677. PropPage.dwSize = sizeof(PROPSHEETPAGE);
  678. PropPage.hInstance = hInstance;
  679. PropPage.pszTemplate = MAKEINTRESOURCE(pPage->dwResource);
  680. PropPage.pszHeaderTitle = MAKEINTRESOURCE(pPage->dwTitle);
  681. PropPage.pszHeaderSubTitle = MAKEINTRESOURCE(pPage->dwSubTitle);
  682. PropPage.pfnDlgProc = pPage->dlgWindowProc;
  683. PropPage.dwFlags = pPage->dwFlags;
  684. // If there is no help file, don't show the help.
  685. //
  686. if ( !EXIST(g_App.szHelpFile) )
  687. PropPage.dwFlags &= ~PSP_HASHELP;
  688. #ifndef USEHELP
  689. PropPage.dwFlags &= ~PSP_HASHELP;
  690. #endif
  691. // Dynamically create the property sheet
  692. //
  693. PageHandles[nIndex] = CreatePropertySheetPage(&PropPage);
  694. }
  695. // Setup the property sheet header.
  696. //
  697. PropSheetHeader.dwSize = sizeof(PROPSHEETHEADER);
  698. PropSheetHeader.dwFlags = PSH_WIZARD97 |
  699. PSH_WATERMARK |
  700. #ifdef USEHELP
  701. PSH_HASHELP |
  702. #endif
  703. PSH_HEADER |
  704. PSH_USEICONID |
  705. PSH_USECALLBACK;
  706. PropSheetHeader.hInstance = hInstance;
  707. PropSheetHeader.hwndParent = hWndParent;
  708. PropSheetHeader.pszCaption = NULL;
  709. PropSheetHeader.phpage = PageHandles;
  710. PropSheetHeader.nStartPage = 0;
  711. PropSheetHeader.nPages = g_dwWizardPages;
  712. PropSheetHeader.pszbmWatermark = MAKEINTRESOURCE(IDB_WATERMARK);
  713. PropSheetHeader.pszbmHeader = MAKEINTRESOURCE(IDB_BANNER);
  714. PropSheetHeader.pszIcon = MAKEINTRESOURCE(IDI_SETUPMGR);
  715. PropSheetHeader.pfnCallback = WizardCallbackProc;
  716. // We are activating the wizard
  717. //
  718. SET_FLAG(OPK_ACTIVEWIZ, TRUE);
  719. // Run the wizard.
  720. //
  721. nReturn = (int) PropertySheet(&PropSheetHeader);
  722. // We are done with the wizard
  723. //
  724. SET_FLAG(OPK_ACTIVEWIZ, FALSE);
  725. // Clean up the allocated memory
  726. //
  727. FREE(PageHandles);
  728. }
  729. else
  730. {
  731. // We were unable to allocate memory
  732. //
  733. MsgBox(hWndParent, IDS_OUTOFMEM, IDS_APPNAME, MB_ERRORBOX);
  734. }
  735. return nReturn;
  736. }
  737. //----------------------------------------------------------------------------
  738. //
  739. // Function: CreateMaintenanceWizard
  740. //
  741. // Purpose: This function creates the maintenance dialog, the main dialog for
  742. // Setup Manager
  743. //
  744. //----------------------------------------------------------------------------
  745. int CreateMaintenanceWizard(HINSTANCE hInstance, HWND hWndParent)
  746. {
  747. TCHAR szMessage[MAX_PATH] = NULLSTR;
  748. HWND hChild;
  749. INITCOMMONCONTROLSEX icc;
  750. // ISSUE-2002/02/28-stelo- Both the parameters are not being used. ASSERT on Invalid Parameters if used.
  751. // Set the global wizard pages sizes based on OEM tag file
  752. //
  753. g_dwWizardPages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMWizardDialogs) : sizeof(vdpCDWizardDialogs)) / sizeof(WIZDLG));
  754. g_dwTreePages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMTreeDialogs) : sizeof(vdpCDTreeDialogs)) / sizeof(TREEDLG));
  755. // Make sure the common controls are loaded and ready to use.
  756. //
  757. icc.dwSize = sizeof(icc);
  758. icc.dwICC = ICC_WIN95_CLASSES; // loads most commonly used WIN95 classes.
  759. InitCommonControlsEx(&icc);
  760. return( (int) DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_MAINT), NULL, MaintDlgProc) );
  761. }
  762. int CALLBACK WizardCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam)
  763. {
  764. if ( uMsg==PSCB_INITIALIZED )
  765. WizardSubWndProc(hwnd, WM_SUBWNDPROC, 0, 0L);
  766. return 1;
  767. }
  768. LONG CALLBACK WizardSubWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  769. {
  770. static FARPROC lpfnOldProc = NULL;
  771. switch ( msg )
  772. {
  773. case WM_SUBWNDPROC:
  774. lpfnOldProc = (FARPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
  775. SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WizardSubWndProc);
  776. return 1;
  777. case WM_HELP:
  778. WIZ_HELP();
  779. break;
  780. }
  781. if ( lpfnOldProc )
  782. return (LONG) CallWindowProc((WNDPROC) lpfnOldProc, hwnd, msg, wParam, lParam);
  783. else
  784. return 0;
  785. }
  786. //----------------------------------------------------------------------------
  787. //
  788. // Function: MaintDlgProc
  789. //
  790. // Purpose: Main Dialog Proc for Setup Manager
  791. //
  792. //----------------------------------------------------------------------------
  793. LRESULT CALLBACK MaintDlgProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
  794. {
  795. static HMENU hMenu;
  796. switch (uMsg)
  797. {
  798. HANDLE_MSG(hwnd, WM_COMMAND, OnCommand);
  799. case WM_CLOSE:
  800. {
  801. // Exit the maintenence wizard all together
  802. //
  803. if ( !GET_FLAG(OPK_CREATED) || CloseProfile(hwnd, TRUE) )
  804. EndDialog(hwnd, 0);
  805. else
  806. return TRUE;
  807. }
  808. break;
  809. case WM_INITDIALOG:
  810. {
  811. DWORD dwResult;
  812. RECT rectHelp, rectCancel, rectBack, rectNext;
  813. // Load the menu for the maintenance dialog
  814. //
  815. if (hMenu = LoadMenu(g_App.hInstance, GET_FLAG(OPK_OEM) ? MAKEINTRESOURCE(IDR_MAIN_OEM) : MAKEINTRESOURCE(IDR_MAIN_CORP)))
  816. SetMenu(hwnd, hMenu);
  817. if ( !EXIST(g_App.szHelpContentFile) )
  818. EnableMenuItem(GetMenu(hwnd), ID_HELP_CONTENTS, MF_GRAYED);
  819. if ( !EXIST(g_App.szHelpFile) )
  820. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), FALSE);
  821. #ifndef USEHELP
  822. // We are no longer using the help button, we should hide this and move the other controls over
  823. //
  824. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), FALSE);
  825. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), SW_HIDE);
  826. // Move the other buttons to the right
  827. //
  828. if ( GetWindowRect(GetDlgItem(hwnd, IDC_MAINT_HELP), &rectHelp) &&
  829. GetWindowRect(GetDlgItem(hwnd, IDCANCEL), &rectCancel) &&
  830. GetWindowRect(GetDlgItem(hwnd, ID_MAINT_BACK), &rectBack) &&
  831. GetWindowRect(GetDlgItem(hwnd, ID_MAINT_NEXT), &rectNext)
  832. )
  833. {
  834. LONG lDelta = 0;
  835. // Map the coordinates to the screen
  836. //
  837. MapWindowPoints(NULL, hwnd, (LPPOINT) &rectHelp, 2);
  838. MapWindowPoints(NULL, hwnd, (LPPOINT) &rectCancel, 2);
  839. MapWindowPoints(NULL, hwnd, (LPPOINT) &rectBack, 2);
  840. MapWindowPoints(NULL, hwnd, (LPPOINT) &rectNext, 2);
  841. // Determine the delta
  842. //
  843. lDelta = rectHelp.left - rectCancel.left;
  844. // Set the new window position
  845. //
  846. SetWindowPos(GetDlgItem(hwnd, IDCANCEL), NULL, rectCancel.left+lDelta, rectCancel.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  847. SetWindowPos(GetDlgItem(hwnd, ID_MAINT_BACK), NULL, rectBack.left+lDelta, rectBack.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  848. SetWindowPos(GetDlgItem(hwnd, ID_MAINT_NEXT), NULL, rectNext.left+lDelta, rectNext.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  849. }
  850. #endif
  851. // Load the icon into the wizard window
  852. //
  853. SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR) LoadIcon(g_App.hInstance, MAKEINTRESOURCE(IDI_OPKSETUP)));
  854. // Make the title text bold
  855. //
  856. SetWindowFont(GetDlgItem(hwnd, IDC_MAINT_TITLE), FixedGlobals.hBoldFont, TRUE);
  857. // Show the Maintenance Wizard
  858. //
  859. ShowWindow(hwnd, SW_SHOW);
  860. // Create the Wizard dialog
  861. //
  862. dwResult = CreateWizard(g_App.hInstance, hwnd);
  863. // Populate the tree dialog
  864. //
  865. FillTreeDialog(hwnd);
  866. if ( !dwResult )
  867. {
  868. CloseProfile(hwnd, FALSE);
  869. return FALSE;
  870. }
  871. // Enable the tree view
  872. //
  873. EnableWindow(GetDlgItem(hwnd, IDC_PAGES), TRUE);
  874. // Select the first child after the last wizard dialog
  875. //
  876. if ( !GET_FLAG(OPK_MAINTMODE) )
  877. SelectFirstMaintenanceDlg(hwnd);
  878. // Set the focus to the maintenance wizard so we can use shortcuts
  879. //
  880. SetFocus(hwnd);
  881. }
  882. return FALSE;
  883. case WM_NOTIFY:
  884. switch ( ((NMHDR FAR *) lParam)->code )
  885. {
  886. case TVN_SELCHANGING:
  887. {
  888. NMHDR mhdr;
  889. // Create the notification message for the wizard page
  890. //
  891. mhdr.code = PSN_WIZNEXT;
  892. // Send the notification message and if we return false, then do not change the page
  893. //
  894. if (SendMessage(g_hCurrentDialog, WM_NOTIFY, (WPARAM) 0, (LPARAM) &mhdr) == -1)
  895. WIZ_RESULT(hwnd, TRUE);
  896. }
  897. return TRUE;
  898. case TVN_SELCHANGED:
  899. {
  900. HTREEITEM hItem;
  901. DWORD dwIndex;
  902. LPTREEDLG lpWizard = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  903. // Selection's been changed, now modify the buttons
  904. //
  905. EnableControls(hwnd);
  906. // Get the current selection and display the dialog
  907. //
  908. if (hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_PAGES)))
  909. {
  910. for(dwIndex=0;dwIndex < g_dwTreePages; dwIndex++, lpWizard++)
  911. {
  912. if ( lpWizard->hItem == hItem )
  913. ShowTreeDialog(hwnd, lpWizard);
  914. }
  915. }
  916. }
  917. case PSN_SETACTIVE:
  918. if (g_hCurrentDialog)
  919. SendMessage(g_hCurrentDialog, WM_NOTIFY, wParam, lParam);
  920. break;
  921. }
  922. case WM_KEYDOWN:
  923. if ( wParam == 18225 )
  924. break;
  925. switch ( wParam )
  926. {
  927. case VK_F1:
  928. {
  929. DWORD dwVal = (DWORD) wParam,
  930. dwVal2 = (DWORD) lParam;
  931. }
  932. }
  933. break;
  934. case PSM_PRESSBUTTON:
  935. switch ( (int) wParam )
  936. {
  937. case PSBTN_FINISH:
  938. break;
  939. case PSBTN_NEXT:
  940. // Selects the Next button.
  941. //
  942. SendMessage(GetDlgItem(hwnd, ID_MAINT_NEXT), BM_CLICK, 0, 0L);
  943. break;
  944. case PSBTN_BACK:
  945. // Selects the Back button.
  946. //
  947. SendMessage(GetDlgItem(hwnd, ID_MAINT_BACK), BM_CLICK, 0, 0L);
  948. break;
  949. case PSBTN_CANCEL:
  950. // Selects the Cancel button.
  951. //
  952. SendMessage(GetDlgItem(hwnd, IDCANCEL), BM_CLICK, 0, 0L);
  953. break;
  954. case PSBTN_HELP:
  955. // Selects the Help button.
  956. //
  957. SendMessage(GetDlgItem(hwnd, IDC_MAINT_HELP), BM_CLICK, 0, 0L);
  958. break;
  959. case PSBTN_OK:
  960. // Selects the OK button.
  961. //
  962. break;
  963. case PSBTN_APPLYNOW:
  964. // Selects the Apply button.
  965. //
  966. break;
  967. }
  968. break;
  969. default:
  970. return FALSE;
  971. }
  972. return FALSE;
  973. }
  974. //----------------------------------------------------------------------------
  975. //
  976. // Function: TreeAddItem
  977. //
  978. // Purpose: Adds an item to the tree view returning a handle to that item
  979. //
  980. //----------------------------------------------------------------------------
  981. static HTREEITEM TreeAddItem(HWND hwndTV, HTREEITEM hTreeParent, LPTSTR lpszItem)
  982. {
  983. TVITEM tvI;
  984. TVINSERTSTRUCT tvIns;
  985. if ( !lpszItem )
  986. return NULL;
  987. ZeroMemory(&tvI, sizeof(TVITEM));
  988. tvI.pszText = lpszItem;
  989. tvI.mask = TVIF_TEXT;
  990. tvI.cchTextMax = lstrlen(tvI.pszText);
  991. ZeroMemory(&tvIns, sizeof(TVINSERTSTRUCT));
  992. tvIns.item = tvI;
  993. tvIns.hInsertAfter = TVI_LAST;
  994. tvIns.hParent = hTreeParent;
  995. // Insert the item into the tree.
  996. //
  997. return TreeView_InsertItem(hwndTV, &tvIns);
  998. }
  999. //----------------------------------------------------------------------------
  1000. //
  1001. // Function: OnCommand
  1002. //
  1003. // Purpose: Processes the Commands of the Main Dialog Proc
  1004. //
  1005. //----------------------------------------------------------------------------
  1006. static void OnCommand(HWND hwnd, INT id, HWND hwndCtl, UINT codeNotify)
  1007. {
  1008. HTREEITEM hItem;
  1009. switch ( id )
  1010. {
  1011. case ID_MAINT_NEXT:
  1012. case ID_MAINT_BACK:
  1013. {
  1014. BOOL bReturn = FALSE;
  1015. LPTSTR lpStringNext = NULL;
  1016. TCHAR szStringButton[MAX_PATH];
  1017. // Determine if the user has pressed the Finish button
  1018. //
  1019. if ( (id == ID_MAINT_NEXT) &&
  1020. (lpStringNext = AllocateString(NULL, IDS_FINISH)) &&
  1021. (GetDlgItemText(hwnd, ID_MAINT_NEXT, szStringButton, STRSIZE(szStringButton))))
  1022. {
  1023. if(!lstrcmpi(lpStringNext, szStringButton))
  1024. {
  1025. SaveProfile(hwnd);
  1026. bReturn = TRUE;
  1027. }
  1028. }
  1029. // Free the allocated string
  1030. //
  1031. FREE(lpStringNext);
  1032. // If the Finish button was not pressed, move to the next page
  1033. //
  1034. if ( !bReturn )
  1035. SelectTreeItem(hwnd, TreeView_GetSelection(GetDlgItem(hwnd, IDC_PAGES)), (id == ID_MAINT_NEXT ? TVGN_NEXTVISIBLE : TVGN_PREVIOUSVISIBLE) );
  1036. break;
  1037. }
  1038. case IDCANCEL:
  1039. PostMessage(hwnd, WM_CLOSE, 0, 0L);
  1040. break;
  1041. case IDC_MAINT_HELP:
  1042. WIZ_HELP();
  1043. break;
  1044. case ID_FILE_SAVE:
  1045. case ID_FILE_SAVEAS:
  1046. SaveProfile(hwnd);
  1047. break;
  1048. case ID_FILE_CLOSE:
  1049. // We are going to close the config set but keep the maint wizard open
  1050. //
  1051. CloseProfile(hwnd, TRUE);
  1052. break;
  1053. case ID_FILE_NEW:
  1054. case ID_FILE_OPEN:
  1055. // We want to open the config set if:
  1056. // 1) There is now current config set open
  1057. // 2) There is a config set open and then closed
  1058. if ((!GET_FLAG(OPK_CREATED)) ||
  1059. (GET_FLAG(OPK_CREATED) && CloseProfile(hwnd, TRUE)))
  1060. {
  1061. // We are going to open an existing config set
  1062. //
  1063. OpenProfile(hwnd, (id == ID_FILE_NEW ? TRUE : FALSE));
  1064. }
  1065. break;
  1066. case ID_FILE_EXIT:
  1067. SendMessage(hwnd, WM_CLOSE, (WPARAM) 0, (LPARAM) 0);
  1068. break;
  1069. case ID_TOOLS_SHARE:
  1070. DistributionShareDialog(hwnd);
  1071. break;
  1072. case ID_TOOLS_SKUS:
  1073. ManageLangSku(hwnd);
  1074. break;
  1075. case ID_HELP_ABOUT:
  1076. DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_ABOUT), hwnd, (DLGPROC) AboutDlgProc);
  1077. break;
  1078. case ID_HELP_CONTENTS:
  1079. HtmlHelp(hwnd, g_App.szHelpContentFile, HH_DISPLAY_TOC, 0);
  1080. break;
  1081. }
  1082. }
  1083. //----------------------------------------------------------------------------
  1084. //
  1085. // Function: ShowTreeDialog
  1086. //
  1087. // Purpose: This function Creates a wizard dialog and places it on the maintenance page
  1088. //
  1089. //----------------------------------------------------------------------------
  1090. static void ShowTreeDialog(HWND hwnd, LPTREEDLG lpTreeDlg)
  1091. {
  1092. RECT rc;
  1093. LPTSTR lpTitle = NULL,
  1094. lpSubTitle = NULL;
  1095. NMHDR mhdr;
  1096. // Hide the current dialog
  1097. //
  1098. if ( g_hCurrentDialog ) {
  1099. ShowWindow(g_hCurrentDialog, SW_HIDE);
  1100. EnableWindow(g_hCurrentDialog, FALSE);
  1101. }
  1102. // Show the dialog if it exists or create/show if it does not
  1103. //
  1104. // ISSUE-2002/02/28-stelo- Check for the validity of LPTREEDLG variable
  1105. if ( lpTreeDlg->hWindow || (lpTreeDlg->hWindow = CreateDialog(g_App.hInstance, MAKEINTRESOURCE(lpTreeDlg->dwResource), hwnd, lpTreeDlg->dlgWindowProc )))
  1106. {
  1107. // Create the buffers for the title and subtitle
  1108. //
  1109. if ( (lpTitle = AllocateString(NULL, PtrToUint(MAKEINTRESOURCE(lpTreeDlg->dwTitle)))) != NULL &&
  1110. (lpSubTitle = AllocateString(NULL, PtrToUint(MAKEINTRESOURCE(lpTreeDlg->dwSubTitle)))) != NULL )
  1111. {
  1112. // Set up the title and subtitle for this dialog
  1113. //
  1114. SetDlgItemText(hwnd, IDC_MAINT_TITLE, lpTitle);
  1115. SetDlgItemText(hwnd, IDC_MAINT_SUBTITLE, lpSubTitle);
  1116. }
  1117. // Free the memory as we don't need it anymore
  1118. //
  1119. FREE(lpTitle);
  1120. FREE(lpSubTitle);
  1121. // Position the wizard dialog on the maintenance page and display it
  1122. //
  1123. GetWindowRect(GetDlgItem(hwnd, IDC_WIZARDFRAME) , &rc);
  1124. MapWindowPoints(NULL, hwnd, (LPPOINT) &rc, 2);
  1125. SetWindowPos(lpTreeDlg->hWindow, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  1126. ShowWindow( lpTreeDlg->hWindow, SW_SHOW );
  1127. EnableWindow(lpTreeDlg->hWindow, TRUE);
  1128. // We need to know what the current dialog is
  1129. //
  1130. g_hCurrentDialog = lpTreeDlg->hWindow;
  1131. // Create the notification message for the wizard page
  1132. //
  1133. mhdr.code = PSN_SETACTIVE;
  1134. // Send the notification message and if we return false, then do not change the page
  1135. //
  1136. if ( SendMessage(lpTreeDlg->hWindow, WM_NOTIFY, (WPARAM) 0, (LPARAM) &mhdr) == -1 )
  1137. {
  1138. // TODO: We should handle when we want to fail the set active.
  1139. //
  1140. }
  1141. }
  1142. }
  1143. //----------------------------------------------------------------------------
  1144. //
  1145. // Function: FillTreeDialog
  1146. //
  1147. // Purpose: Fills the Tree Dialog with the appropriate items
  1148. //
  1149. //----------------------------------------------------------------------------
  1150. static void FillTreeDialog(HWND hwnd)
  1151. {
  1152. DWORD dwPage,
  1153. dwResult,
  1154. dwLastResource;
  1155. HTREEITEM hCurrentGroup = NULL;
  1156. LPTSTR lpHeader;
  1157. HTREEITEM hItem;
  1158. HWND hTreeView = GetDlgItem(hwnd, IDC_PAGES);
  1159. LPTREEDLG lpWizard = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1160. // Remove all items first
  1161. //
  1162. TreeView_DeleteAllItems(hTreeView);
  1163. // Update the items that should and should not be visible
  1164. //
  1165. UpdateTreeVisibility(hwnd);
  1166. // Loop through all the pages and add them to the tree view
  1167. //
  1168. for ( dwPage = 0; dwPage < g_dwTreePages; dwPage++, lpWizard++ )
  1169. {
  1170. if ( lpWizard->bVisible &&
  1171. (lpHeader = AllocateString(NULL, lpWizard->dwTitle)) != NULL )
  1172. {
  1173. // If a resource exists then it is a dialog, otherwise it's a group header
  1174. //
  1175. if ( lpWizard->dwResource )
  1176. lpWizard->hItem = TreeAddItem(hTreeView, hCurrentGroup, lpHeader);
  1177. else
  1178. hCurrentGroup = TreeAddItem(hTreeView, NULL, lpHeader);
  1179. // Expand the current group
  1180. //
  1181. TreeView_Expand(hTreeView, hCurrentGroup, TVE_EXPAND);
  1182. // Free the header, as it's no longer needed
  1183. //
  1184. FREE(lpHeader);
  1185. }
  1186. }
  1187. // Select the first child
  1188. //
  1189. TreeView_SelectItem(hTreeView, (hItem = TreeView_GetFirstVisible(hTreeView)));
  1190. TreeView_SelectItem(hTreeView, (hItem = TreeView_GetNextVisible(hTreeView, hItem)));
  1191. }
  1192. //----------------------------------------------------------------------------
  1193. //
  1194. // Function: UpdateTreeVisibility
  1195. //
  1196. // Purpose: This function is used to update each item's bVisible property. At
  1197. // runtime certain variables may change that will change whether or not
  1198. // a page is displayed. This function handles those changes
  1199. //
  1200. //----------------------------------------------------------------------------
  1201. static void UpdateTreeVisibility(HWND hwnd)
  1202. {
  1203. DWORD dwPage;
  1204. LPTREEDLG lpWizard = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1205. for ( dwPage = 0; dwPage < g_dwTreePages; dwPage++, lpWizard++ )
  1206. {
  1207. switch ( lpWizard->dwResource )
  1208. {
  1209. // Dialogs should not be displayed if we are doing a remote install
  1210. //
  1211. case IDD_DOMAINJ:
  1212. if ( WizGlobals.iProductInstall == PRODUCT_REMOTEINSTALL )
  1213. lpWizard->bVisible = FALSE;
  1214. else
  1215. lpWizard->bVisible = TRUE;
  1216. break;
  1217. // Dialogs should be displayed if we are doing a remote install
  1218. //
  1219. case IDD_SIFTEXT:
  1220. if ( WizGlobals.iProductInstall != PRODUCT_REMOTEINSTALL )
  1221. lpWizard->bVisible = FALSE;
  1222. else
  1223. lpWizard->bVisible = TRUE;
  1224. break;
  1225. // Dialogs should not be displayed if doing a sysprep install
  1226. //
  1227. case IDD_IE:
  1228. case IDD_TARGETPATH:
  1229. if ( WizGlobals.iProductInstall == PRODUCT_SYSPREP )
  1230. lpWizard->bVisible = FALSE;
  1231. else
  1232. lpWizard->bVisible = TRUE;
  1233. break;
  1234. // Dialogs should be displayed if doing a sysprep install
  1235. //
  1236. case IDD_OEMDUPSTRING:
  1237. if ( WizGlobals.iProductInstall != PRODUCT_SYSPREP )
  1238. lpWizard->bVisible = FALSE;
  1239. else
  1240. lpWizard->bVisible = TRUE;
  1241. break;
  1242. // Dialogs should be displayed if doing an unattended install
  1243. //
  1244. case IDD_COPYFILES1:
  1245. case IDD_DISTFOLDER:
  1246. case IDD_COMPUTERNAME:
  1247. case IDD_SCSI:
  1248. case IDD_HAL:
  1249. case IDD_OPTCOMP:
  1250. if ( WizGlobals.iProductInstall != PRODUCT_UNATTENDED_INSTALL )
  1251. lpWizard->bVisible = FALSE;
  1252. else
  1253. lpWizard->bVisible = TRUE;
  1254. break;
  1255. // Dialogs should not be displayed if doing an unattended install
  1256. //
  1257. case IDD_SYSPREPCOMPUTERNAME:
  1258. if ( WizGlobals.iProductInstall == PRODUCT_UNATTENDED_INSTALL )
  1259. lpWizard->bVisible = FALSE;
  1260. else
  1261. lpWizard->bVisible = TRUE;
  1262. break;
  1263. // Dialogs that should be displayed for server installs
  1264. //
  1265. case IDD_SRVLICENSE:
  1266. if ( PLATFORM_SERVERS & WizGlobals.iPlatform)
  1267. lpWizard->bVisible = TRUE;
  1268. else
  1269. lpWizard->bVisible = FALSE;
  1270. break;
  1271. /* Always show this now that the mouse stuff is back.
  1272. // If we are in DBCS mode, show the following screens
  1273. //
  1274. case IDD_SCREENS:
  1275. if ( GET_FLAG(OPK_DBCS))
  1276. lpWizard->bVisible = TRUE;
  1277. else
  1278. lpWizard->bVisible = FALSE;
  1279. */
  1280. }
  1281. }
  1282. }
  1283. //----------------------------------------------------------------------------
  1284. //
  1285. // Function: GetTreeItem
  1286. //
  1287. // Purpose: Given a handle to the TreeView item, this function returns the TREEDLG
  1288. // struct that corresponds with that handle.
  1289. //
  1290. //----------------------------------------------------------------------------
  1291. static LPTREEDLG GetTreeItem(HWND hwnd, HTREEITEM hItem)
  1292. {
  1293. DWORD dwTreePages = 0,
  1294. dwPage = 0;
  1295. BOOL bFound = FALSE;
  1296. LPTREEDLG lpTreeIndex = NULL;
  1297. // The first two parameters are required, if any of them are NULL, we exit the fuction
  1298. //
  1299. if ( !hwnd || !hItem )
  1300. return NULL;
  1301. // Set the dialog to the first dialog in the array
  1302. //
  1303. lpTreeIndex = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1304. // Determine the number of tree pages that we are going to iterate through
  1305. //
  1306. dwTreePages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMTreeDialogs) : sizeof(vdpCDTreeDialogs)) / sizeof(TREEDLG));
  1307. // Loop through all of the wizard pages, looking for the item
  1308. //
  1309. for(dwPage=0;(dwPage < dwTreePages) && !bFound; dwPage++)
  1310. {
  1311. if ( lpTreeIndex->hItem == hItem )
  1312. bFound = TRUE;
  1313. else
  1314. lpTreeIndex++;
  1315. }
  1316. // If we did not find the item, return FALSE
  1317. //
  1318. if ( !bFound )
  1319. {
  1320. return NULL;
  1321. }
  1322. // We successfully found the item, returning it as lpTreeDialog
  1323. //
  1324. return lpTreeIndex;
  1325. }
  1326. //----------------------------------------------------------------------------
  1327. //
  1328. // Function: SelectTreeItem
  1329. //
  1330. // Purpose: Selects the next/previous item relative to the supplied tree item
  1331. //
  1332. //----------------------------------------------------------------------------
  1333. static BOOL SelectTreeItem(HWND hwnd, HTREEITEM hItem, UINT uSelection)
  1334. {
  1335. BOOL bItemFound = FALSE;
  1336. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1337. LPTREEDLG lpTreeDialog;
  1338. // If we do not have the first two parameters or we can't get the TreeView handle then we exit the function
  1339. //
  1340. if ( !hwndTV || !hwnd || !hItem )
  1341. return FALSE;
  1342. // Verify that we have a valid selection
  1343. //
  1344. switch ( uSelection )
  1345. {
  1346. case TVGN_NEXTVISIBLE:
  1347. case TVGN_PREVIOUSVISIBLE:
  1348. break;
  1349. default:
  1350. return FALSE;
  1351. }
  1352. // While we have not found the item, or there are no more items in that direction, continue iterations
  1353. //
  1354. while ( !bItemFound && hItem )
  1355. {
  1356. // If we are able to get the "next" item and grab the dialog struct check to make sure we have a resource
  1357. //
  1358. if ( (hItem = TreeView_GetNextItem(hwndTV, hItem, uSelection)) &&
  1359. (lpTreeDialog = GetTreeItem(hwnd, hItem)) &&
  1360. (lpTreeDialog->dwResource)
  1361. )
  1362. {
  1363. bItemFound = TRUE;
  1364. TreeView_SelectItem(hwndTV, hItem);
  1365. }
  1366. }
  1367. // Return whether or not the item was selected
  1368. //
  1369. return bItemFound;
  1370. }
  1371. static BOOL SelectFirstMaintenanceDlg(HWND hwnd)
  1372. {
  1373. DWORD dwTotalPages = 0,
  1374. dwPage = 0;
  1375. BOOL bFound = FALSE;
  1376. LPTREEDLG lpTreeIndex = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1377. WIZDLG WizardIndex;
  1378. // Determine the number of wizard pages in the array
  1379. //
  1380. dwTotalPages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMWizardDialogs) : sizeof(vdpCDWizardDialogs)) / sizeof(WIZDLG));
  1381. // Find the last dialog of the wizard
  1382. //
  1383. WizardIndex = (GET_FLAG(OPK_OEM) ? vdpOEMWizardDialogs[dwTotalPages - 1] : vdpCDWizardDialogs[dwTotalPages - 1]);
  1384. // Determine the number of pages in the tree array
  1385. //
  1386. dwTotalPages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMTreeDialogs) : sizeof(vdpCDTreeDialogs)) / sizeof(WIZDLG));
  1387. // Locate this dialog in the tree view
  1388. //
  1389. for(dwPage=0;(dwPage < ( dwTotalPages - 1 )) && !bFound; dwPage++)
  1390. {
  1391. if ( WizardIndex.dwResource == lpTreeIndex->dwResource )
  1392. {
  1393. bFound = TRUE;
  1394. // If there is an Item, select it
  1395. //
  1396. if ( lpTreeIndex->hItem )
  1397. SelectTreeItem(hwnd, lpTreeIndex->hItem, TVGN_NEXTVISIBLE );SelectTreeItem(hwnd, lpTreeIndex->hItem, TVGN_NEXTVISIBLE );
  1398. }
  1399. else
  1400. lpTreeIndex++;
  1401. }
  1402. return bFound;
  1403. }
  1404. //----------------------------------------------------------------------------
  1405. //
  1406. // Function: CloseProfile
  1407. //
  1408. // Purpose: This function closes an open profile but keeps the Maintenance Dialog
  1409. // open.
  1410. //
  1411. //----------------------------------------------------------------------------
  1412. static BOOL CloseProfile(HWND hwnd, BOOL bUserGenerated)
  1413. {
  1414. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1415. DWORD dwPage,
  1416. dwReturn;
  1417. LPTSTR lpString;
  1418. LPTREEDLG lpWizard = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1419. // If this was user generated and the do not want to close it, return
  1420. //
  1421. if ( bUserGenerated )
  1422. {
  1423. dwReturn = MsgBox(GetParent(hwnd), IDS_USERCLOSE, IDS_APPNAME, MB_YESNOCANCEL | MB_DEFBUTTON1 );
  1424. if ( dwReturn == IDYES )
  1425. {
  1426. SaveProfile(hwnd);
  1427. return FALSE;
  1428. }
  1429. else if ( dwReturn == IDCANCEL )
  1430. return FALSE;
  1431. }
  1432. // Set the tree handles back to null as they are of no use
  1433. //
  1434. for ( dwPage = 0; dwPage < g_dwTreePages; dwPage++, lpWizard++ )
  1435. {
  1436. // Destroy the window and set the array back to null
  1437. //
  1438. // ISSUE-2002/02/27-stelo,swamip - Need to check the window handle validity.
  1439. DestroyWindow(lpWizard->hWindow);
  1440. lpWizard->hWindow = NULL;
  1441. }
  1442. // Delete all the items from the list
  1443. //
  1444. if ( hwndTV )
  1445. EnableWindow(hwndTV, FALSE);
  1446. // Disable all the buttons, except Cancel
  1447. //
  1448. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), FALSE);
  1449. EnableWindow(GetDlgItem(hwnd, ID_MAINT_NEXT), FALSE);
  1450. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), FALSE);
  1451. EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
  1452. // Disable the menu items
  1453. //
  1454. EnableMenuItem(GetMenu(hwnd), ID_FILE_CLOSE, MF_BYCOMMAND | MF_GRAYED);
  1455. EnableMenuItem(GetMenu(hwnd), ID_FILE_SAVE, MF_BYCOMMAND | MF_GRAYED);
  1456. // Hide the title, subtitle
  1457. //
  1458. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_TITLE), SW_HIDE);
  1459. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_SUBTITLE), SW_HIDE);
  1460. // Make sure there is no titles in there
  1461. //
  1462. SetDlgItemText(hwnd, IDC_MAINT_TITLE, _T(""));
  1463. SetDlgItemText(hwnd, IDC_MAINT_SUBTITLE, _T(""));
  1464. // Reset necessary global flags
  1465. //
  1466. SET_FLAG(OPK_CREATED, FALSE);
  1467. // Reset necessary global variables
  1468. //
  1469. if ( g_App.szTempDir[0] )
  1470. DeletePath(g_App.szTempDir);
  1471. g_App.szTempDir[0] = NULLCHR;
  1472. g_App.szConfigName[0] = NULLCHR;
  1473. g_hCurrentDialog = NULL;
  1474. // Switch the button back to next
  1475. //
  1476. if ( lpString = AllocateString(NULL, IDS_NEXT))
  1477. {
  1478. SetDlgItemText(hwnd, ID_MAINT_NEXT, lpString);
  1479. FREE(lpString);
  1480. }
  1481. // Reset the necessary global variables for the answer file
  1482. //
  1483. FixedGlobals.iLoadType = LOAD_UNDEFINED;
  1484. FixedGlobals.ScriptName[0] = NULLCHR;
  1485. FixedGlobals.UdfFileName[0] = NULLCHR;
  1486. FixedGlobals.BatchFileName[0] = NULLCHR;
  1487. SetFocus(GetDlgItem(hwnd,IDCANCEL));
  1488. return TRUE;
  1489. }
  1490. //----------------------------------------------------------------------------
  1491. //
  1492. // Function: OpenProfile
  1493. //
  1494. // Purpose: Brings the user to the open a new configuration/profile page, setting
  1495. // the proper default based on whether the user selected a new/open existing
  1496. // configuration.
  1497. //
  1498. //----------------------------------------------------------------------------
  1499. static void OpenProfile(HWND hwnd, BOOL bNewConfig)
  1500. {
  1501. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1502. // Enabled the menu items
  1503. //
  1504. EnableMenuItem(GetMenu(hwnd), ID_FILE_CLOSE, MF_BYCOMMAND | MF_ENABLED);
  1505. EnableMenuItem(GetMenu(hwnd), ID_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
  1506. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), TRUE);
  1507. EnableWindow(GetDlgItem(hwnd, ID_MAINT_NEXT), TRUE);
  1508. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), TRUE);
  1509. EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
  1510. // Enable the title and subtitle
  1511. //
  1512. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_TITLE), SW_SHOW);
  1513. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_SUBTITLE), SW_SHOW);
  1514. // Are we going to open a new config set
  1515. //
  1516. if ( !bNewConfig )
  1517. SET_FLAG(OPK_OPENCONFIG, TRUE);
  1518. // Hide the splash screen
  1519. //
  1520. ShowSplashDialog(hwnd, 0);
  1521. SendMessage(hwnd, WM_INITDIALOG, (WPARAM) 0, (LPARAM) 0);
  1522. }
  1523. //----------------------------------------------------------------------------
  1524. //
  1525. // Function: SaveProfile
  1526. //
  1527. // Purpose: Saves the currently open profile
  1528. //
  1529. //----------------------------------------------------------------------------
  1530. static void SaveProfile(HWND hwnd)
  1531. {
  1532. DWORD dwResult = 0;
  1533. NMHDR mhdr;
  1534. // Create the notification message for the wizard page
  1535. //
  1536. mhdr.code = TVN_SELCHANGING;
  1537. // Send the notification message and if we return false, then do not change the page
  1538. //
  1539. if ( !SendMessage(hwnd, WM_NOTIFY, (WPARAM) 0, (LPARAM) &mhdr) )
  1540. {
  1541. // The user is in the oem/system builder mode
  1542. //
  1543. if ( GET_FLAG(OPK_OEM) )
  1544. {
  1545. if ( DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_SAVEAS), hwnd, SaveAsDlgProc) )
  1546. {
  1547. //
  1548. // Now some last minute cleanup before we are totally finished.
  1549. //
  1550. g_App.szTempDir[0] = NULLCHR;
  1551. // Show the complete splash screen
  1552. //
  1553. ShowSplashDialog(hwnd, IDD_COMPLETE);
  1554. // Close the config set
  1555. //
  1556. CloseProfile(hwnd, FALSE);
  1557. // Close if the auto run flag is set.
  1558. //
  1559. if ( GET_FLAG(OPK_AUTORUN) )
  1560. PostMessage(hwnd, WM_CLOSE, 0, 0L);
  1561. }
  1562. }
  1563. else
  1564. {
  1565. if ( DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_SAVESCRIPT), hwnd, DlgSaveScriptPage) )
  1566. {
  1567. if ( WizGlobals.bCreateNewDistFolder &&
  1568. !WizGlobals.bStandAloneScript &&
  1569. (WizGlobals.iProductInstall == PRODUCT_UNATTENDED_INSTALL) )
  1570. {
  1571. COPYDIRDATA cdd;
  1572. DWORD dwFileCount;
  1573. LPTSTR lpBuffer;
  1574. TCHAR szBuffer[MAX_PATH] = NULLSTR;
  1575. // Clean up the memory before we use it
  1576. //
  1577. ZeroMemory(&cdd, sizeof(COPYDIRDATA));
  1578. // Fill in the COPYDIRDATA Structure
  1579. //
  1580. lstrcpyn(szBuffer, WizGlobals.bCopyFromPath ? WizGlobals.CopySourcePath : WizGlobals.CdSourcePath,AS(szBuffer));
  1581. AddPathN(szBuffer, _T(".."),AS(szBuffer));
  1582. GetFullPathName(szBuffer, AS(szBuffer), cdd.szSrc, &lpBuffer);
  1583. lstrcpyn(cdd.szDst, WizGlobals.DistFolder,AS(cdd.szDst));
  1584. lstrcpyn(cdd.szInfFile, cdd.szSrc,AS(cdd.szInfFile));
  1585. AddPathN(cdd.szInfFile, WizGlobals.Architecture,AS(cdd.szInfFile));
  1586. AddPathN(cdd.szInfFile, FILE_DOSNET_INF,AS(cdd.szInfFile));
  1587. dwFileCount = CopySkuFiles(NULL, NULL, cdd.szSrc, cdd.szDst, cdd.szInfFile);
  1588. cdd.dwFileCount = dwFileCount;
  1589. cdd.lpszEndSku = cdd.szDst + lstrlen(cdd.szDst);
  1590. // Call the dialog box that copies the sources over
  1591. //
  1592. DialogBoxParam(g_App.hInstance, MAKEINTRESOURCE(IDD_PROGRESS), hwnd, ProgressDlgProc, (LPARAM) &cdd);
  1593. }
  1594. // Show the complete splash screen
  1595. //
  1596. ShowSplashDialog(hwnd, IDD_FINISH);
  1597. CloseProfile(hwnd, FALSE);
  1598. }
  1599. }
  1600. }
  1601. }
  1602. //----------------------------------------------------------------------------
  1603. //
  1604. // Function: EnableControls
  1605. //
  1606. // Purpose: Enables the proper back/next buttons based on the selection in the
  1607. // tree view
  1608. //
  1609. //----------------------------------------------------------------------------
  1610. static void EnableControls(HWND hwnd)
  1611. {
  1612. HTREEITEM hItem;
  1613. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1614. if (hwndTV &&
  1615. (hItem = TreeView_GetSelection(hwndTV)))
  1616. {
  1617. // Enable the back button if we are not the first dialog
  1618. //
  1619. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), ( hItem == TreeView_GetFirstVisible(hwndTV) ? FALSE : TRUE) );
  1620. }
  1621. return;
  1622. }
  1623. void SetWizardButtons(HWND hwnd, DWORD dwButtons)
  1624. {
  1625. LPTSTR lpString = NULL;
  1626. // Set the buttons for the starting wizard
  1627. //
  1628. SendMessage(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, (LPARAM) dwButtons);
  1629. // Determine if we need to set the next button to the finish button
  1630. //
  1631. lpString = AllocateString(NULL, (dwButtons & PSWIZB_FINISH) ? IDS_FINISH : IDS_NEXT);
  1632. // ISSUE-2002/02/27-stelo,swamip - Make sure Buffer has been allocated.
  1633. SetDlgItemText(GetParent(hwnd), ID_MAINT_NEXT, lpString);
  1634. // Clean up the allocated memory
  1635. //
  1636. FREE(lpString);
  1637. // Set the maintenance mode buttons
  1638. //
  1639. EnableWindow(GetDlgItem(GetParent(hwnd), ID_MAINT_BACK), (dwButtons & PSWIZB_BACK));
  1640. EnableWindow(GetDlgItem(GetParent(hwnd), ID_MAINT_NEXT), (dwButtons & PSWIZB_NEXT) || (dwButtons & PSWIZB_FINISH));
  1641. }
  1642. static void ShowSplashDialog(HWND hwnd, DWORD dwResource)
  1643. {
  1644. DWORD dwIndex = 0,
  1645. dwDisplay = -1;
  1646. BOOL bFound = FALSE;
  1647. RECT rc;
  1648. // Loop through each dialog and hide any existing ones
  1649. //
  1650. for ( dwIndex = 0; dwIndex < AS(vdpSplashDialogs); dwIndex++)
  1651. {
  1652. // Hide existing windows
  1653. //
  1654. if ( vdpSplashDialogs[dwIndex].hWindow )
  1655. EndDialog(vdpSplashDialogs[dwIndex].hWindow, 0);
  1656. // Determine the one that we are going to display
  1657. //
  1658. if ( vdpSplashDialogs[dwIndex].dwResource == dwResource )
  1659. {
  1660. bFound = TRUE;
  1661. dwDisplay = dwIndex;
  1662. }
  1663. }
  1664. // We have been given a resource and we found it in the loop, display it
  1665. //
  1666. if ( dwResource && bFound)
  1667. {
  1668. if ( vdpSplashDialogs[dwDisplay].hWindow = CreateDialog(g_App.hInstance, MAKEINTRESOURCE(dwResource), hwnd, vdpSplashDialogs[dwDisplay].dlgWindowProc ))
  1669. {
  1670. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_BAR), SW_HIDE);
  1671. // Position the splash dialog on the splash frame
  1672. //
  1673. GetWindowRect(GetDlgItem(hwnd, IDC_SPLASHFRAME) , &rc);
  1674. MapWindowPoints(NULL, hwnd, (LPPOINT) &rc, 2);
  1675. SetWindowPos(vdpSplashDialogs[dwDisplay].hWindow, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  1676. ShowWindow( vdpSplashDialogs[dwDisplay].hWindow, SW_SHOW );
  1677. }
  1678. }
  1679. else
  1680. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_BAR), SW_SHOW);
  1681. }
  1682. BOOL CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1683. {
  1684. switch ( uMsg )
  1685. {
  1686. case WM_INITDIALOG:
  1687. {
  1688. CHAR szCompany[] = VER_COMPANYNAME_STR,
  1689. szVersion[] = VER_FILEVERSION_STR,
  1690. szCopyright[] = VER_LEGALCOPYRIGHT_STR,
  1691. szDescription[] = VER_FILEDESCRIPTION_STR;
  1692. SetDlgItemTextA(hwnd, IDC_ABOUT_COMPANY, szCompany);
  1693. SetDlgItemTextA(hwnd, IDC_ABOUT_VERSION, szVersion);
  1694. SetDlgItemTextA(hwnd, IDC_ABOUT_COPYRIGHT, szCopyright);
  1695. SetDlgItemTextA(hwnd, IDC_ABOUT_DESCRIPTION, szDescription);
  1696. return FALSE;
  1697. }
  1698. case WM_COMMAND:
  1699. if ( LOWORD(wParam) == IDOK )
  1700. EndDialog(hwnd, LOWORD(wParam));
  1701. return FALSE;
  1702. default:
  1703. return FALSE;
  1704. }
  1705. return FALSE;
  1706. }