Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2026 lines
55 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. INT_PTR 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. INT_PTR 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, 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. case IDD_SYSPREPCOMPUTERNAME:
  1238. if ( WizGlobals.iProductInstall != PRODUCT_SYSPREP )
  1239. lpWizard->bVisible = FALSE;
  1240. else
  1241. lpWizard->bVisible = TRUE;
  1242. break;
  1243. // Dialogs should be displayed if doing an unattended install
  1244. //
  1245. case IDD_COPYFILES1:
  1246. case IDD_DISTFOLDER:
  1247. case IDD_COMPUTERNAME:
  1248. case IDD_SCSI:
  1249. case IDD_HAL:
  1250. case IDD_OPTCOMP:
  1251. if ( WizGlobals.iProductInstall != PRODUCT_UNATTENDED_INSTALL )
  1252. lpWizard->bVisible = FALSE;
  1253. else
  1254. lpWizard->bVisible = TRUE;
  1255. break;
  1256. // Dialogs that should be displayed for server installs
  1257. //
  1258. case IDD_SRVLICENSE:
  1259. if ( PLATFORM_SERVERS & WizGlobals.iPlatform)
  1260. lpWizard->bVisible = TRUE;
  1261. else
  1262. lpWizard->bVisible = FALSE;
  1263. break;
  1264. /* Always show this now that the mouse stuff is back.
  1265. // If we are in DBCS mode, show the following screens
  1266. //
  1267. case IDD_SCREENS:
  1268. if ( GET_FLAG(OPK_DBCS))
  1269. lpWizard->bVisible = TRUE;
  1270. else
  1271. lpWizard->bVisible = FALSE;
  1272. */
  1273. }
  1274. }
  1275. }
  1276. //----------------------------------------------------------------------------
  1277. //
  1278. // Function: GetTreeItem
  1279. //
  1280. // Purpose: Given a handle to the TreeView item, this function returns the TREEDLG
  1281. // struct that corresponds with that handle.
  1282. //
  1283. //----------------------------------------------------------------------------
  1284. static LPTREEDLG GetTreeItem(HWND hwnd, HTREEITEM hItem)
  1285. {
  1286. DWORD dwTreePages = 0,
  1287. dwPage = 0;
  1288. BOOL bFound = FALSE;
  1289. LPTREEDLG lpTreeIndex = NULL;
  1290. // The first two parameters are required, if any of them are NULL, we exit the fuction
  1291. //
  1292. if ( !hwnd || !hItem )
  1293. return NULL;
  1294. // Set the dialog to the first dialog in the array
  1295. //
  1296. lpTreeIndex = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1297. // Determine the number of tree pages that we are going to iterate through
  1298. //
  1299. dwTreePages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMTreeDialogs) : sizeof(vdpCDTreeDialogs)) / sizeof(TREEDLG));
  1300. // Loop through all of the wizard pages, looking for the item
  1301. //
  1302. for(dwPage=0;(dwPage < dwTreePages) && !bFound; dwPage++)
  1303. {
  1304. if ( lpTreeIndex->hItem == hItem )
  1305. bFound = TRUE;
  1306. else
  1307. lpTreeIndex++;
  1308. }
  1309. // If we did not find the item, return FALSE
  1310. //
  1311. if ( !bFound )
  1312. {
  1313. return NULL;
  1314. }
  1315. // We successfully found the item, returning it as lpTreeDialog
  1316. //
  1317. return lpTreeIndex;
  1318. }
  1319. //----------------------------------------------------------------------------
  1320. //
  1321. // Function: SelectTreeItem
  1322. //
  1323. // Purpose: Selects the next/previous item relative to the supplied tree item
  1324. //
  1325. //----------------------------------------------------------------------------
  1326. static BOOL SelectTreeItem(HWND hwnd, HTREEITEM hItem, UINT uSelection)
  1327. {
  1328. BOOL bItemFound = FALSE;
  1329. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1330. LPTREEDLG lpTreeDialog;
  1331. // If we do not have the first two parameters or we can't get the TreeView handle then we exit the function
  1332. //
  1333. if ( !hwndTV || !hwnd || !hItem )
  1334. return FALSE;
  1335. // Verify that we have a valid selection
  1336. //
  1337. switch ( uSelection )
  1338. {
  1339. case TVGN_NEXTVISIBLE:
  1340. case TVGN_PREVIOUSVISIBLE:
  1341. break;
  1342. default:
  1343. return FALSE;
  1344. }
  1345. // While we have not found the item, or there are no more items in that direction, continue iterations
  1346. //
  1347. while ( !bItemFound && hItem )
  1348. {
  1349. // If we are able to get the "next" item and grab the dialog struct check to make sure we have a resource
  1350. //
  1351. if ( (hItem = TreeView_GetNextItem(hwndTV, hItem, uSelection)) &&
  1352. (lpTreeDialog = GetTreeItem(hwnd, hItem)) &&
  1353. (lpTreeDialog->dwResource)
  1354. )
  1355. {
  1356. bItemFound = TRUE;
  1357. TreeView_SelectItem(hwndTV, hItem);
  1358. }
  1359. }
  1360. // Return whether or not the item was selected
  1361. //
  1362. return bItemFound;
  1363. }
  1364. static BOOL SelectFirstMaintenanceDlg(HWND hwnd)
  1365. {
  1366. DWORD dwTotalPages = 0,
  1367. dwPage = 0;
  1368. BOOL bFound = FALSE;
  1369. LPTREEDLG lpTreeIndex = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1370. WIZDLG WizardIndex;
  1371. // Determine the number of wizard pages in the array
  1372. //
  1373. dwTotalPages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMWizardDialogs) : sizeof(vdpCDWizardDialogs)) / sizeof(WIZDLG));
  1374. // Find the last dialog of the wizard
  1375. //
  1376. WizardIndex = (GET_FLAG(OPK_OEM) ? vdpOEMWizardDialogs[dwTotalPages - 1] : vdpCDWizardDialogs[dwTotalPages - 1]);
  1377. // Determine the number of pages in the tree array
  1378. //
  1379. dwTotalPages = ((GET_FLAG(OPK_OEM) ? sizeof(vdpOEMTreeDialogs) : sizeof(vdpCDTreeDialogs)) / sizeof(WIZDLG));
  1380. // Locate this dialog in the tree view
  1381. //
  1382. for(dwPage=0;(dwPage < ( dwTotalPages - 1 )) && !bFound; dwPage++)
  1383. {
  1384. if ( WizardIndex.dwResource == lpTreeIndex->dwResource )
  1385. {
  1386. bFound = TRUE;
  1387. // If there is an Item, select it
  1388. //
  1389. if ( lpTreeIndex->hItem )
  1390. SelectTreeItem(hwnd, lpTreeIndex->hItem, TVGN_NEXTVISIBLE );SelectTreeItem(hwnd, lpTreeIndex->hItem, TVGN_NEXTVISIBLE );
  1391. }
  1392. else
  1393. lpTreeIndex++;
  1394. }
  1395. return bFound;
  1396. }
  1397. //----------------------------------------------------------------------------
  1398. //
  1399. // Function: CloseProfile
  1400. //
  1401. // Purpose: This function closes an open profile but keeps the Maintenance Dialog
  1402. // open.
  1403. //
  1404. //----------------------------------------------------------------------------
  1405. static BOOL CloseProfile(HWND hwnd, BOOL bUserGenerated)
  1406. {
  1407. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1408. DWORD dwPage,
  1409. dwReturn;
  1410. LPTSTR lpString;
  1411. LPTREEDLG lpWizard = (GET_FLAG(OPK_OEM) ? vdpOEMTreeDialogs : vdpCDTreeDialogs);
  1412. // If this was user generated and the do not want to close it, return
  1413. //
  1414. if ( bUserGenerated )
  1415. {
  1416. dwReturn = MsgBox(GetParent(hwnd), IDS_USERCLOSE, IDS_APPNAME, MB_YESNOCANCEL | MB_DEFBUTTON1 );
  1417. if ( dwReturn == IDYES )
  1418. {
  1419. SaveProfile(hwnd);
  1420. return FALSE;
  1421. }
  1422. else if ( dwReturn == IDCANCEL )
  1423. return FALSE;
  1424. }
  1425. // Set the tree handles back to null as they are of no use
  1426. //
  1427. for ( dwPage = 0; dwPage < g_dwTreePages; dwPage++, lpWizard++ )
  1428. {
  1429. // Destroy the window and set the array back to null
  1430. //
  1431. // ISSUE-2002/02/27-stelo,swamip - Need to check the window handle validity.
  1432. DestroyWindow(lpWizard->hWindow);
  1433. lpWizard->hWindow = NULL;
  1434. }
  1435. // Delete all the items from the list
  1436. //
  1437. if ( hwndTV )
  1438. EnableWindow(hwndTV, FALSE);
  1439. // Disable all the buttons, except Cancel
  1440. //
  1441. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), FALSE);
  1442. EnableWindow(GetDlgItem(hwnd, ID_MAINT_NEXT), FALSE);
  1443. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), FALSE);
  1444. EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
  1445. // Disable the menu items
  1446. //
  1447. EnableMenuItem(GetMenu(hwnd), ID_FILE_CLOSE, MF_BYCOMMAND | MF_GRAYED);
  1448. EnableMenuItem(GetMenu(hwnd), ID_FILE_SAVE, MF_BYCOMMAND | MF_GRAYED);
  1449. // Hide the title, subtitle
  1450. //
  1451. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_TITLE), SW_HIDE);
  1452. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_SUBTITLE), SW_HIDE);
  1453. // Make sure there is no titles in there
  1454. //
  1455. SetDlgItemText(hwnd, IDC_MAINT_TITLE, _T(""));
  1456. SetDlgItemText(hwnd, IDC_MAINT_SUBTITLE, _T(""));
  1457. // Reset necessary global flags
  1458. //
  1459. SET_FLAG(OPK_CREATED, FALSE);
  1460. // Reset necessary global variables
  1461. //
  1462. if ( g_App.szTempDir[0] )
  1463. DeletePath(g_App.szTempDir);
  1464. g_App.szTempDir[0] = NULLCHR;
  1465. g_App.szConfigName[0] = NULLCHR;
  1466. g_hCurrentDialog = NULL;
  1467. // Switch the button back to next
  1468. //
  1469. if ( lpString = AllocateString(NULL, IDS_NEXT))
  1470. {
  1471. SetDlgItemText(hwnd, ID_MAINT_NEXT, lpString);
  1472. FREE(lpString);
  1473. }
  1474. // Reset the necessary global variables for the answer file
  1475. //
  1476. FixedGlobals.iLoadType = LOAD_UNDEFINED;
  1477. FixedGlobals.ScriptName[0] = NULLCHR;
  1478. FixedGlobals.UdfFileName[0] = NULLCHR;
  1479. FixedGlobals.BatchFileName[0] = NULLCHR;
  1480. SetFocus(GetDlgItem(hwnd,IDCANCEL));
  1481. return TRUE;
  1482. }
  1483. //----------------------------------------------------------------------------
  1484. //
  1485. // Function: OpenProfile
  1486. //
  1487. // Purpose: Brings the user to the open a new configuration/profile page, setting
  1488. // the proper default based on whether the user selected a new/open existing
  1489. // configuration.
  1490. //
  1491. //----------------------------------------------------------------------------
  1492. static void OpenProfile(HWND hwnd, BOOL bNewConfig)
  1493. {
  1494. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1495. // Enabled the menu items
  1496. //
  1497. EnableMenuItem(GetMenu(hwnd), ID_FILE_CLOSE, MF_BYCOMMAND | MF_ENABLED);
  1498. EnableMenuItem(GetMenu(hwnd), ID_FILE_SAVE, MF_BYCOMMAND | MF_ENABLED);
  1499. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), TRUE);
  1500. EnableWindow(GetDlgItem(hwnd, ID_MAINT_NEXT), TRUE);
  1501. EnableWindow(GetDlgItem(hwnd, IDC_MAINT_HELP), TRUE);
  1502. EnableWindow(GetDlgItem(hwnd, IDCANCEL), TRUE);
  1503. // Enable the title and subtitle
  1504. //
  1505. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_TITLE), SW_SHOW);
  1506. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_SUBTITLE), SW_SHOW);
  1507. // Are we going to open a new config set
  1508. //
  1509. if ( !bNewConfig )
  1510. SET_FLAG(OPK_OPENCONFIG, TRUE);
  1511. // Hide the splash screen
  1512. //
  1513. ShowSplashDialog(hwnd, 0);
  1514. SendMessage(hwnd, WM_INITDIALOG, (WPARAM) 0, (LPARAM) 0);
  1515. }
  1516. //----------------------------------------------------------------------------
  1517. //
  1518. // Function: SaveProfile
  1519. //
  1520. // Purpose: Saves the currently open profile
  1521. //
  1522. //----------------------------------------------------------------------------
  1523. static void SaveProfile(HWND hwnd)
  1524. {
  1525. DWORD dwResult = 0;
  1526. NMHDR mhdr;
  1527. // Create the notification message for the wizard page
  1528. //
  1529. mhdr.code = TVN_SELCHANGING;
  1530. // Send the notification message and if we return false, then do not change the page
  1531. //
  1532. if ( !SendMessage(hwnd, WM_NOTIFY, (WPARAM) 0, (LPARAM) &mhdr) )
  1533. {
  1534. // The user is in the oem/system builder mode
  1535. //
  1536. if ( GET_FLAG(OPK_OEM) )
  1537. {
  1538. if ( DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_SAVEAS), hwnd, SaveAsDlgProc) )
  1539. {
  1540. //
  1541. // Now some last minute cleanup before we are totally finished.
  1542. //
  1543. g_App.szTempDir[0] = NULLCHR;
  1544. // Show the complete splash screen
  1545. //
  1546. ShowSplashDialog(hwnd, IDD_COMPLETE);
  1547. // Close the config set
  1548. //
  1549. CloseProfile(hwnd, FALSE);
  1550. // Close if the auto run flag is set.
  1551. //
  1552. if ( GET_FLAG(OPK_AUTORUN) )
  1553. PostMessage(hwnd, WM_CLOSE, 0, 0L);
  1554. }
  1555. }
  1556. else
  1557. {
  1558. if ( DialogBox(g_App.hInstance, MAKEINTRESOURCE(IDD_SAVESCRIPT), hwnd, DlgSaveScriptPage) )
  1559. {
  1560. if ( WizGlobals.bCreateNewDistFolder &&
  1561. !WizGlobals.bStandAloneScript &&
  1562. (WizGlobals.iProductInstall == PRODUCT_UNATTENDED_INSTALL) )
  1563. {
  1564. COPYDIRDATA cdd;
  1565. DWORD dwFileCount;
  1566. LPTSTR lpBuffer;
  1567. TCHAR szBuffer[MAX_PATH] = NULLSTR;
  1568. // Clean up the memory before we use it
  1569. //
  1570. ZeroMemory(&cdd, sizeof(COPYDIRDATA));
  1571. // Fill in the COPYDIRDATA Structure
  1572. //
  1573. lstrcpyn(szBuffer, WizGlobals.bCopyFromPath ? WizGlobals.CopySourcePath : WizGlobals.CdSourcePath,AS(szBuffer));
  1574. AddPathN(szBuffer, _T(".."),AS(szBuffer));
  1575. GetFullPathName(szBuffer, AS(szBuffer), cdd.szSrc, &lpBuffer);
  1576. lstrcpyn(cdd.szDst, WizGlobals.DistFolder,AS(cdd.szDst));
  1577. lstrcpyn(cdd.szInfFile, cdd.szSrc,AS(cdd.szInfFile));
  1578. AddPathN(cdd.szInfFile, WizGlobals.Architecture,AS(cdd.szInfFile));
  1579. AddPathN(cdd.szInfFile, FILE_DOSNET_INF,AS(cdd.szInfFile));
  1580. dwFileCount = CopySkuFiles(NULL, NULL, cdd.szSrc, cdd.szDst, cdd.szInfFile);
  1581. cdd.dwFileCount = dwFileCount;
  1582. cdd.lpszEndSku = cdd.szDst + lstrlen(cdd.szDst);
  1583. // Call the dialog box that copies the sources over
  1584. //
  1585. DialogBoxParam(g_App.hInstance, MAKEINTRESOURCE(IDD_PROGRESS), hwnd, ProgressDlgProc, (LPARAM) &cdd);
  1586. }
  1587. // Show the complete splash screen
  1588. //
  1589. ShowSplashDialog(hwnd, IDD_FINISH);
  1590. CloseProfile(hwnd, FALSE);
  1591. }
  1592. }
  1593. }
  1594. }
  1595. //----------------------------------------------------------------------------
  1596. //
  1597. // Function: EnableControls
  1598. //
  1599. // Purpose: Enables the proper back/next buttons based on the selection in the
  1600. // tree view
  1601. //
  1602. //----------------------------------------------------------------------------
  1603. static void EnableControls(HWND hwnd)
  1604. {
  1605. HTREEITEM hItem;
  1606. HWND hwndTV = GetDlgItem(hwnd, IDC_PAGES);
  1607. if (hwndTV &&
  1608. (hItem = TreeView_GetSelection(hwndTV)))
  1609. {
  1610. // Enable the back button if we are not the first dialog
  1611. //
  1612. EnableWindow(GetDlgItem(hwnd, ID_MAINT_BACK), ( hItem == TreeView_GetFirstVisible(hwndTV) ? FALSE : TRUE) );
  1613. }
  1614. return;
  1615. }
  1616. void SetWizardButtons(HWND hwnd, DWORD dwButtons)
  1617. {
  1618. LPTSTR lpString = NULL;
  1619. // Set the buttons for the starting wizard
  1620. //
  1621. SendMessage(GetParent(hwnd), PSM_SETWIZBUTTONS, 0, (LPARAM) dwButtons);
  1622. // Determine if we need to set the next button to the finish button
  1623. //
  1624. lpString = AllocateString(NULL, (dwButtons & PSWIZB_FINISH) ? IDS_FINISH : IDS_NEXT);
  1625. // ISSUE-2002/02/27-stelo,swamip - Make sure Buffer has been allocated.
  1626. SetDlgItemText(GetParent(hwnd), ID_MAINT_NEXT, lpString);
  1627. // Clean up the allocated memory
  1628. //
  1629. FREE(lpString);
  1630. // Set the maintenance mode buttons
  1631. //
  1632. EnableWindow(GetDlgItem(GetParent(hwnd), ID_MAINT_BACK), (dwButtons & PSWIZB_BACK));
  1633. EnableWindow(GetDlgItem(GetParent(hwnd), ID_MAINT_NEXT), (dwButtons & PSWIZB_NEXT) || (dwButtons & PSWIZB_FINISH));
  1634. }
  1635. static void ShowSplashDialog(HWND hwnd, DWORD dwResource)
  1636. {
  1637. DWORD dwIndex = 0,
  1638. dwDisplay = -1;
  1639. BOOL bFound = FALSE;
  1640. RECT rc;
  1641. // Loop through each dialog and hide any existing ones
  1642. //
  1643. for ( dwIndex = 0; dwIndex < AS(vdpSplashDialogs); dwIndex++)
  1644. {
  1645. // Hide existing windows
  1646. //
  1647. if ( vdpSplashDialogs[dwIndex].hWindow )
  1648. EndDialog(vdpSplashDialogs[dwIndex].hWindow, 0);
  1649. // Determine the one that we are going to display
  1650. //
  1651. if ( vdpSplashDialogs[dwIndex].dwResource == dwResource )
  1652. {
  1653. bFound = TRUE;
  1654. dwDisplay = dwIndex;
  1655. }
  1656. }
  1657. // We have been given a resource and we found it in the loop, display it
  1658. //
  1659. if ( dwResource && bFound)
  1660. {
  1661. if ( vdpSplashDialogs[dwDisplay].hWindow = CreateDialog(g_App.hInstance, MAKEINTRESOURCE(dwResource), hwnd, vdpSplashDialogs[dwDisplay].dlgWindowProc ))
  1662. {
  1663. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_BAR), SW_HIDE);
  1664. // Position the splash dialog on the splash frame
  1665. //
  1666. GetWindowRect(GetDlgItem(hwnd, IDC_SPLASHFRAME) , &rc);
  1667. MapWindowPoints(NULL, hwnd, (LPPOINT) &rc, 2);
  1668. SetWindowPos(vdpSplashDialogs[dwDisplay].hWindow, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOOWNERZORDER);
  1669. ShowWindow( vdpSplashDialogs[dwDisplay].hWindow, SW_SHOW );
  1670. }
  1671. }
  1672. else
  1673. ShowWindow(GetDlgItem(hwnd, IDC_MAINT_BAR), SW_SHOW);
  1674. }
  1675. INT_PTR CALLBACK AboutDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1676. {
  1677. switch ( uMsg )
  1678. {
  1679. case WM_INITDIALOG:
  1680. {
  1681. CHAR szCompany[] = VER_COMPANYNAME_STR,
  1682. szVersion[] = VER_FILEVERSION_STR,
  1683. szCopyright[] = VER_LEGALCOPYRIGHT_STR,
  1684. szDescription[] = VER_FILEDESCRIPTION_STR;
  1685. SetDlgItemTextA(hwnd, IDC_ABOUT_COMPANY, szCompany);
  1686. SetDlgItemTextA(hwnd, IDC_ABOUT_VERSION, szVersion);
  1687. SetDlgItemTextA(hwnd, IDC_ABOUT_COPYRIGHT, szCopyright);
  1688. SetDlgItemTextA(hwnd, IDC_ABOUT_DESCRIPTION, szDescription);
  1689. return FALSE;
  1690. }
  1691. case WM_COMMAND:
  1692. if ( LOWORD(wParam) == IDOK )
  1693. EndDialog(hwnd, LOWORD(wParam));
  1694. return FALSE;
  1695. default:
  1696. return FALSE;
  1697. }
  1698. return FALSE;
  1699. }