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