INSTWIZ.C
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:26k
源码类别:

Windows编程

开发平台:

Visual C++

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