home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / setup / infinst / instwiz.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  27KB  |  814 lines

  1.  
  2. /******************************************************************************\
  3. *       This is a part of the Microsoft Source Code Samples. 
  4. *       Copyright (C) 1994-1997 Microsoft Corporation.
  5. *       All rights reserved. 
  6. *       This source code is only intended as a supplement to 
  7. *       Microsoft Development Tools and/or WinHelp documentation.
  8. *       See these sources for detailed information regarding the 
  9. *       Microsoft samples programs.
  10. \******************************************************************************/
  11.  
  12. //
  13. //
  14. //  This wizard code is adapted from the mstools\win32\wizard
  15. //  sample, refer to the wizard sample and the online help for 
  16. //  more information about wizards and property pages
  17. //
  18. //
  19. //  Functions:
  20. //      CreateWizard(HWND, HINSTANCE) - starts the wizard
  21. //        FillInPropertyPage() - Fills in a PROPSHEETPAGE structure
  22. //
  23. //        Welcome(),License(),YourInfo(),Install_Type(),Install_Destination(),
  24. //      Custom_Options(),Install()
  25. //           - Process the respective Install pages
  26. //
  27. //
  28.  
  29. #include <windows.h>
  30. #include "instwiz.h"
  31. #include "infinst.h"
  32.  
  33. // global license flag
  34. BOOL gLicenseAccepted = FALSE;
  35.  
  36. //
  37. //
  38. //    FUNCTION: CreateWizard(HWND)
  39. //
  40. //    PURPOSE: Create the Install control. 
  41. //
  42. //   COMMENTS:
  43. //    
  44. //      This function creates the install property sheet.
  45. //
  46. int CreateWizard(HWND hwndOwner, HINSTANCE hInst)
  47. {
  48.     PROPSHEETPAGE psp[NUM_PAGES];
  49.     PROPSHEETHEADER psh;
  50.  
  51.     FillInPropertyPage( &psp[0], IDD_WELCOME, TEXT("Welcome"), Welcome);
  52.     //FillInPropertyPage( &psp[1], IDD_LICENSE, TEXT("Software License Agreement"), License);
  53.     FillInPropertyPage( &psp[1], IDD_INFO, TEXT("Your Information"), YourInfo);
  54.     FillInPropertyPage( &psp[2], IDD_INSTALL_TYPE, TEXT("Installation Type"), Install_Type);
  55.     FillInPropertyPage( &psp[3], IDD_INSTALL_DESTINATION, TEXT("Installation Location"), Install_Destination);
  56.     FillInPropertyPage( &psp[4], IDD_CUSTOM_OPTIONS, TEXT("Custom Installation Options"), Custom_Options);
  57.     FillInPropertyPage( &psp[5], IDD_INSTALL, TEXT("Finish Installation"), Install);
  58.                    
  59.     psh.dwSize = sizeof(PROPSHEETHEADER);
  60.     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD | PSH_NOAPPLYNOW;
  61.     psh.hwndParent = hwndOwner;
  62.     psh.pszCaption = (LPSTR) TEXT("Product Install");
  63.     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  64.     psh.nStartPage = 0;
  65.     psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  66.  
  67.     return (PropertySheet(&psh));
  68. }
  69.  
  70.  
  71. //
  72. //
  73. //  FUNCTION: FillInPropertyPage(PROPSHEETPAGE *, int, LPSTR, LPFN) 
  74. //
  75. //  PURPOSE: Fills in the given PROPSHEETPAGE structure 
  76. //
  77. //  COMMENTS:
  78. //
  79. //      This function fills in a PROPSHEETPAGE structure with the
  80. //      information the system needs to create the page.
  81. // 
  82. void FillInPropertyPage( PROPSHEETPAGE* psp, int idDlg, LPSTR pszProc, DLGPROC pfnDlgProc)
  83. {
  84.     psp->dwSize = sizeof(PROPSHEETPAGE);
  85.     psp->dwFlags = 0;
  86.     psp->hInstance = setupInfo.hInst;
  87.     psp->pszTemplate = MAKEINTRESOURCE(idDlg);
  88.     psp->pszIcon = NULL;
  89.     psp->pfnDlgProc = pfnDlgProc;
  90.     psp->pszTitle = pszProc;
  91.     psp->lParam = 0;
  92.  
  93. }
  94.  
  95. //////////////////////////////////////////
  96. //
  97. // Wizard procs
  98. //
  99. //////////////////////////////////////////
  100.  
  101. //
  102. //  FUNCTION: Welcome (HWND, UINT, UINT, LONG)
  103. //
  104. //  PURPOSE:  Processes messages for "Welcome" page 
  105. //
  106. //  MESSAGES:
  107. //    
  108. //    WM_INITDIALOG - intializes the page
  109. //    WM_NOTIFY - processes the notifications sent to the page
  110. //    WM_COMMAND - saves the id of the choice selected
  111. //
  112. BOOL APIENTRY Welcome(
  113.     HWND hDlg,
  114.     UINT message,
  115.     UINT wParam,
  116.     LONG lParam)
  117. {
  118.  
  119.     switch (message)
  120.     {
  121.         case WM_INITDIALOG:
  122.             setupInfo.iWelcome = 0;
  123.                SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  124.             break;
  125.  
  126.                         
  127.         case WM_NOTIFY:
  128.             switch (((NMHDR FAR *) lParam)->code) 
  129.             {
  130.  
  131.                   case PSN_KILLACTIVE:
  132.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  133.                     return 1;
  134.                     break;
  135.  
  136.                 case PSN_RESET:
  137.                     // rest to the original values
  138.                     setupInfo.iWelcome = 0;
  139.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  140.                     break;
  141.  
  142.                  case PSN_SETACTIVE:
  143.                      PropSheet_SetWizButtons(GetParent(hDlg),  PSWIZB_NEXT);
  144.                     SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE,
  145.                                                    (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
  146.                     break;
  147.  
  148.                 case PSN_WIZNEXT:
  149.                     //
  150.                     // If they haven't accepted the license 
  151.                     // take them there, otherwise proceed with the wizard
  152.                     //
  153.                     if (TRUE != gLicenseAccepted) 
  154.                     {
  155.                         int nUserResponse;
  156.                         
  157.                         // Ask them to accept the license
  158.                         nUserResponse = DialogBox
  159.                             (setupInfo.hInst,
  160.                              MAKEINTRESOURCE(IDD_LICENSE),
  161.                              hDlg,
  162.                              (DLGPROC) License);
  163.                         
  164.                         if (IDC_LICENSE_ACCEPT == nUserResponse) 
  165.                         {
  166.                             // They agreed, now we won't show them the
  167.                             // license again
  168.                             gLicenseAccepted = TRUE;
  169.                         } 
  170.                         else
  171.                         {
  172.                             // the user just cancelled the install
  173.                             // by declining the license agreement
  174.                             // you could put dialog box here
  175.                             // making sure they realize that this will
  176.                             // cancel the installation
  177.                             PostQuitMessage(0);
  178.                             return 1;
  179.                         }
  180.                     }
  181.  
  182.                     break;
  183.  
  184.                     default:
  185.                         return FALSE;
  186.  
  187.         }
  188.         break;
  189.  
  190.         default:
  191.             return FALSE;
  192.     }
  193.     return TRUE;   
  194. }
  195.  
  196. //
  197. //  FUNCTION: License (HWND, UINT, UINT, LONG)
  198. //
  199. //  PURPOSE:  Processes messages for "License Agreement" page 
  200. //
  201. //  MESSAGES:
  202. //    
  203. //    WM_INITDIALOG - intializes the page
  204. //    WM_NOTIFY - processes the notifications sent to the page
  205. //    WM_COMMAND - saves the id of the choice selected
  206. //
  207. BOOL APIENTRY License(
  208.     HWND hDlg,
  209.     UINT message,
  210.     UINT wParam,
  211.     LONG lParam)
  212. {
  213.  
  214.     switch (message)
  215.     {
  216.         case WM_INITDIALOG:
  217.             {
  218.                 //Read in License fiel
  219.                 char szLicenseFile[MAX_PATH], ReturnTextBuffer[MAX_PATH]; 
  220.  
  221.                 LPSTR lpszLicenseFile = (char *) &szLicenseFile ;
  222.                 LPSTR lpszLicenseText;
  223.                 
  224.                 HWND hEditCtl;
  225.                 HANDLE hFile;
  226.  
  227.                 DWORD NumberOfBytesRead, dwFileSize;
  228.  
  229.                 //
  230.                 // Determine where we are installing from
  231.                 // and specific the license file there
  232.                 //
  233.                 GetModuleFileName(NULL, szLicenseFile, _MAX_PATH);
  234.                 *(strrchr(szLicenseFile, '\\') + 1) = '\0';        // Strip setup.exe off path
  235.                 
  236.                 strcat(szLicenseFile,TEXT("license.txt"));
  237.  
  238.                 // Open License file
  239.                 hFile = CreateFile(
  240.                                    lpszLicenseFile,       // pointer to name of the file 
  241.                                    GENERIC_READ,          // access (read-write) mode 
  242.                                    FILE_SHARE_READ,       // share mode 
  243.                                    NULL,                  // pointer to security descriptor 
  244.                                    OPEN_EXISTING,         // how to create 
  245.                                    FILE_ATTRIBUTE_NORMAL, // file attributes 
  246.                                    NULL);                 // handle to file with attributes to copy  
  247.                     
  248.                     if(INVALID_HANDLE_VALUE == hFile)
  249.                     {
  250.                         wsprintf(ReturnTextBuffer, "Error accessing file: %s", szLicenseFile);
  251.  
  252.                         MessageBox(hDlg, ReturnTextBuffer, 
  253.                                    "Sample Installation Critical Error", 0);
  254.  
  255.                         //install cannot proceed so go away
  256.                       
  257.                         PostQuitMessage(0);
  258.                         return FALSE;
  259.                     }
  260.  
  261.                     // Read License file into string
  262.                     // setup memory
  263.                     dwFileSize = GetFileSize (hFile, NULL) ;
  264.  
  265.                     lpszLicenseText = malloc ((dwFileSize + 1));
  266.                     
  267.                     if(NULL == lpszLicenseText)
  268.                     {
  269.                         wsprintf(ReturnTextBuffer, "Error allocating memory for license text.");
  270.                         CloseHandle(hFile);
  271.  
  272.                         MessageBox(hDlg, ReturnTextBuffer, 
  273.                             "Sample Installation Critical Error", 0);
  274.  
  275.                         //install cannot proceed so go away
  276.                         
  277.                         free(lpszLicenseText);
  278.                         PostQuitMessage(0);
  279.                         return FALSE;
  280.                     }
  281.  
  282.                     //read file
  283.                     if (!ReadFile(hFile,        // handle of file to read 
  284.                                   lpszLicenseText,    // address of buffer that receives data  
  285.                                   dwFileSize,        // number of bytes to read 
  286.                                   &NumberOfBytesRead,    // address of number of bytes read 
  287.                                   NULL))                // address of structure for data 
  288.                     {
  289.                         wsprintf(ReturnTextBuffer, "Error reading license file: %s", szLicenseFile);
  290.  
  291.                         // clean up
  292.                         free(lpszLicenseText);
  293.                         CloseHandle(hFile);
  294.                         
  295.                         MessageBox(hDlg, "Sample Installation Critical Error", 
  296.                                    ReturnTextBuffer, 0);
  297.  
  298.                         //install cannot proceed so go away
  299.  
  300.                         PostMessage(hDlg, WM_DESTROY, 0, 0 );
  301.                         return FALSE;
  302.                     }
  303.                       
  304.                 //Done with file
  305.                 CloseHandle(hFile);
  306.                 hFile = NULL;
  307.                                     
  308.                 // Be sure the file string is null terminated
  309.                 lpszLicenseText[dwFileSize] = '\0';
  310.                     
  311.                 SetDlgItemText(hDlg, LICENSE_TEXT, lpszLicenseText);
  312.        
  313.                 //set focus to license text
  314.                 hEditCtl = GetDlgItem(hDlg, LICENSE_TEXT);
  315.                 SetFocus(hEditCtl);
  316.  
  317.                 // the control now has the text
  318.                 // so free the memory
  319.                 free(lpszLicenseText);
  320.                 return(FALSE);
  321.             }
  322.  
  323.             break;
  324.  
  325.         case WM_COMMAND:
  326.             //
  327.             // LOWORD added for portability
  328.             //
  329.             switch(LOWORD(wParam)) {
  330.             case IDC_LICENSE_ACCEPT:
  331.                 EndDialog(hDlg, IDC_LICENSE_ACCEPT);
  332.                 return 0;
  333.             case IDC_LICENSE_DECLINE:
  334.                 EndDialog(hDlg, IDC_LICENSE_DECLINE);
  335.                 return 0;
  336.             }
  337.             break;
  338.         }
  339.     return(FALSE);
  340.  
  341.     UNREFERENCED_PARAMETER(lParam);
  342. }
  343.  
  344. //
  345. //  FUNCTION: YourInfo(HWND, UINT, UINT, LONG)
  346. //
  347. //  PURPOSE:  Processes messages for "Your Information" page 
  348. //
  349. //  MESSAGES:
  350. //    
  351. //    WM_INITDIALOG - intializes the page
  352. //    WM_NOTIFY - processes the notifications sent to the page
  353. //
  354. BOOL APIENTRY YourInfo(
  355.     HWND hDlg,
  356.     UINT message,
  357.     UINT wParam,
  358.     LONG lParam)
  359. {
  360.  
  361.     switch (message)
  362.     {
  363.         case WM_INITDIALOG:
  364.             break;
  365.  
  366.         case WM_NOTIFY:
  367.             switch (((NMHDR FAR *) lParam)->code) 
  368.             {
  369.  
  370.                   case PSN_KILLACTIVE:
  371.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  372.                     return 1;
  373.                     break;
  374.  
  375.                 case PSN_RESET:
  376.                     // reset to the blank values
  377.                     lstrcpy(setupInfo.pszUserName, TEXT(""));
  378.                     lstrcpy(setupInfo.pszCompany,TEXT(""));
  379.                     lstrcpy(setupInfo.pszProductIdString, TEXT(""));
  380.                     lstrcpy(setupInfo.pszEmailAddress, TEXT(""));
  381.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  382.                     break;
  383.  
  384.                  case PSN_SETACTIVE:
  385.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK |PSWIZB_NEXT);
  386.                     SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
  387.                     //SendMessage(GetParent(hDlg), DM_SETDEFID, (WPARAM)IDC_BUTTON1, 0);
  388.                     SendMessage(GetDlgItem(hDlg, IDE_NAME), 
  389.                                      WM_SETTEXT, 0, (LPARAM)setupInfo.pszUserName);
  390.                     SendMessage(GetDlgItem(hDlg, IDE_COMPANY), 
  391.                                      WM_SETTEXT, 0, (LPARAM)setupInfo.pszCompany);
  392.                     SendMessage(GetDlgItem(hDlg, IDE_PRODUCT_ID), 
  393.                                      WM_SETTEXT, 0, (LPARAM)setupInfo.pszProductIdString);
  394.                     SendMessage(GetDlgItem(hDlg, IDE_EMAIL), 
  395.                                      WM_SETTEXT, 0, (LPARAM)setupInfo.pszEmailAddress);
  396.                     break;
  397.  
  398.                 case PSN_WIZBACK:
  399.                     break;
  400.  
  401.                 case PSN_WIZNEXT:
  402.                     // the Next button was pressed
  403.                      SendDlgItemMessage(hDlg, IDE_NAME, WM_GETTEXT, 
  404.                                     (WPARAM)MAX_PATH, (LPARAM) setupInfo.pszUserName);
  405.                     SendDlgItemMessage(hDlg, IDE_COMPANY, WM_GETTEXT, 
  406.                                     (WPARAM)MAX_PATH, (LPARAM)setupInfo.pszCompany);
  407.                     SendDlgItemMessage(hDlg, IDE_PRODUCT_ID, WM_GETTEXT, 
  408.                                     (WPARAM)MAX_PATH, (LPARAM)setupInfo.pszProductIdString);
  409.                     SendDlgItemMessage(hDlg, IDE_EMAIL, WM_GETTEXT, 
  410.                                     (WPARAM)MAX_PATH, (LPARAM)setupInfo.pszEmailAddress);
  411.                     break;
  412.  
  413.                 default:
  414.                     return FALSE;
  415.  
  416.         }
  417.         break;
  418.  
  419.         default:
  420.             return FALSE;
  421.     }
  422.     return TRUE;   
  423. }
  424.  
  425. //
  426. //  FUNCTION: Install_Type (HWND, UINT, UINT, LONG)
  427. //
  428. //  PURPOSE:  Processes messages for "Install_Type" page 
  429. //
  430. //  MESSAGES:
  431. //    
  432. //    WM_INITDIALOG - intializes the page
  433. //    WM_NOTIFY - processes the notifications sent to the page
  434. //    WM_COMMAND - saves the id of the choice selected
  435. //
  436. BOOL APIENTRY Install_Type(
  437.     HWND hDlg,
  438.     UINT message,
  439.     UINT wParam,
  440.     LONG lParam)
  441. {
  442.  
  443.     switch (message)
  444.     {
  445.         case WM_INITDIALOG:
  446.             // pick normal as the default
  447.             setupInfo.iInstall_Type = IDC_INSTALL_TYPE_NORMAL;
  448.             CheckRadioButton( hDlg, IDC_INSTALL_TYPE_NORMAL, IDC_INSTALL_TYPE_UNINSTALL, 
  449.             IDC_INSTALL_TYPE_NORMAL);
  450.             setupInfo.iCustom_Options1 = 1;
  451.             setupInfo.iCustom_Options2 = 1;
  452.             setupInfo.iCustom_Options3 = 0;
  453.             setupInfo.iCustom_Options4 = 1;
  454.             break;
  455.  
  456.         case WM_COMMAND:
  457.             if (HIWORD(wParam) == BN_CLICKED)
  458.             {
  459.                 setupInfo.iInstall_Type = LOWORD(wParam);
  460.                 CheckRadioButton( hDlg, IDC_INSTALL_TYPE_NORMAL, IDC_INSTALL_TYPE_UNINSTALL, LOWORD(wParam));
  461.                 
  462.                 //TODO: you could change the wizard at this
  463.                 // point with add and remove page.
  464.                 // We will just set the options of custom options
  465.                 // for simplicity 
  466.                 
  467.                 // change the NEXT to FINISH if they want to uninstall
  468.                 if (IDC_INSTALL_TYPE_UNINSTALL == LOWORD(wParam))
  469.                 {
  470.                     //TODO: could check that the product is indeed
  471.                     // installed and if not, don't let them select
  472.                     // it--you could grey out the selection or 
  473.                     // you could just uninstall even though
  474.                     // it won't do anything
  475.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  476.                 }
  477.                 else
  478.                 {
  479.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  480.                 }
  481.                 
  482.                 // add in options according to what was seleced
  483.                 switch LOWORD(wParam)
  484.                 {
  485.                 case IDC_INSTALL_TYPE_CUSTOM:
  486.                     // first reset options to off
  487.                     setupInfo.iCustom_Options1 = 0;
  488.                     setupInfo.iCustom_Options2 = 0;
  489.                     setupInfo.iCustom_Options3 = 0;
  490.                     setupInfo.iCustom_Options4 = 0;
  491.                     break;
  492.                 case IDC_INSTALL_TYPE_NORMAL:
  493.                     setupInfo.iCustom_Options1 = 1;
  494.                     setupInfo.iCustom_Options2 = 1;
  495.                     setupInfo.iCustom_Options3 = 0;
  496.                     setupInfo.iCustom_Options4 = 1;
  497.                     break;
  498.                 case IDC_INSTALL_TYPE_MIN:
  499.                     setupInfo.iCustom_Options1 = 1;
  500.                     setupInfo.iCustom_Options2 = 1;
  501.                     setupInfo.iCustom_Options3 = 0;
  502.                     setupInfo.iCustom_Options4 = 0;
  503.                     break;
  504.                 default:
  505.                     break; 
  506.                 }
  507.             }
  508.  
  509.             break;    
  510.                         
  511.         case WM_NOTIFY:
  512.             switch (((NMHDR FAR *) lParam)->code) 
  513.             {
  514.  
  515.                   case PSN_KILLACTIVE:
  516.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  517.                     return 1;
  518.                     break;
  519.  
  520.                 case PSN_RESET:
  521.                     // rest to the original values
  522.                     setupInfo.iInstall_Type = 0;
  523.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  524.                     break;
  525.  
  526.                  case PSN_SETACTIVE:
  527.                                //if they have selected an install type, be sure
  528.                                //it is checked
  529.                                if (setupInfo.iInstall_Type)
  530.                         SendMessage(GetDlgItem(hDlg, setupInfo.iInstall_Type),
  531.                                             BM_SETCHECK, 1, 0L);
  532.  
  533.                                // Set the correct button NEXT or FINISH
  534.                                if (IDC_INSTALL_TYPE_UNINSTALL == setupInfo.iInstall_Type)
  535.                                {
  536.                                    //TODO: could check that the product is indeed
  537.                                    // installed and if not, don't let them select
  538.                                    // it--you could grey out the selection or 
  539.                                    // you could just uninstall even though
  540.                                    // it won't do anything
  541.                                    PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  542.                                }
  543.                                else
  544.                                {
  545.                                    PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  546.                                }
  547.             break;
  548.  
  549.                 case PSN_WIZBACK:
  550.                     break;
  551.  
  552.                 case PSN_WIZNEXT:
  553.                     break;
  554.  
  555.                 case PSN_WIZFINISH:
  556.                     // They finished the wizard, now do
  557.                     // what they said
  558.                     break;
  559.  
  560.                 default:
  561.                     return FALSE;
  562.  
  563.         }
  564.         break;
  565.  
  566.         default:
  567.             return FALSE;
  568.     }
  569.     return TRUE;   
  570. }
  571. //
  572. //  FUNCTION: Install_Destination(HWND, UINT, UINT, LONG)
  573. //
  574. //  PURPOSE:  Processes messages for "Install Destination" page 
  575. //
  576. //  MESSAGES:
  577. //    
  578. //    WM_INITDIALOG - intializes the page
  579. //    WM_NOTIFY - processes the notifications sent to the page
  580. //
  581. BOOL APIENTRY Install_Destination(
  582.     HWND hDlg,
  583.     UINT message,
  584.     UINT wParam,
  585.     LONG lParam)
  586. {
  587.  
  588.     switch (message)
  589.     {
  590.         case WM_INITDIALOG:
  591.             //lstrcpy(setupInfo.pszDestPath, TEXT(""));
  592.             break;
  593.  
  594.         case WM_NOTIFY:
  595.             switch (((NMHDR FAR *) lParam)->code) 
  596.             {
  597.                 //TODO: Add code here to check that the user entered
  598.                 //      path is valid and show the user disk space available
  599.                 //      You can also have more on disk space on the 
  600.                 //      customer options page.  
  601.                 //      So this sample does NOT verify the path and disk space
  602.                 //      requirements.  Note the setupapi functions will gracefully
  603.                 //      let the user know there is no disk space avail--at which
  604.                 //      time the user can go clean up some space or cancel the install
  605.  
  606.                   case PSN_KILLACTIVE:
  607.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  608.                     return 1;
  609.                     break;
  610.  
  611.                 case PSN_RESET:
  612.                     // reset to the original values
  613.                     lstrcpy(setupInfo.pszDestPath, TEXT(""));
  614.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  615.                     break;
  616.  
  617.                  case PSN_SETACTIVE:
  618.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK |PSWIZB_NEXT);
  619.                     SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
  620.                     SendMessage(GetDlgItem(hDlg, IDE_PATH), WM_SETTEXT, 0, (LPARAM)setupInfo.pszDestPath);
  621.                     break;
  622.  
  623.                 case PSN_WIZBACK:
  624.                     break;
  625.  
  626.                 case PSN_WIZNEXT:
  627.                     // the Next button was pressed
  628.                      SendDlgItemMessage(hDlg, IDE_PATH, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM) setupInfo.pszDestPath);
  629.                      break;
  630.  
  631.                 default:
  632.                     return FALSE;
  633.  
  634.         }
  635.         break;
  636.  
  637.         default:
  638.             return FALSE;
  639.     }
  640.     return TRUE;   
  641. }
  642. //
  643. //  FUNCTION: Custom_Options (HWND, UINT, UINT, LONG)
  644. //
  645. //  PURPOSE:  Processes messages for "Custom options" page 
  646. //
  647. //  MESSAGES:
  648. //    
  649. //    WM_INITDIALOG - intializes the page
  650. //    WM_NOTIFY - processes the notifications sent to the page
  651. //    WM_COMMAND - saves the id of the choice selected
  652. //
  653. BOOL APIENTRY Custom_Options(
  654.     HWND hDlg,
  655.     UINT message,
  656.     UINT wParam,
  657.     LONG lParam)
  658. {
  659.  
  660.     switch (message)
  661.     {
  662.         case WM_INITDIALOG:
  663.             // these are initialized via the install type page
  664.             // so we don't need to initialize anything
  665.             break;
  666.  
  667.         case WM_COMMAND:
  668.             if (HIWORD(wParam) == BN_CLICKED)
  669.             {
  670.                     if (LOWORD(wParam) == IDC_CUSTOM_OPTION1) {
  671.                         if (setupInfo.iCustom_Options1) {
  672.                              setupInfo.iCustom_Options1 = 0;
  673.                          } else {
  674.                              setupInfo.iCustom_Options1 = 1;
  675.                          }
  676.                      }
  677.  
  678.                      if (LOWORD(wParam) == IDC_CUSTOM_OPTION2) {
  679.                          if (setupInfo.iCustom_Options2) {
  680.                               setupInfo.iCustom_Options2 = 0;
  681.                           } else {
  682.                               setupInfo.iCustom_Options2 = 1;
  683.                           }
  684.                       }
  685.  
  686.                    if (LOWORD(wParam) == IDC_CUSTOM_OPTION3) {
  687.                          if (setupInfo.iCustom_Options3) {
  688.                               setupInfo.iCustom_Options3 = 0;
  689.                          } else {
  690.                               setupInfo.iCustom_Options3 = 1;
  691.                          }
  692.                       }
  693.  
  694.                   if (LOWORD(wParam) == IDC_CUSTOM_OPTION4) {
  695.                           if (setupInfo.iCustom_Options4) {
  696.                                setupInfo.iCustom_Options4 = 0;
  697.                           } else {
  698.                                setupInfo.iCustom_Options4 = 1;
  699.                       }
  700.                    }
  701.             }
  702.             break;    
  703.                         
  704.         case WM_NOTIFY:
  705.             switch (((NMHDR FAR *) lParam)->code) 
  706.             {
  707.  
  708.                   case PSN_KILLACTIVE:
  709.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  710.                     return 1;
  711.                     break;
  712.  
  713.                 case PSN_RESET:
  714.                     // rest to the original values
  715.                     setupInfo.iCustom_Options1 = 0;
  716.                     setupInfo.iCustom_Options2 = 0;
  717.                     setupInfo.iCustom_Options3 = 0;
  718.                     setupInfo.iCustom_Options4 = 0;
  719.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  720.                     break;
  721.  
  722.                  case PSN_SETACTIVE:
  723.                     CheckDlgButton (hDlg, IDC_CUSTOM_OPTION1, 
  724.                         setupInfo.iCustom_Options1);
  725.                     CheckDlgButton (hDlg, IDC_CUSTOM_OPTION2, 
  726.                         setupInfo.iCustom_Options2);
  727.                     CheckDlgButton (hDlg, IDC_CUSTOM_OPTION3, 
  728.                         setupInfo.iCustom_Options3);
  729.                     CheckDlgButton (hDlg, IDC_CUSTOM_OPTION4,
  730.                         setupInfo.iCustom_Options4);
  731.                      PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  732.                     break;
  733.  
  734.                 case PSN_WIZBACK:
  735.                     break;
  736.  
  737.                 case PSN_WIZNEXT:
  738.                     break;
  739.  
  740.                 default:
  741.                     return FALSE;
  742.  
  743.         }
  744.         break;
  745.  
  746.         default:
  747.             return FALSE;
  748.     }
  749.     return TRUE;   
  750. }
  751. //
  752. //  FUNCTION: Install(HWND, UINT, UINT, LONG)
  753. //
  754. //  PURPOSE:  Processes messages for "Installation" page 
  755. //
  756. //  MESSAGES:
  757. //    
  758. //    WM_INITDIALOG - intializes the page
  759. //    WM_NOTIFY - processes the notifications sent to the page
  760. //    WM_COMMAND - saves the id of the choice selected
  761. //
  762. //
  763. BOOL APIENTRY Install(
  764.     HWND hDlg,
  765.     UINT message,
  766.     UINT wParam,
  767.     LONG lParam)
  768. {
  769.  
  770.     switch (message)
  771.     {
  772.         case WM_INITDIALOG:
  773.             setupInfo.iInstall = 0;
  774.             break;
  775.  
  776.         case WM_NOTIFY:
  777.             switch (((NMHDR FAR *) lParam)->code) 
  778.             {
  779.                   case PSN_KILLACTIVE:
  780.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  781.                     return 1;
  782.                     break;
  783.  
  784.                 case PSN_RESET:
  785.                     // rest to the original values
  786.                     setupInfo.iInstall = 0;
  787.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  788.                     break;
  789.  
  790.                  case PSN_SETACTIVE:
  791.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  792.                     break;
  793.  
  794.                 case PSN_WIZBACK:
  795.                     break;
  796.  
  797.  
  798.                 case PSN_WIZFINISH:
  799.                     // They finished the wizard, now do
  800.                     // what they said
  801.                     break;
  802.  
  803.                 default:
  804.                     return FALSE;
  805.         }
  806.         break;
  807.  
  808.         default:
  809.             return FALSE;
  810.     }
  811.     return TRUE;   
  812. }
  813.  
  814.