home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winui / propsheet / comctl / wizard / wizard.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  20.7 KB  |  814 lines

  1. //THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  2. //ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  3. //THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright  1994-1996  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //    PROGRAM:    Wizard.c
  9. //
  10. //    PURPOSE:    Demonstrates how to manipulate a wizard control
  11. //
  12. //    PLATFORMS:    Windows 95
  13. //
  14. //    FUNCTIONS:    
  15. //        WinMain() - calls initialization function, processes message loop
  16. //        InitApplication() - Initializes window data nd registers window
  17. //        InitInstance() -saves instance handle and creates main window
  18. //        MainWindProc() Processes messages
  19. //        About() - Process messages for "About" dialog box
  20. //        YourInfo() - Process the "Your Information" Wizard page
  21. //        WorkHabits() - Processes the "Work Habits" Wizard page
  22. //        TeamWork() - Processes the "Team Work" Wizard page
  23. //        Reliability() - Processes the "Reliability" Wizard page
  24. //        Goals() - Processes the "Goal Attainment" Wizard page
  25. //         Adaptation() - Processes the "Adaptability to Change" Wizard page
  26. //        FillInPropertyPage() - Fills in a PROPSHEETPAGE structure
  27. //        CreateWizard() - Creates the wizard
  28. //        GenerateReview() - Generates the resulting review
  29. //
  30. //    SPECIAL INSTRUCTIONS: N/A
  31. //
  32.  
  33. #include <windows.h>    // includes basic windows functionality
  34. #include <string.h>     // includes the string functions
  35. #include <prsht.h>      // includes the property sheet functionality
  36. #include "resource.h"   // includes the definitions for the resources
  37. #include "wizard.h"     // includes the application-specific information
  38.  
  39. REVIEWINFO rvInfo;      // a structure containing the review information
  40. HWND hwndEdit;          // handle to the main MLE
  41. TCHAR lpReview[MAX_BUF]; // Buffer for the review
  42.  
  43. //
  44. //
  45. //   FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int)
  46. //
  47. //   PURPOSE: Main entry point for the application. 
  48. //
  49. //   COMMENTS:
  50. //    
  51. //    This function calls the initialization functions and processes
  52. //    the main message loop.
  53. // 
  54. int APIENTRY WinMain(
  55.     HINSTANCE hInstance,
  56.     HINSTANCE hPrevInstance,
  57.     LPSTR lpCmdLine,
  58.     int nCmdShow
  59.     )
  60. {
  61.     MSG msg;                       
  62.  
  63.       // save off the current instance
  64.     rvInfo.hInst = hInstance;
  65.  
  66.       // if the initialization fails, return.
  67.     if (!InitApplication(hInstance))
  68.         return (FALSE);     
  69.  
  70.     // Perform initializations that apply to a specific instance 
  71.     if (!InitInstance(hInstance, nCmdShow))
  72.         return (FALSE);
  73.  
  74.     // Acquire and dispatch messages until a WM_QUIT message is received. 
  75.     while (GetMessage(&msg,
  76.         NULL,              
  77.         0,                 
  78.         0))                
  79.     {
  80.         TranslateMessage(&msg);
  81.         DispatchMessage(&msg); 
  82.     }
  83.     return (msg.wParam);  
  84.                                                  
  85. }
  86.  
  87.  
  88. //
  89. //
  90. //   FUNCTION: InitApplication(HANDLE) 
  91. //
  92. //   PURPOSE: Initializes window data and registers window class 
  93. //
  94. //   COMMENTS:
  95. //
  96. //        This function registers the window class for the main window.    
  97. // 
  98. BOOL InitApplication(HANDLE hInstance)
  99. {
  100.         WNDCLASS  wcSample;
  101.     
  102.     // Fill in window class structure with parameters that describe the       
  103.     // main window.                                                           
  104.  
  105.         wcSample.style = 0;                     
  106.         wcSample.lpfnWndProc = (WNDPROC)MainWndProc; 
  107.         wcSample.cbClsExtra = 0;              
  108.         wcSample.cbWndExtra = 0;              
  109.         wcSample.hInstance = hInstance;       
  110.         wcSample.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(EXE_ICON));
  111.         wcSample.hCursor = LoadCursor(NULL, IDC_ARROW);
  112.         wcSample.hbrBackground = GetStockObject(WHITE_BRUSH); 
  113.         wcSample.lpszMenuName =  TEXT("WizardMenu");  
  114.         wcSample.lpszClassName = TEXT("SampleWClass");
  115.  
  116.         return (RegisterClass(&wcSample));
  117.  
  118. }
  119.  
  120.  
  121. //
  122. //
  123. //   FUNCTION: InitInstance(HANDLE, int)
  124. //
  125. //   PURPOSE: Creates the main window.
  126. //
  127. //   COMMENTS: N/A
  128. //    
  129. // 
  130. BOOL InitInstance(
  131.     HANDLE          hInstance,
  132.     int             nCmdShow) 
  133. {
  134.     HWND hWndMain;
  135.  
  136.     hWndMain = CreateWindow(
  137.                 TEXT("SampleWClass"),
  138.                 TEXT("Wizard Sample"), 
  139.         WS_OVERLAPPEDWINDOW,
  140.         CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  141.         NULL,               
  142.         NULL,               
  143.         hInstance,          
  144.         NULL);
  145.  
  146.     /* If window could not be created, return "failure" */
  147.     if (!hWndMain)
  148.         return (FALSE);
  149.  
  150.     /* Make the window visible; update its client area; and return "success" */
  151.     ShowWindow(hWndMain, nCmdShow);
  152.     UpdateWindow(hWndMain); 
  153.     return (TRUE);      
  154.  
  155. }
  156.  
  157. //
  158. //   FUNCTION: MainWndProc(HWND, UINT, UINT, LONG)
  159. //
  160. //  PURPOSE:  Processes messages for the main window procedure 
  161. //
  162. //    MESSAGES:
  163. //    
  164. //    WM_CREATE - creates the main MLE for the window
  165. //    WM_COMMAND - processes the menu commands for the application
  166. //    WM_SIZE - sizes the MLE to fill the client area of the window
  167. //    WM_DESTROY - posts a quit message and returns
  168. //
  169. LONG APIENTRY MainWndProc(
  170.     HWND hWnd,                // window handle                   
  171.     UINT message,             // type of message                 
  172.     UINT wParam,              // additional information          
  173.     LONG lParam)              // additional information          
  174. {
  175.  
  176.     switch (message) 
  177.     {
  178.         case WM_CREATE:
  179.             // Create an MLE for the file contents.
  180.             hwndEdit = CreateWindow(
  181.                 TEXT("EDIT"),     
  182.                 NULL,       
  183.                 WS_CHILD | WS_VISIBLE | ES_WANTRETURN |
  184.                     ES_MULTILINE | ES_AUTOVSCROLL,
  185.                 0, 0, 0, 0, 
  186.                 hWnd,       
  187.                 (HMENU) ID_EDITCHILD, 
  188.                 (HINSTANCE) GetWindowLong(hWnd, GWL_HINSTANCE),
  189.                 NULL);               
  190.  
  191.             // Update the MLE. 
  192.             SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM) "Choose Performance Review Wizard from the Options menu.");
  193.             return 0;
  194.  
  195.         case WM_SIZE:
  196.             // Make the edit control the size of the window's client area. 
  197.             MoveWindow(hwndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);          
  198.             return 0;
  199.  
  200.         case WM_COMMAND:
  201.             switch( LOWORD( wParam ))
  202.             {
  203.                 case IDM_WIZARD:
  204.                     CreateWizard(hWnd, rvInfo.hInst);
  205.  
  206.                     // Update the MLE. 
  207.                     if (SendMessage(hwndEdit, WM_SETTEXT, 0, (LPARAM) lpReview) != TRUE)
  208.                         MessageBox( hWnd, TEXT("Text not set!"), NULL, MB_OK);
  209.  
  210.                     break;
  211.  
  212.                 case IDM_EXIT:
  213.                     PostQuitMessage(0);
  214.                     break;
  215.  
  216.                 case IDM_ABOUT:
  217.                     DialogBox(rvInfo.hInst, TEXT("AboutBox"), hWnd, (DLGPROC)About);
  218.                     break;
  219.  
  220.                 default:
  221.                     return (DefWindowProc(hWnd, message, wParam, lParam));
  222.  
  223.         }
  224.         break;
  225.  
  226.         case WM_DESTROY:                  /* message: window being destroyed */
  227.             PostQuitMessage(0);
  228.             break;
  229.  
  230.         default:
  231.             return (DefWindowProc(hWnd, message, wParam, lParam));
  232.     }
  233.     return (0);
  234. }
  235.  
  236.  
  237. //
  238. //  FUNCTION: About(HWND, UINT, UINT, LONG)
  239. //
  240. //  PURPOSE:  Processes messages for the "About" dialog box 
  241. //
  242. //  MESSAGES:
  243. //    
  244. //    WM_INITDIALOG - initalizes the dialog box
  245. //    WM_COMMAND - processes the input
  246. //    
  247. BOOL APIENTRY About(
  248.    HWND hDlg,
  249.     UINT message,
  250.     UINT wParam,
  251.     LONG lParam)
  252. {
  253.     switch (message)
  254.     {
  255.        case WM_INITDIALOG:
  256.           return TRUE;
  257.  
  258.        case WM_COMMAND:              
  259.           if (LOWORD(wParam) == IDOK)
  260.          {
  261.               EndDialog(hDlg, TRUE);
  262.               return TRUE;
  263.           }
  264.           break;
  265.  
  266.         default:
  267.             return FALSE;
  268.     }
  269.  
  270. }
  271.  
  272. //
  273. //  FUNCTION: YourInfo(HWND, UINT, UINT, LONG)
  274. //
  275. //  PURPOSE:  Processes messages for "Your Information" page 
  276. //
  277. //  MESSAGES:
  278. //    
  279. //    WM_INITDIALOG - intializes the page
  280. //    WM_NOTIFY - processes the notifications sent to the page
  281. //
  282. BOOL APIENTRY YourInfo(
  283.     HWND hDlg,
  284.     UINT message,
  285.     UINT wParam,
  286.     LONG lParam)
  287. {
  288.  
  289.     switch (message)
  290.     {
  291.         case WM_INITDIALOG:
  292.             lstrcpy(rvInfo.pszName, TEXT(""));
  293.             lstrcpy(rvInfo.pszTitle, TEXT(""));
  294.             lstrcpy(rvInfo.pszProject, TEXT(""));
  295.             lstrcpy(rvInfo.pszDepartment, TEXT(""));
  296.             
  297.             break;
  298.  
  299.         case WM_NOTIFY:
  300.             switch (((NMHDR FAR *) lParam)->code) 
  301.             {
  302.  
  303.                   case PSN_KILLACTIVE:
  304.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  305.                     return 1;
  306.                     break;
  307.  
  308.                 case PSN_RESET:
  309.                     // reset to the original values
  310.                     lstrcpy(rvInfo.pszName, TEXT(""));
  311.                     lstrcpy(rvInfo.pszTitle,TEXT(""));
  312.                     lstrcpy(rvInfo.pszProject, TEXT(""));
  313.                     lstrcpy(rvInfo.pszDepartment, TEXT(""));
  314.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  315.                     break;
  316.  
  317.                  case PSN_SETACTIVE:
  318.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT);
  319.                     SendMessage(GetDlgItem(hDlg,0x3024 ), BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, MAKELONG(FALSE, 0));
  320.                     //SendMessage(GetParent(hDlg), DM_SETDEFID, (WPARAM)IDC_BUTTON1, 0);
  321.                     SendMessage(GetDlgItem(hDlg, IDE_NAME), WM_SETTEXT, 0, (LPARAM)rvInfo.pszName);
  322.                     SendMessage(GetDlgItem(hDlg, IDE_TITLE), WM_SETTEXT, 0, (LPARAM)rvInfo.pszTitle);
  323.                     SendMessage(GetDlgItem(hDlg, IDE_PROJECT), WM_SETTEXT, 0, (LPARAM)rvInfo.pszProject);
  324.                     SendMessage(GetDlgItem(hDlg, IDE_DEPARTMENT), WM_SETTEXT, 0, (LPARAM)rvInfo.pszDepartment);
  325.                     break;
  326.  
  327.                 case PSN_WIZNEXT:
  328.                     // the Next button was pressed
  329.                      SendDlgItemMessage(hDlg, IDE_NAME, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM) rvInfo.pszName);
  330.                     SendDlgItemMessage(hDlg, IDE_TITLE, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)rvInfo.pszTitle);
  331.                     SendDlgItemMessage(hDlg, IDE_PROJECT, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)rvInfo.pszProject);
  332.                     SendDlgItemMessage(hDlg, IDE_DEPARTMENT, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)rvInfo.pszDepartment);
  333.                      break;
  334.  
  335.                 default:
  336.                     return FALSE;
  337.  
  338.         }
  339.         break;
  340.  
  341.         default:
  342.             return FALSE;
  343.     }
  344.     return TRUE;   
  345. }
  346.  
  347. //
  348. //  FUNCTION: WorkHabits(HWND, UINT, UINT, LONG)
  349. //
  350. //  PURPOSE:  Processes messages for "Work Habits" page 
  351. //
  352. //  MESSAGES:
  353. //    
  354. //    WM_INITDIALOG - intializes the page
  355. //    WM_NOTIFY - processes the notifications sent to the page
  356. //    WM_COMMAND - saves the id of the choice selected
  357. //
  358. BOOL APIENTRY WorkHabits(
  359.     HWND hDlg,
  360.     UINT message,
  361.     UINT wParam,
  362.     LONG lParam)
  363. {
  364.  
  365.     switch (message)
  366.     {
  367.         case WM_INITDIALOG:
  368.             rvInfo.iWorkHabits = 0;
  369.             break;
  370.  
  371.         case WM_COMMAND:
  372.             if (HIWORD(wParam) == BN_CLICKED)
  373.             {
  374.                 rvInfo.iWorkHabits = LOWORD(wParam);
  375.                 CheckRadioButton( hDlg, IDC_WORKHAB1,IDC_WORKHAB4, LOWORD(wParam));
  376.             }
  377.             break;                
  378.  
  379.         case WM_NOTIFY:
  380.             switch (((NMHDR FAR *) lParam)->code) 
  381.             {
  382.  
  383.                   case PSN_KILLACTIVE:
  384.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  385.                     return 1;
  386.                     break;
  387.  
  388.                 case PSN_RESET:
  389.                     // rest to the original values
  390.                     rvInfo.iWorkHabits = 0;
  391.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  392.                     break;
  393.  
  394.                  case PSN_SETACTIVE:
  395.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_NEXT | PSWIZB_BACK);
  396.                     if (rvInfo.iWorkHabits)
  397.                         SendMessage(GetDlgItem(hDlg, rvInfo.iWorkHabits), BM_SETCHECK, 1, 0L);
  398.                     break;
  399.  
  400.                 case PSN_WIZNEXT:
  401.                     // get the selected radio button
  402.                      break;
  403.  
  404.                 default:
  405.                     return FALSE;
  406.  
  407.         }
  408.         break;
  409.  
  410.         default:
  411.             return FALSE;
  412.     }
  413.     return TRUE;   
  414. }
  415.  
  416. //
  417. //  FUNCTION: TeamWork(HWND, UINT, UINT, LONG)
  418. //
  419. //  PURPOSE:  Processes messages for "Team Work" page 
  420. //
  421. //  MESSAGES:
  422. //    
  423. //    WM_INITDIALOG - intializes the page
  424. //    WM_NOTIFY - processes the notifications sent to the page
  425. //    WM_COMMAND - saves the id of the choice selected
  426. //
  427. //
  428. BOOL APIENTRY TeamWork(
  429.     HWND hDlg,
  430.     UINT message,
  431.     UINT wParam,
  432.     LONG lParam)
  433. {
  434.  
  435.     switch (message)
  436.     {
  437.         case WM_INITDIALOG:
  438.             rvInfo.iTeamWork = 0;
  439.             break;
  440.  
  441.         case WM_COMMAND:
  442.             if (HIWORD(wParam) == BN_CLICKED)
  443.             {
  444.                 rvInfo.iTeamWork = LOWORD(wParam);
  445.                 CheckRadioButton( hDlg, IDC_TEAMWORK1,IDC_TEAMWORK4, LOWORD(wParam));
  446.             }
  447.             break;                
  448.         case WM_NOTIFY:
  449.             switch (((NMHDR FAR *) lParam)->code) 
  450.             {
  451.  
  452.                   case PSN_KILLACTIVE:
  453.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  454.                     return 1;
  455.                     break;
  456.  
  457.                 case PSN_RESET:
  458.                     // rest to the original values
  459.                     rvInfo.iTeamWork = 0;
  460.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  461.                     break;
  462.  
  463.                  case PSN_SETACTIVE:
  464.                     if (rvInfo.iTeamWork)
  465.                         SendMessage(GetDlgItem(hDlg, rvInfo.iTeamWork), BM_SETCHECK, 1, 0L);
  466.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  467.                     break;
  468.  
  469.                 case PSN_WIZBACK:
  470.                     break;
  471.  
  472.                 case PSN_WIZNEXT:
  473.                     break;
  474.  
  475.                 default:
  476.                     return FALSE;
  477.  
  478.         }
  479.         break;
  480.  
  481.         default:
  482.             return FALSE;
  483.  
  484.     }
  485.     return TRUE;   
  486. }
  487. //
  488. //  FUNCTION: Reliability(HWND, UINT, UINT, LONG)
  489. //
  490. //  PURPOSE:  Processes messages for "Reliability" page 
  491. //
  492. //  MESSAGES:
  493. //    
  494. //    WM_INITDIALOG - intializes the page
  495. //    WM_NOTIFY - processes the notifications sent to the page
  496. //    WM_COMMAND - saves the id of the choice selected
  497. //
  498. BOOL APIENTRY Reliability(
  499.     HWND hDlg,
  500.     UINT message,
  501.     UINT wParam,
  502.     LONG lParam)
  503. {
  504.  
  505.     switch (message)
  506.     {
  507.         case WM_INITDIALOG:
  508.             rvInfo.iReliability = 0;
  509.             break;
  510.  
  511.         case WM_COMMAND:
  512.             if (HIWORD(wParam) == BN_CLICKED)
  513.             {
  514.                 rvInfo.iReliability = LOWORD(wParam);
  515.                 CheckRadioButton( hDlg, IDC_RELIABILITY1,IDC_RELIABILITY4, LOWORD(wParam));
  516.             }
  517.             break;                
  518.  
  519.         case WM_NOTIFY:
  520.             switch (((NMHDR FAR *) lParam)->code) 
  521.             {
  522.  
  523.                   case PSN_KILLACTIVE:
  524.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  525.                     return 1;
  526.                     break;
  527.  
  528.                 case PSN_RESET:
  529.                     // rest to the original values
  530.                     rvInfo.iReliability = 0;
  531.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  532.                     break;
  533.  
  534.                  case PSN_SETACTIVE:
  535.                     if (rvInfo.iReliability)
  536.                         SendMessage(GetDlgItem(hDlg, rvInfo.iReliability), BM_SETCHECK, 1, 0L);
  537.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  538.                     break;
  539.  
  540.                 case PSN_WIZBACK:
  541.                     break;
  542.  
  543.                 case PSN_WIZNEXT:
  544.                     break;
  545.                 
  546.                 default:
  547.                     return FALSE;
  548.         }
  549.         break;
  550.         
  551.         default:
  552.             return FALSE;
  553.     }
  554.     return TRUE;   
  555. }
  556. //
  557. //  FUNCTION: Goals(HWND, UINT, UINT, LONG)
  558. //
  559. //  PURPOSE:  Processes messages for "Goal Attainment" page 
  560. //
  561. //  MESSAGES:
  562. //    
  563. //    WM_INITDIALOG - intializes the page
  564. //    WM_NOTIFY - processes the notifications sent to the page
  565. //    WM_COMMAND - saves the id of the choice selected
  566. //
  567. BOOL APIENTRY Goals(
  568.     HWND hDlg,
  569.     UINT message,
  570.     UINT wParam,
  571.     LONG lParam)
  572. {
  573.  
  574.     switch (message)
  575.     {
  576.         case WM_INITDIALOG:
  577.             rvInfo.iGoals = 0;
  578.             break;
  579.  
  580.         case WM_COMMAND:
  581.             if (HIWORD(wParam) == BN_CLICKED)
  582.             {
  583.                 rvInfo.iGoals = LOWORD(wParam);
  584.                 CheckRadioButton( hDlg, IDC_GOALS1, IDC_GOALS4, LOWORD(wParam));
  585.             }
  586.             break;    
  587.                         
  588.         case WM_NOTIFY:
  589.             switch (((NMHDR FAR *) lParam)->code) 
  590.             {
  591.  
  592.                   case PSN_KILLACTIVE:
  593.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  594.                     return 1;
  595.                     break;
  596.  
  597.                 case PSN_RESET:
  598.                     // rest to the original values
  599.                     rvInfo.iGoals = 0;
  600.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  601.                     break;
  602.  
  603.                  case PSN_SETACTIVE:
  604.                     if (rvInfo.iGoals)
  605.                         SendMessage(GetDlgItem(hDlg, rvInfo.iGoals), BM_SETCHECK, 1, 0L);
  606.                      PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_NEXT);
  607.                     break;
  608.  
  609.                 case PSN_WIZBACK:
  610.                     break;
  611.  
  612.                 case PSN_WIZNEXT:
  613.                     break;
  614.  
  615.                 default:
  616.                     return FALSE;
  617.  
  618.         }
  619.         break;
  620.  
  621.         default:
  622.             return FALSE;
  623.     }
  624.     return TRUE;   
  625. }
  626. //
  627. //  FUNCTION: Adaptation(HWND, UINT, UINT, LONG)
  628. //
  629. //  PURPOSE:  Processes messages for "Addaptability to Change" page 
  630. //
  631. //  MESSAGES:
  632. //    
  633. //    WM_INITDIALOG - intializes the page
  634. //    WM_NOTIFY - processes the notifications sent to the page
  635. //    WM_COMMAND - saves the id of the choice selected
  636. //
  637. //
  638. BOOL APIENTRY Adaptation(
  639.     HWND hDlg,
  640.     UINT message,
  641.     UINT wParam,
  642.     LONG lParam)
  643. {
  644.  
  645.     switch (message)
  646.     {
  647.         case WM_INITDIALOG:
  648.             rvInfo.iAdaptation = 0;
  649.             break;
  650.  
  651.         case WM_COMMAND:
  652.             if (HIWORD(wParam) == BN_CLICKED)
  653.             {
  654.                 rvInfo.iAdaptation = LOWORD(wParam);
  655.                 CheckRadioButton( hDlg, IDC_ADAPTATION1, IDC_ADAPTATION4, LOWORD(wParam));
  656.             }
  657.             break;                
  658.  
  659.         case WM_NOTIFY:
  660.             switch (((NMHDR FAR *) lParam)->code) 
  661.             {
  662.                   case PSN_KILLACTIVE:
  663.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  664.                     return 1;
  665.                     break;
  666.  
  667.                 case PSN_RESET:
  668.                     // rest to the original values
  669.                     rvInfo.iAdaptation = 0;
  670.                        SetWindowLong(hDlg,    DWL_MSGRESULT, FALSE);
  671.                     break;
  672.  
  673.                  case PSN_SETACTIVE:
  674.                     if (rvInfo.iAdaptation)
  675.                         SendMessage(GetDlgItem(hDlg, rvInfo.iAdaptation), BM_SETCHECK, 1, 0L);
  676.                     PropSheet_SetWizButtons(GetParent(hDlg), PSWIZB_BACK | PSWIZB_FINISH);
  677.                     break;
  678.  
  679.                 case PSN_WIZBACK:
  680.                     break;
  681.  
  682.  
  683.                 case PSN_WIZFINISH:
  684.                     GenerateReview(hDlg);
  685.                     break;
  686.  
  687.                 default:
  688.                     return FALSE;
  689.         }
  690.         break;
  691.  
  692.         default:
  693.             return FALSE;
  694.     }
  695.     return TRUE;   
  696. }
  697.  
  698. //
  699. //
  700. //  FUNCTION: FillInPropertyPage(PROPSHEETPAGE *, int, LPSTR, LPFN) 
  701. //
  702. //  PURPOSE: Fills in the given PROPSHEETPAGE structure 
  703. //
  704. //  COMMENTS:
  705. //
  706. //      This function fills in a PROPSHEETPAGE structure with the
  707. //      information the system needs to create the page.
  708. // 
  709. void FillInPropertyPage( PROPSHEETPAGE* psp, int idDlg, LPSTR pszProc, DLGPROC pfnDlgProc)
  710. {
  711.     psp->dwSize = sizeof(PROPSHEETPAGE);
  712.     psp->dwFlags = 0;
  713.     psp->hInstance = rvInfo.hInst;
  714.     psp->pszTemplate = MAKEINTRESOURCE(idDlg);
  715.     psp->pszIcon = NULL;
  716.     psp->pfnDlgProc = pfnDlgProc;
  717.     psp->pszTitle = pszProc;
  718.     psp->lParam = 0;
  719.  
  720. }
  721.  
  722. //
  723. //
  724. //    FUNCTION: CreateWizard(HWND)
  725. //
  726. //    PURPOSE: Create the Wizard control. 
  727. //
  728. //   COMMENTS:
  729. //    
  730. //      This function creates the wizard property sheet.
  731. //
  732. int CreateWizard(HWND hwndOwner, HINSTANCE hInst)
  733. {
  734.     PROPSHEETPAGE psp[NUM_PAGES];
  735.     PROPSHEETHEADER psh;
  736.  
  737.     FillInPropertyPage( &psp[0], IDD_INFO, TEXT("Your Information"), YourInfo);
  738.     FillInPropertyPage( &psp[1], IDD_WORKHABITS, TEXT("Work Habits"), WorkHabits);
  739.     FillInPropertyPage( &psp[2], IDD_TEAMWORK, TEXT("Team Work"), TeamWork);
  740.     FillInPropertyPage( &psp[3], IDD_RELIABILITY, TEXT("Reliability"), Reliability);
  741.     FillInPropertyPage( &psp[4], IDD_GOALS, TEXT("Attainment of Goals"), Goals);
  742.     FillInPropertyPage( &psp[5], IDD_ADAPTATION, TEXT("Adaptability to Change"), Adaptation);
  743.     
  744.     psh.dwSize = sizeof(PROPSHEETHEADER);
  745.     psh.dwFlags = PSH_PROPSHEETPAGE | PSH_WIZARD | PSH_NOAPPLYNOW;
  746.     psh.hwndParent = hwndOwner;
  747.     psh.pszCaption = (LPSTR) TEXT("Review Wizard");
  748.     psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  749.     psh.nStartPage = 0;
  750.     psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  751.  
  752.     return (PropertySheet(&psh));
  753. }
  754.  
  755. //
  756. //
  757. //    FUNCTION: GenerateReview(void)
  758. //
  759. //    PURPOSE: Generate the review. 
  760. //
  761. //   COMMENTS:
  762. //    
  763. //      This function generates the review based upon the answers
  764. //      given by the Wizard. The function translates lame reality into
  765. //      impressive-sounding manager-speak via a string table.
  766. //
  767. void GenerateReview( HWND hDlg )
  768. {
  769.     TCHAR lpBuf1[MAX_LINE];  // Buffers for the lines in the review.
  770.     TCHAR lpBuf2[MAX_LINE];
  771.     TCHAR lpBuf3[MAX_LINE];
  772.     TCHAR lpBuf4[MAX_LINE];
  773.     TCHAR lpBuf5[MAX_LINE];
  774.  
  775.  
  776.     wsprintf(lpReview, TEXT("Name: %s%C%C%C%CTitle: %s%C%C%C%CDepartment: %s%C%C%C%CMain Project: %s%C%C%C%C"),
  777.         rvInfo.pszName, 0x0d, 0x0a, 0x0d, 0x0a, 
  778.         rvInfo.pszTitle, 0x0d, 0x0a, 0x0d, 0x0a, 
  779.         rvInfo.pszDepartment, 0x0d, 0x0a, 0x0d, 0x0a, 
  780.         rvInfo.pszProject,0x0d, 0x0a, 0x0d, 0x0a );
  781.  
  782.     // Add a line describing work habits
  783.     if (LoadString(rvInfo.hInst, rvInfo.iWorkHabits, lpBuf1, sizeof(lpBuf1)) == 0)
  784.         MessageBox(hDlg, TEXT("Error loading string!"), NULL, MB_OK);
  785.     else
  786.         lstrcat(lpReview, lpBuf1);
  787.  
  788.     // Add a line describing team work
  789.     if (LoadString(rvInfo.hInst, rvInfo.iTeamWork, lpBuf2, sizeof(lpBuf2)) == 0)
  790.         MessageBox(hDlg, TEXT("Error loading string!"), NULL, MB_OK);
  791.     else
  792.         lstrcat(lpReview, lpBuf2);
  793.  
  794.     // Add a line describing reliability
  795.     if (LoadString(rvInfo.hInst, rvInfo.iReliability, lpBuf3, sizeof(lpBuf3)) == 0)
  796.         MessageBox(hDlg, TEXT("Error loading string!"), NULL, MB_OK);
  797.     else
  798.         lstrcat(lpReview, lpBuf3);
  799.  
  800.     // Add a line describing goals
  801.     if (LoadString(rvInfo.hInst, rvInfo.iGoals, lpBuf4, sizeof(lpBuf4)) == 0)
  802.         MessageBox(hDlg, TEXT("Error loading string!"), NULL, MB_OK);
  803.     else
  804.         lstrcat(lpReview, lpBuf4);
  805.  
  806.     // Add a line describing adaptability
  807.     if (LoadString(rvInfo.hInst, rvInfo.iAdaptation, lpBuf5, sizeof(lpBuf5)) == 0)
  808.         MessageBox(hDlg, TEXT("Error loading string!"), NULL, MB_OK);
  809.     else
  810.         lstrcat(lpReview, lpBuf5);
  811.  
  812.        
  813. }
  814.