home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / TOOLKIT / WPS / CAR / CAR.C next >
C/C++ Source or Header  |  1994-11-17  |  76KB  |  2,473 lines

  1.  
  2. /******************************************************************************
  3. *
  4. *  Module Name: CAR.C
  5. *
  6. *  OS/2 Work Place Shell Sample Program
  7. *
  8. *  Copyright (C) 1992 IBM Corporation
  9. *
  10. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  11. *      sample code created by IBM Corporation. This sample code is not
  12. *      part of any standard or IBM product and is provided to you solely
  13. *      for  the purpose of assisting you in the development of your
  14. *      applications.  The code is provided "AS IS", without
  15. *      warranty of any kind.  IBM shall not be liable for any damages
  16. *      arising out of your use of the sample code, even if they have been
  17. *      advised of the possibility of such damages.                                                    *
  18. *
  19. *  Entry Points:
  20. *
  21. *     Class Methods:
  22. *
  23. *        carM_QueryModuleHandle
  24. *
  25. *     Overridden Class Methods:
  26. *
  27. *        carM_wpclsInitData
  28. *        carM_wpclsQueryDefaultHelp
  29. *        carM_wpclsQueryDefaultView
  30. *        carM_wpclsQueryDetailsInfo
  31. *        carM_wpclsQueryIconData
  32. *        carM_wpclsQueryStyle
  33. *        carM_wpclsQueryTitle
  34. *        carM_wpclsUnInitData
  35. *
  36. *     Instance Methods:
  37. *
  38. *        car_AddDashboardPage
  39. *        car_AddHornBeepPage
  40. *        car_BeepHorn
  41. *        car_QueryBrakes
  42. *        car_QueryDuration
  43. *        car_QueryHighTone
  44. *        car_QueryLowTone
  45. *        car_QuerySpeed
  46. *        car_SetBrakes
  47. *        car_SetDuration
  48. *        car_SetHighTone
  49. *        car_SetLowTone
  50. *        car_SetSpeed
  51. *
  52. *     Overridden Instance Methods:
  53. *
  54. *        car_wpAddSettingsPages
  55. *        car_wpFilterPopupMenu
  56. *        car_wpInitData
  57. *        car_wpMenuItemHelpSelected
  58. *        car_wpMenuItemSelected
  59. *        car_wpModifyPopupMenu
  60. *        car_wpViewObject
  61. *        car_wpQueryDetailsData
  62. *        car_wpRestoreState
  63. *        car_wpSaveState
  64. *        car_wpUnInitData
  65. *
  66. *     Non-Method Functions:
  67. *
  68. *        CarInit
  69. *        CarWndProc
  70. *        DashBoardDlgProc
  71. *        HornBeepDlgProc
  72. *
  73. ******************************************************************************/
  74.  
  75. #define Car_Class_Source
  76. #define M_Car_Class_Source
  77.  
  78. #include "car.ih"              /* implementation header emitted from car.idl */
  79. #include "car.h"
  80.  
  81.  
  82. #include <string.h>
  83. #include <stdio.h>
  84. #include <memory.h>
  85. #include <stdlib.h>
  86. #include <setjmp.h>
  87.  
  88. /*
  89.  *   Non-Method function prototypes
  90.  */
  91.  
  92. HWND             CarInit (Car*);
  93. MRESULT EXPENTRY DashBoardDlgProc( HWND hwnd, ULONG msg,
  94.                                    MPARAM mp1, MPARAM mp2 );
  95. MRESULT EXPENTRY HornBeepDlgProc( HWND hwnd, ULONG msg,
  96.                                    MPARAM mp1, MPARAM mp2 );
  97. MRESULT EXPENTRY CarWndProc ( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 );
  98.  
  99. #pragma linkage(_Exception, system)
  100. ULONG _Exception(EXCEPTIONREPORTRECORD       *parg,
  101.                  EXCEPTIONREGISTRATIONRECORD *pRegisRecord,
  102.                  PCONTEXTRECORD               pContextRecord,
  103.                  PVOID                        pvSpare);
  104.  
  105.  
  106.  
  107. /***************** GLOBAL/STATIC (NON-INSTANCE) DATA SECTION ******************
  108. *****                                                                     *****
  109. *****    This data shouldn't be changed by instance methods or it will    *****
  110. *****    effect all instances!  Any variables that are specific (unique   *****
  111. *****    values) for each instance of this object should be declared as   *****
  112. *****  instance data or dynamically allocated and stored as window data.  *****
  113. *****                                                                     *****
  114. *****      This global data should be declared as class instance data     *****
  115. *****    if it will change after initialization.  In this case, it will   *****
  116. *****                  be accessed through class methods.                 *****
  117. *****                                                                     *****
  118. ******************************************************************************/
  119.  
  120.  
  121.    CHAR       szCarWindowClass[] =    "CARSAMPLE";
  122.    CHAR       szCarInstanceFilter[] = "*.CAR";
  123.    CHAR       szHelpLibrary[] =       "car.hlp";
  124.    UCHAR      szCarClassTitle[CCHMAXPATH] = "";
  125.    HMODULE    hmod = NULLHANDLE;
  126.  
  127.    PSZ        pszDefaultText ="\
  128.                                \n\
  129.      Bill of Sale              \n\
  130.    =========================   \n\
  131.                                \n\
  132.    Make........ Toyota         \n\
  133.                                \n\
  134.    Model....... Camry          \n\
  135.                                \n\
  136.    Color....... Blue           \n\
  137.                                \n\
  138.    Sale Date... 3/31/92        \n\
  139.                                \n\
  140.    Price....... 14,995         \n";
  141.  
  142.    /*
  143.     *   Globals required for Exception handling
  144.     */
  145.  
  146.    jmp_buf jmpState;
  147.  
  148.    PSZ pszTrapMessage =                        "\
  149. \
  150. A Memory Access Violation occurred.  The Car \
  151. sample's exception handler has transferred \
  152. control back to the cleanup code in the method \
  153. where the exception occurred.\n";
  154.  
  155.    /*
  156.     *   Statics required for FIELDINFO structures needed for DETAILS view are
  157.     *   handled in the three functions:
  158.     *
  159.     *   car_wpclsInitData, car_wpQueryDetailsData, car_wpQueryClassDetailsInfo
  160.     */
  161.  
  162.    #define NUM_CAR_FIELDS    5
  163.  
  164.    CLASSFIELDINFO fieldinfo[NUM_CAR_FIELDS];      /* structure in wpobject.h */
  165.  
  166.    PSZ apszCarColTitles[] =
  167.    {
  168.       "Make",           /* details column 1 */
  169.       "Model",          /* details column 2 */
  170.       "Color",          /* details column 3 */
  171.       "Sale date",      /* details column 4 */
  172.       "Price ($)"       /* details column 5 */
  173.    };
  174.  
  175.  
  176. /*************************  INSTANCE METHODS SECTION  *************************
  177. *****                                                                     *****
  178. *****              Do not put any code in this section unless             *****
  179. *****                   it is an object INSTANCE method                   *****
  180. *****                                                                     *****
  181. ******************************************************************************/
  182. #undef SOM_CurrentClass
  183. #define SOM_CurrentClass SOMInstance
  184.  
  185.  
  186. /*
  187.  *
  188.  *  METHOD: QueryBrakes                                    ( ) PRIVATE
  189.  *                                                         (X) PUBLIC
  190.  *  DESCRIPTION:
  191.  *
  192.  *    Query state of car's brakes
  193.  *
  194.  *  RETURN:
  195.  *
  196.  *    TRUE           Brake is on
  197.  *    FALSE          Brake is off
  198.  *
  199.  */
  200.  
  201. /*
  202.  * METHOD: QueryBrakes                                    ( ) PRIVATE
  203.  *                                                        (X) PUBLIC
  204.  * DESCRIPTION:
  205.  *
  206.  *   Query state of car's brakes
  207.  *
  208.  * RETURN:
  209.  *
  210.  *   TRUE           Brake is on
  211.  *   FALSE          Brake is off
  212.  */
  213.  
  214. SOM_Scope BOOL   SOMLINK car_QueryBrakes(Car *somSelf)
  215. {
  216.    CarData *somThis = CarGetData(somSelf);
  217.    CarMethodDebug("Car","car_QueryBrakes");
  218.  
  219.    return _BrakeFlag;
  220. }
  221.  
  222. /*
  223.  *
  224.  *  METHOD: SetBrakes                                      ( ) PRIVATE
  225.  *                                                         (X) PUBLIC
  226.  *  DESCRIPTION:
  227.  *
  228.  *    Put on the brakes
  229.  *
  230.  *  RETURN:
  231.  *
  232.  *    TRUE           state changed
  233.  *    FALSE          state didn't change
  234.  *
  235.  */
  236. /*
  237.  * SOM_Scope VOID  SOMLINK car_SetBrakes(Car *somSelf, BOOL fBrake)
  238.  */
  239.  
  240. /*
  241.  * The prototype for car_SetBrakes was replaced by the following prototype:
  242.  */
  243. /*
  244.  * METHOD: SetBrakes                                      ( ) PRIVATE
  245.  *                                                        (X) PUBLIC
  246.  * DESCRIPTION:
  247.  *
  248.  *   Put on the brakes
  249.  */
  250.  
  251. SOM_Scope void  SOMLINK car_SetBrakes(Car *somSelf, BOOL fBrake)
  252. {
  253.     CarData *somThis = CarGetData(somSelf);
  254.     CarMethodDebug("Car","car_SetBrakes");
  255.  
  256.     _BrakeFlag = fBrake;
  257. }
  258.  
  259. /*
  260.  *
  261.  *  METHOD: QueryDuration                                  ( ) PRIVATE
  262.  *                                                         (X) PUBLIC
  263.  *  DESCRIPTION:
  264.  *
  265.  *    Query Duration of horn beep
  266.  *
  267.  *  RETURN:
  268.  *
  269.  *    ULONG          Duration of beep
  270.  *
  271.  */
  272.  
  273. /*
  274.  * METHOD: QueryDuration                                  ( ) PRIVATE
  275.  *                                                        (X) PUBLIC
  276.  * DESCRIPTION:
  277.  *
  278.  *   Query Duration of horn beep
  279.  *
  280.  * RETURN:
  281.  *
  282.  *   ULONG          Duration of beep
  283.  */
  284.  
  285. SOM_Scope ULONG  SOMLINK car_QueryDuration(Car *somSelf)
  286. {
  287.     CarData *somThis = CarGetData(somSelf);
  288.     CarMethodDebug("Car","car_QueryDuration");
  289.  
  290.     return _duration;
  291. }
  292.  
  293. /*
  294.  *
  295.  *  METHOD: SetDuration                                    ( ) PRIVATE
  296.  *                                                         (X) PUBLIC
  297.  *  DESCRIPTION:
  298.  *
  299.  *    Set Duration of horn beep
  300.  *
  301.  *  RETURN:
  302.  *
  303.  *    TRUE           Duration changed
  304.  *    FALSE          Duration didn't change
  305.  *
  306.  */
  307.  
  308.  
  309. /*
  310.  * SOM_Scope VOID  SOMLINK car_SetDuration(Car *somSelf, ULONG ulDuration)
  311.  */
  312.  
  313. /*
  314.  * The prototype for car_SetDuration was replaced by the following prototype:
  315.  */
  316. /*
  317.  * METHOD: SetDuration                                    ( ) PRIVATE
  318.  *                                                        (X) PUBLIC
  319.  * DESCRIPTION:
  320.  *
  321.  *   Set Duration of horn beep
  322.  */
  323.  
  324. SOM_Scope void  SOMLINK car_SetDuration(Car *somSelf, ULONG ulDuration)
  325. {
  326.     CarData *somThis = CarGetData(somSelf);
  327.     CarMethodDebug("Car","car_SetDuration");
  328.  
  329.     _duration = ulDuration;
  330. }
  331.  
  332. /*
  333.  *
  334.  *  METHOD: QueryHighTone                                  ( ) PRIVATE
  335.  *                                                         (X) PUBLIC
  336.  *  DESCRIPTION:
  337.  *
  338.  *    Query HighTone of horn
  339.  *
  340.  *  RETURN:
  341.  *
  342.  *    ULONG          High frequency of horn
  343.  *
  344.  */
  345.  
  346. /*
  347.  * METHOD: QueryHighTone                                  ( ) PRIVATE
  348.  *                                                        (X) PUBLIC
  349.  * DESCRIPTION:
  350.  *
  351.  *   Query HighTone of horn
  352.  *
  353.  * RETURN:
  354.  *
  355.  *   ULONG          High frequency of horn
  356.  */
  357.  
  358. SOM_Scope ULONG  SOMLINK car_QueryHighTone(Car *somSelf)
  359. {
  360.     CarData *somThis = CarGetData(somSelf);
  361.     CarMethodDebug("Car","car_QueryHighTone");
  362.  
  363.     return _HighTone;
  364. }
  365.  
  366. /*
  367.  *
  368.  *  METHOD: SetHighTone                                    ( ) PRIVATE
  369.  *                                                         (X) PUBLIC
  370.  *  DESCRIPTION:
  371.  *
  372.  *    Set HighTone of horn
  373.  *
  374.  *  RETURN:
  375.  *
  376.  *    TRUE           Tone changed
  377.  *    FALSE          Tone didn't change
  378.  *
  379.  */
  380.  
  381.  
  382. /*
  383.  * SOM_Scope VOID  SOMLINK car_SetHighTone(Car *somSelf, ULONG ulTone)
  384.  */
  385.  
  386. /*
  387.  * The prototype for car_SetHighTone was replaced by the following prototype:
  388.  */
  389. /*
  390.  * METHOD: SetHighTone                                    ( ) PRIVATE
  391.  *                                                        (X) PUBLIC
  392.  * DESCRIPTION:
  393.  *
  394.  *   Set HighTone of horn
  395.  */
  396.  
  397. SOM_Scope void  SOMLINK car_SetHighTone(Car *somSelf, ULONG ulTone)
  398. {
  399.     CarData *somThis = CarGetData(somSelf);
  400.     CarMethodDebug("Car","car_SetHighTone");
  401.  
  402.     _HighTone = ulTone;
  403. }
  404.  
  405. /*
  406.  *
  407.  *  METHOD: QueryLowTone                                  ( ) PRIVATE
  408.  *                                                         (X) PUBLIC
  409.  *  DESCRIPTION:
  410.  *
  411.  *    Query LowTone of horn
  412.  *
  413.  *  RETURN:
  414.  *
  415.  *    ULONG          High frequency of horn
  416.  *
  417.  */
  418.  
  419. /*
  420.  * METHOD: QueryLowTone                                   ( ) PRIVATE
  421.  *                                                        (X) PUBLIC
  422.  * DESCRIPTION:
  423.  *
  424.  *   Query LowTone of horn
  425.  *
  426.  * RETURN:
  427.  *
  428.  *   ULONG          High frequency of horn
  429.  */
  430.  
  431. SOM_Scope ULONG  SOMLINK car_QueryLowTone(Car *somSelf)
  432. {
  433.     CarData *somThis = CarGetData(somSelf);
  434.     CarMethodDebug("Car","car_QueryLowTone");
  435.  
  436.     return _LowTone;
  437. }
  438.  
  439. /*
  440.  *
  441.  *  METHOD: SetLowTone                                    ( ) PRIVATE
  442.  *                                                         (X) PUBLIC
  443.  *  DESCRIPTION:
  444.  *
  445.  *    Set LowTone of horn
  446.  *
  447.  *  RETURN:
  448.  *
  449.  *    TRUE           Tone changed
  450.  *    FALSE          Tone didn't change
  451.  *
  452.  */
  453.  
  454.  
  455. /*
  456.  * SOM_Scope VOID  SOMLINK car_SetLowTone(Car *somSelf, ULONG ulTone)
  457.  */
  458.  
  459. /*
  460.  * The prototype for car_SetLowTone was replaced by the following prototype:
  461.  */
  462. /*
  463.  * METHOD: SetLowTone                                     ( ) PRIVATE
  464.  *                                                        (X) PUBLIC
  465.  * DESCRIPTION:
  466.  *
  467.  *   Set LowTone of horn
  468.  */
  469.  
  470. SOM_Scope void  SOMLINK car_SetLowTone(Car *somSelf, ULONG ulTone)
  471. {
  472.     CarData *somThis = CarGetData(somSelf);
  473.     CarMethodDebug("Car","car_SetLowTone");
  474.  
  475.     _LowTone = ulTone;
  476. }
  477.  
  478. /*
  479.  *
  480.  *  METHOD: QuerySpeed                                     ( ) PRIVATE
  481.  *                                                         (X) PUBLIC
  482.  *  DESCRIPTION:
  483.  *
  484.  *    Query Speed of car
  485.  *
  486.  *  RETURN:
  487.  *
  488.  *    ULONG          car speed
  489.  *
  490.  */
  491.  
  492. /*
  493.  * METHOD: QuerySpeed                                     ( ) PRIVATE
  494.  *                                                        (X) PUBLIC
  495.  * DESCRIPTION:
  496.  *
  497.  *   Query Speed of car
  498.  *
  499.  * RETURN:
  500.  *
  501.  *   ULONG          car speed
  502.  */
  503.  
  504. SOM_Scope ULONG  SOMLINK car_QuerySpeed(Car *somSelf)
  505. {
  506.     CarData *somThis = CarGetData(somSelf);
  507.     CarMethodDebug("Car","car_QuerySpeed");
  508.  
  509.     return _speed;
  510. }
  511.  
  512. /*
  513.  *
  514.  *  METHOD: SetSpeed                                       ( ) PRIVATE
  515.  *                                                         (X) PUBLIC
  516.  *  DESCRIPTION:
  517.  *
  518.  *    Set Speed of car
  519.  *
  520.  *  RETURN:
  521.  *
  522.  *    TRUE           speed changed
  523.  *    FALSE          speed didn't change
  524.  *
  525.  */
  526.  
  527.  
  528. /*
  529.  * SOM_Scope VOID  SOMLINK car_SetSpeed(Car *somSelf, ULONG ulSpeed)
  530.  */
  531.  
  532. /*
  533.  * The prototype for car_SetSpeed was replaced by the following prototype:
  534.  */
  535. /*
  536.  * METHOD: SetSpeed                                       ( ) PRIVATE
  537.  *                                                        (X) PUBLIC
  538.  * DESCRIPTION:
  539.  *
  540.  *   Set Speed of car
  541.  */
  542.  
  543. SOM_Scope void  SOMLINK car_SetSpeed(Car *somSelf, ULONG ulSpeed)
  544. {
  545.     CarData *somThis = CarGetData(somSelf);
  546.     CarMethodDebug("Car","car_SetSpeed");
  547.  
  548.     _speed = ulSpeed;
  549. }
  550.  
  551. /*
  552.  *
  553.  *  METHOD: BeepHorn                                       ( ) PRIVATE
  554.  *                                                         (X) PUBLIC
  555.  *  DESCRIPTION:
  556.  *
  557.  *    Beep the car's horn.
  558.  *
  559.  *  RETURN:
  560.  *
  561.  *    TRUE           Successful
  562.  *    FALSE          Unsuccessful
  563.  *
  564.  */
  565.  
  566. /*
  567.  * METHOD: BeepHorn                                       ( ) PRIVATE
  568.  *                                                        (X) PUBLIC
  569.  * DESCRIPTION:
  570.  *
  571.  *   Beep the car's horn.
  572.  *
  573.  * RETURN:
  574.  *
  575.  *   TRUE           Successful
  576.  *   FALSE          Unsuccessful
  577.  */
  578.  
  579. SOM_Scope BOOL SOMLINK car_BeepHorn(Car *somSelf)
  580. {
  581.     USHORT i;
  582.  
  583.     CarData *somThis = CarGetData(somSelf);
  584.     CarMethodDebug("Car","car_BeepHorn");
  585.  
  586.     DosBeep(_QueryHighTone(somSelf), _QueryDuration(somSelf));
  587.     DosSleep(100);
  588.     DosBeep(_QueryLowTone(somSelf), _QueryDuration(somSelf));
  589.  
  590.     return TRUE;
  591.  
  592. }   /* end car_BeepHorn() */
  593.  
  594. /*
  595.  *
  596.  *  METHOD: AddDashboardPage                               ( ) PRIVATE
  597.  *                                                         (X) PUBLIC
  598.  *  DESCRIPTION:
  599.  *
  600.  *    This method adds the dashboard page to the settings notebook.
  601.  *
  602.  *  RETURN:
  603.  *
  604.  *    0              Unsuccessful
  605.  *    ulPageId       Identifier for the inserted page
  606.  *
  607.  *  HOW TO OVERRIDE:
  608.  *
  609.  *    Method should always be overridden in order to replace or remove
  610.  *    the dashboard page from an object which is a descendent of Car.
  611.  *    In most cases, an override of this method will not call the parent.
  612.  *
  613.  */
  614.  
  615. /*
  616.  * METHOD: AddDashboardPage                               ( ) PRIVATE
  617.  *                                                        (X) PUBLIC
  618.  * DESCRIPTION:
  619.  *
  620.  *   This method adds the dashboard page to the settings notebook.
  621.  *
  622.  * RETURN:
  623.  *
  624.  *   0              Unsuccessful
  625.  *   ulPageId       Identifier for the inserted page
  626.  *
  627.  * HOW TO OVERRIDE:
  628.  *
  629.  *   Method should always be overridden in order to replace or remove
  630.  *   the dashboard page from an object which is a descendent of Car.
  631.  *   In most cases, an override of this method will not call the parent.
  632.  */
  633.  
  634. SOM_Scope ULONG SOMLINK car_AddDashboardPage(Car *somSelf, HWND hwndNotebook)
  635. {
  636.     PAGEINFO pageinfo;
  637.  
  638.     CarData *somThis = CarGetData(somSelf);
  639.     CarMethodDebug("Car","car_AddDashboardPage");
  640.  
  641.     memset((PCH)&pageinfo,0,sizeof(PAGEINFO));
  642.     pageinfo.cb                 = sizeof(PAGEINFO);
  643.     pageinfo.hwndPage           = NULLHANDLE;
  644.     pageinfo.usPageStyleFlags   = BKA_MAJOR;
  645.     pageinfo.usPageInsertFlags  = BKA_FIRST;
  646.     pageinfo.pfnwp              = DashBoardDlgProc;
  647.     pageinfo.resid              = hmod;
  648.     pageinfo.dlgid              = IDD_DASHBOARD;
  649.     pageinfo.pszName            = "Dashboard";
  650.     pageinfo.pCreateParams      = somSelf;
  651.     pageinfo.idDefaultHelpPanel = ID_HELP_DASHBOARD;
  652.     pageinfo.pszHelpLibraryName = szHelpLibrary;
  653.  
  654.     return _wpInsertSettingsPage( somSelf, hwndNotebook, &pageinfo );
  655.  
  656. }   /* end car_AddDashboardPage() */
  657.  
  658.  
  659. /*
  660.  *
  661.  *  METHOD: AddHornBeepPage                                ( ) PRIVATE
  662.  *                                                         (X) PUBLIC
  663.  *  DESCRIPTION:
  664.  *
  665.  *    This method adds the horn beep page to the settings
  666.  *    notebook.
  667.  *
  668.  *  RETURN:
  669.  *
  670.  *    0              Unsuccessful
  671.  *    ulPageId       Identifier for the inserted page
  672.  *
  673.  *  HOW TO OVERRIDE:
  674.  *
  675.  *    Method should always be overridden in order to replace or remove
  676.  *    the horn beep page from an object which is a descendent of Car.
  677.  *    In most cases, an override of this method will not call the parent.
  678.  *
  679.  *
  680.  *    Methods from the WPObject class
  681.  *
  682.  */
  683.  
  684. /*
  685.  * METHOD: AddHornBeepPage                                ( ) PRIVATE
  686.  *                                                        (X) PUBLIC
  687.  * DESCRIPTION:
  688.  *
  689.  *   This method adds the horn beep page to the settings
  690.  *   notebook.
  691.  *
  692.  * RETURN:
  693.  *
  694.  *   0              Unsuccessful
  695.  *   ulPageId       Identifier for the inserted page
  696.  *
  697.  * HOW TO OVERRIDE:
  698.  *
  699.  *   Method should always be overridden in order to replace or remove
  700.  *   the horn beep page from an object which is a descendent of Car.
  701.  *   In most cases, an override of this method will not call the parent.
  702.  */
  703.  
  704. SOM_Scope ULONG SOMLINK car_AddHornBeepPage(Car *somSelf, HWND hwndNotebook)
  705. {
  706.     PAGEINFO pageinfo;
  707.  
  708.     CarData *somThis = CarGetData(somSelf);
  709.     CarMethodDebug("Car","car_AddHornBeepPage");
  710.  
  711.     /* Insert the settings pages for a car
  712.      */
  713.     memset((PCH)&pageinfo,0,sizeof(PAGEINFO));
  714.     pageinfo.cb                 = sizeof(PAGEINFO);
  715.     pageinfo.hwndPage           = NULLHANDLE;
  716.     pageinfo.usPageStyleFlags   = BKA_MAJOR;
  717.     pageinfo.usPageInsertFlags  = BKA_FIRST;
  718.     pageinfo.pfnwp              = HornBeepDlgProc;
  719.     pageinfo.resid              = hmod;
  720.     pageinfo.dlgid              = IDD_HORNBEEP;
  721.     pageinfo.pszName            = "Horn Beep";
  722.     pageinfo.pCreateParams      = somSelf;
  723.     pageinfo.idDefaultHelpPanel = ID_HELP_HORNBEEP;
  724.     pageinfo.pszHelpLibraryName = szHelpLibrary;
  725.  
  726.     return _wpInsertSettingsPage( somSelf, hwndNotebook, &pageinfo );
  727.  
  728. }   /* end car_AddHornBeepPage() */
  729.  
  730. /*
  731.  *
  732.  *  OVERRIDE: wpInitData                                   ( ) PRIVATE
  733.  *                                                         (X) PUBLIC
  734.  *  DESCRIPTION:
  735.  *
  736.  *    Initialize our state variables. Allocate any extra memory that
  737.  *    we might need.
  738.  *
  739.  */
  740.  
  741. SOM_Scope void SOMLINK car_wpInitData(Car *somSelf)
  742. {
  743.     CarData *somThis = CarGetData(somSelf);
  744.     CarMethodDebug("Car","car_wpInitData");
  745.  
  746.     /*
  747.      *   We can initialize our instance data to 0's by using the somThis
  748.      *   pointer and the size of the CarData structure created by SOM.
  749.      *
  750.      *   SOM stores instance data in a data structure named by prefixing
  751.      *   the name "Data" with the class name, in this case, "Car".
  752.      */
  753.  
  754.     memset((PVOID)somThis, 0, sizeof(CarData));
  755.  
  756.     /*
  757.      *   And/or we can explicitly initialize our instance variables.
  758.      */
  759.  
  760.     _HighTone  = DEFAULT_HITONE;
  761.     _LowTone   = DEFAULT_LOTONE;
  762.     _duration  = DEFAULT_DURATION;
  763.     _speed     = DEFAULT_SPEED;
  764.     _BrakeFlag = DEFAULT_BRAKEFLAG;
  765.  
  766.     parent_wpInitData(somSelf);
  767.  
  768. }   /* end car_wpInitData() */
  769.  
  770. /*
  771.  *
  772.  *  OVERRIDE: wpUnInitData                                 ( ) PRIVATE
  773.  *                                                         (X) PUBLIC
  774.  *  DESCRIPTION:
  775.  *
  776.  *    Clear up memory that was allocated on wpInitData.
  777.  *
  778.  */
  779.  
  780. SOM_Scope void   SOMLINK car_wpUnInitData(Car *somSelf)
  781. {
  782.     CarData *somThis = CarGetData(somSelf);
  783.     CarMethodDebug("Car","car_wpUnInitData");
  784.  
  785.     parent_wpUnInitData(somSelf);
  786.  
  787. }   /* end car_wpUnInitData() */
  788.  
  789.  
  790. /*
  791.  *
  792.  *  METHOD: wpSaveState                                    ( ) PRIVATE
  793.  *                                                         (X) PUBLIC
  794.  *  DESCRIPTION:
  795.  *
  796.  *    Save our state variables (pitch and duration).
  797.  *
  798.  */
  799.  
  800. SOM_Scope BOOL SOMLINK car_wpSaveState(Car *somSelf)
  801. {
  802.     CarData *somThis = CarGetData(somSelf);
  803.     CarMethodDebug("Car","car_wpSaveState");
  804.  
  805.     _wpSaveLong( somSelf, szCarClassTitle, IDKEY_HITONE,          _HighTone  );
  806.     _wpSaveLong( somSelf, szCarClassTitle, IDKEY_LOTONE,          _LowTone   );
  807.     _wpSaveLong( somSelf, szCarClassTitle, IDKEY_DURATION,        _duration  );
  808.     _wpSaveLong( somSelf, szCarClassTitle, IDKEY_SPEED,           _speed     );
  809.     _wpSaveLong( somSelf, szCarClassTitle, IDKEY_BRAKEFLAG, (LONG)_BrakeFlag );
  810.  
  811.     return (parent_wpSaveState(somSelf));
  812.  
  813. }   /* end car_wpSaveState() */
  814.  
  815. /*
  816.  *
  817.  *  METHOD: wpRestoreState                                 ( ) PRIVATE
  818.  *                                                         (X) PUBLIC
  819.  *  DESCRIPTION:
  820.  *
  821.  *    Retrieve our saved state variables (pitch and duration).
  822.  *
  823.  */
  824.  
  825. SOM_Scope BOOL SOMLINK car_wpRestoreState(Car *somSelf, ULONG ulReserved)
  826. {
  827.     CarData *somThis = CarGetData(somSelf);
  828.     CarMethodDebug("Car","car_wpRestoreState");
  829.  
  830.     _wpRestoreLong( somSelf, szCarClassTitle, IDKEY_HITONE,    &_HighTone  );
  831.     _wpRestoreLong( somSelf, szCarClassTitle, IDKEY_LOTONE,    &_LowTone   );
  832.     _wpRestoreLong( somSelf, szCarClassTitle, IDKEY_DURATION,  &_duration  );
  833.     _wpRestoreLong( somSelf, szCarClassTitle, IDKEY_SPEED,     &_speed     );
  834.     _wpRestoreLong( somSelf, szCarClassTitle, IDKEY_BRAKEFLAG, &_BrakeFlag );
  835.  
  836.     return (parent_wpRestoreState(somSelf,ulReserved));
  837.  
  838. }   /* car_wpRestoreState() */
  839.  
  840. /*
  841.  *
  842.  *  METHOD: wpAddSettingsPages                             ( ) PRIVATE
  843.  *                                                         (X) PUBLIC
  844.  *  DESCRIPTION:
  845.  *
  846.  *    Add our own settings page to let the user alter the pitch
  847.  *    and duration of the car's beep.
  848.  *
  849.  */
  850.  
  851. SOM_Scope BOOL SOMLINK car_wpAddSettingsPages(Car *somSelf, HWND hwndNotebook)
  852. {
  853.     CarData *somThis = CarGetData(somSelf);
  854.     CarMethodDebug("Car","car_wpAddSettingsPages");
  855.  
  856.     if (parent_wpAddSettingsPages(somSelf, hwndNotebook)
  857.              && _AddHornBeepPage( somSelf, hwndNotebook)
  858.              && _AddDashboardPage(somSelf, hwndNotebook))
  859.     {
  860.         return(TRUE);
  861.     }
  862.     else
  863.     {
  864.         DebugBox("car_wpAddSettingsPages", " Failed to add a settings page.");
  865.         return( FALSE );
  866.     }
  867.  
  868. }   /* car_wpAddSettingsPages() */
  869.  
  870. /*
  871.  *
  872.  *  METHOD: wpFilterPopupMenu                              ( ) PRIVATE
  873.  *                                                         (X) PUBLIC
  874.  *  DESCRIPTION:
  875.  *
  876.  *    Filter out any options from the context that don't apply.
  877.  *
  878.  *  HOW TO OVERRIDE:
  879.  *
  880.  *    No restrictions.
  881.  *
  882.  */
  883.  
  884. SOM_Scope ULONG SOMLINK car_wpFilterPopupMenu(Car *somSelf,
  885.                 ULONG ulFlags,
  886.                 HWND hwndCnr,
  887.                 BOOL fMultiSelect)
  888. {
  889.     CarData *somThis = CarGetData(somSelf);
  890.     CarMethodDebug("Car","car_wpFilterPopupMenu");
  891.  
  892.     /*
  893.      *   This method allows you to filter which menus to include in the
  894.      *   popup menu.  Note: wpclsQueryStyle is overridden to disallow
  895.      *   linking (creating shadow) as well.
  896.      */
  897.     return( parent_wpFilterPopupMenu(somSelf,ulFlags,hwndCnr,
  898.                     fMultiSelect) & ~CTXT_LINK );
  899.  
  900. }   /* end car_wpFilterPopupMenu() */
  901.  
  902. /*
  903.  *
  904.  *  METHOD: wpModifyPopupMenu                              ( ) PRIVATE
  905.  *                                                         (X) PUBLIC
  906.  *  DESCRIPTION:
  907.  *
  908.  *    Add our extra option to the context menu to beep the horn
  909.  *
  910.  */
  911.  
  912. SOM_Scope BOOL SOMLINK car_wpModifyPopupMenu(Car *somSelf,
  913.                 HWND hwndMenu,
  914.                 HWND hwndCnr,
  915.                 ULONG iPosition)
  916. {
  917.     CarData *somThis = CarGetData(somSelf);
  918.     CarMethodDebug("Car","car_wpModifyPopupMenu");
  919.  
  920.     /*
  921.      *   Put in our special "open car" submenu item under the "open" menu
  922.      */
  923.     _wpInsertPopupMenuItems( somSelf, hwndMenu, 0,
  924.                                hmod, ID_OPENMENU, WPMENUID_OPEN);
  925.     /*
  926.      *   insert a "beep horn" menu item at the end of the list.
  927.      */
  928.     _wpInsertPopupMenuItems( somSelf, hwndMenu, iPosition,
  929.                                hmod, ID_BEEPMENU, 0 );
  930.  
  931.     /*
  932.      *   insert a "TRAP-D" menu item at the end of the list.
  933.      */
  934.     _wpInsertPopupMenuItems( somSelf, hwndMenu, 0,
  935.                                hmod, ID_TRAPMENU, 0 );
  936.  
  937.     return (parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition));
  938.  
  939. }   /* end car_wpModifyPopupMenu() */
  940.  
  941. /*
  942.  *
  943.  *  METHOD: wpMenuItemSelected                             ( ) PRIVATE
  944.  *                                                         (X) PUBLIC
  945.  *  DESCRIPTION:
  946.  *
  947.  *    Process input from the extra menu option that we added.
  948.  *
  949.  */
  950.  
  951. SOM_Scope BOOL SOMLINK car_wpMenuItemSelected(Car *somSelf,
  952.                 HWND hwndFrame,
  953.                 ULONG MenuId)
  954. {
  955.     CarData *somThis = CarGetData(somSelf);
  956.     CarMethodDebug("Car","car_wpMenuItemSelected");
  957.  
  958.     /* Which of our menu items was selected ?
  959.      */
  960.     switch( MenuId )
  961.     {
  962.        case IDM_OPENCAR:
  963.           /*
  964.            *   We could call wpOpen here, but, if the object is already opened,
  965.            *   the following API determines whether the object should be
  966.            *   resurfaced, or if multiple views are desired.
  967.            */
  968.           _wpViewObject(somSelf, NULLHANDLE, OPEN_CAR, 0);
  969.           break;
  970.  
  971.        case IDM_BEEPHORN:
  972.           _BeepHorn(somSelf);
  973.           break;
  974.  
  975.        case IDM_TRAPCAR:
  976.           _TrapTest(somSelf);
  977.           break;
  978.  
  979.        default:
  980.           return parent_wpMenuItemSelected(somSelf, hwndFrame, MenuId);
  981.           break;
  982.     }
  983.     return TRUE;                                          /* we processed it */
  984.  
  985. }   /* end car_wpMenuItemSelected() */
  986.  
  987. /*
  988.  *
  989.  *  METHOD: wpMenuItemHelpSelected                         ( ) PRIVATE
  990.  *                                                         (X) PUBLIC
  991.  *  DESCRIPTION:
  992.  *
  993.  *    Process input from the extra menu option that we added.
  994.  *
  995.  */
  996. SOM_Scope BOOL SOMLINK car_wpMenuItemHelpSelected(Car *somSelf,
  997.                 ULONG MenuId)
  998. {
  999.     CarData *somThis = CarGetData(somSelf);
  1000.     CarMethodDebug("Car","car_wpMenuItemHelpSelected");
  1001.  
  1002.     /* Which of our menu items was selected ?
  1003.      */
  1004.    switch( MenuId )
  1005.    {
  1006.       case IDM_BEEPHORN:
  1007.  
  1008.          return(_wpDisplayHelp(somSelf,ID_HELP_BEEPHORN,szHelpLibrary));
  1009.          break;
  1010.  
  1011.   /*  case ID_OPENCAR:    no help written at this time
  1012.    *
  1013.    *     return(_wpDisplayHelp(somSelf,ID_HELP_OPENCAR,szHelpLibrary));
  1014.    *     break;
  1015.    */
  1016.       default:
  1017.          break;
  1018.    }
  1019.  
  1020.    return FALSE;
  1021.  
  1022. }   /* end car_wpMenuItemHelpSelected() */
  1023.  
  1024. /*
  1025.  *
  1026.  *  METHOD: wpQueryDetailsData                             ( ) PRIVATE
  1027.  *                                                         (X) PUBLIC
  1028.  *  DESCRIPTION:
  1029.  *
  1030.  *    Returns the car specific data for the details view of this object.
  1031.  *    Sets the pointer (*ppDetailsData) to the beginning of the buffer
  1032.  *    into which the data is written.
  1033.  *
  1034.  */
  1035. SOM_Scope ULONG SOMLINK car_wpQueryDetailsData(Car *somSelf,
  1036.                 PVOID *ppDetailsData,
  1037.                 PULONG pcp)
  1038. {
  1039.    PCARDETAILS pCarDetails;
  1040.    PBYTE       pSize;
  1041.     CarData *somThis = CarGetData(somSelf);
  1042.     CarMethodDebug("Car","car_wpQueryDetailsData");
  1043.  
  1044.    parent_wpQueryDetailsData(somSelf,ppDetailsData, pcp);
  1045.  
  1046.    if (ppDetailsData)                                          /* query data */
  1047.    {
  1048.       pCarDetails                  = (PCARDETAILS) *ppDetailsData;
  1049.       pCarDetails->pszMake         = "Toyota";               /* Manufacturer */
  1050.       pCarDetails->pszModel        = "Camry";                  /* Model name */
  1051.       pCarDetails->pszColor        = "BLUE";             /* Color of the car */
  1052.       pCarDetails->cdateSale.day   = 24;                     /* Date of sale */
  1053.       pCarDetails->cdateSale.month = 12;
  1054.       pCarDetails->cdateSale.year  = 91;
  1055.       pCarDetails->ulPrice         = 14000;              /* Price in dollars */
  1056.  
  1057.       /* point to buffer location after our details data */
  1058.       *ppDetailsData = ((PBYTE) (*ppDetailsData)) + sizeof(*pCarDetails);
  1059.  
  1060.    }   /* end if (ppDetailsData) */
  1061.    else                                                /* query size of data */
  1062.    {
  1063.       *pcp += sizeof(*pCarDetails);     /* caller is querying size of buffer */
  1064.    }
  1065.  
  1066.    return(TRUE);
  1067.  
  1068. }   /* end car_wpQueryDetailsData() */
  1069.  
  1070. /*
  1071.  *
  1072.  *   METHOD: wpOpen                                         ( ) PRIVATE
  1073.  *                                                          (X) PUBLIC
  1074.  *   DESCRIPTION:
  1075.  *
  1076.  *     Opens the car window.
  1077.  *
  1078.  */
  1079. SOM_Scope HWND SOMLINK car_wpOpen(Car *somSelf,
  1080.                 HWND hwndCnr,
  1081.                 ULONG ulView,
  1082.                 ULONG param)
  1083. {
  1084.  CarData *somThis = CarGetData(somSelf);
  1085.  CarMethodDebug("Car","car_wpOpen");
  1086.  
  1087.    switch (ulView)
  1088.    {
  1089.       case OPEN_CAR:
  1090.  
  1091.          if (!_wpSwitchTo(somSelf, ulView))
  1092.          {
  1093.             /*
  1094.              *   Create a basic Frame and Client window for this instance.
  1095.              */
  1096.            return CarInit(somSelf);
  1097.          }
  1098.          break;
  1099.  
  1100.       default:
  1101.          return parent_wpOpen(somSelf,hwndCnr,ulView,param);
  1102.          break;
  1103.  
  1104.    }   /* end switch (ulView) */
  1105.  
  1106. }   /* end car_wpOpen() */
  1107.  
  1108.  
  1109. /*
  1110.  *
  1111.  *  METHOD: wpSetup                                        ( ) PRIVATE
  1112.  *                                                         (X) PUBLIC
  1113.  *  DESCRIPTION:
  1114.  *
  1115.  *    Specify Setup strings and do some initialization.  This method is
  1116.  *    invoked once an object is completely created.
  1117.  *
  1118.  *  Note:  We're overriding this method to write some default data to the
  1119.  *         object's real filename.  This will give us something to look at
  1120.  *         if the user drag/drops us on an editor or selects the open/editor
  1121.  *         view.
  1122.  */
  1123. SOM_Scope BOOL   SOMLINK car_wpSetup(Car *somSelf,
  1124.                 PSZ pszSetupString)
  1125. {
  1126.  ULONG cbBytesWritten;           /* pointer to variable receiving byte count */
  1127.  APIRET rc;
  1128.  BOOL fSuccess;
  1129.  HFILE hf;                            /* pointer to variable for file handle */
  1130.  ULONG ulAction;                     /* pointer to variable for action taken */
  1131.  CHAR szObjectFilename[CCHMAXPATH];          /* buffer for wpQueryRealName() */
  1132.  ULONG cb  = sizeof(szObjectFilename);
  1133.  
  1134.  
  1135.     CarData *somThis = CarGetData(somSelf);
  1136.     CarMethodDebug("Car","car_wpSetup");
  1137.  
  1138.    /*
  1139.     *   Write an initial bill-of-sale to the object data file
  1140.     */
  1141.  
  1142.    fSuccess =
  1143.    _wpQueryRealName(                 /* query full-pathname of object's file */
  1144.       somSelf,                                     /* pointer to this object */
  1145.       szObjectFilename,                                     /* return buffer */
  1146.       &cb,                                                  /* sizeof buffer */
  1147.       TRUE);                            /* request fully qualified pathname? */
  1148.  
  1149.    if (fSuccess)
  1150.    {
  1151.       rc =
  1152.       DosOpen(szObjectFilename, &hf, &ulAction,
  1153.          0,                             /* file size if created or truncated */
  1154.          FILE_NORMAL,                                      /* file attribute */
  1155.          FILE_OPEN             /* action taken if file exists/does not exist */
  1156.             | FILE_CREATE,
  1157.          OPEN_ACCESS_READWRITE                          /* open mode of file */
  1158.             | OPEN_SHARE_DENYNONE,
  1159.          NULL);              /* pointer to structure for extended attributes */
  1160.  
  1161.       if (rc)
  1162.       {
  1163.        CHAR ach[10];
  1164.  
  1165.          _ltoa(rc, ach, 10);
  1166.          DebugBox("car_wpSetup:DosOpen failed rc =", ach);
  1167.       }
  1168.       else
  1169.       {
  1170.          DosWrite(hf, pszDefaultText, strlen(pszDefaultText), &cbBytesWritten);
  1171.          DosClose(hf);
  1172.       }
  1173.    }   /* end if (fSuccess) */
  1174.  
  1175.    return (parent_wpSetup(somSelf,pszSetupString));
  1176.  
  1177. }   /* end car_wpSetup() */
  1178.  
  1179. /*
  1180.  *
  1181.  *  METHOD: TrapTest                                        ( ) PRIVATE
  1182.  *                                                         (X) PUBLIC
  1183.  *  DESCRIPTION:
  1184.  *
  1185.  *    Specify Setup strings and do some initialization.  This method is
  1186.  *    invoked once an object is completely created.
  1187.  *
  1188.  *  Note:  The variable used to communicate the current state to the
  1189.  *         exception handler is global.  If an exception occurs in more than
  1190.  *         one instance of this object at the same time, the results will
  1191.  *         be unpredictable.
  1192.  */
  1193.  
  1194. #pragma handler (car_TrapTest)
  1195.  
  1196. /*
  1197.  * METHOD: AddHornBeepPage                                ( ) PRIVATE
  1198.  *                                                        (X) PUBLIC
  1199.  * DESCRIPTION:
  1200.  *
  1201.  *   This method tests the exception handling in this sample.
  1202.  *
  1203.  * RETURN:
  1204.  *
  1205.  *   nothing
  1206.  *
  1207.  * HOW TO OVERRIDE:
  1208.  *
  1209.  *   n/a
  1210.  *
  1211.  *
  1212.  *   Methods from the WPObject class
  1213.  */
  1214.  
  1215.  
  1216. /*
  1217.  * SOM_Scope VOID  SOMLINK car_TrapTest(Car *somSelf)
  1218.  */
  1219.  
  1220. /*
  1221.  * The prototype for car_TrapTest was replaced by the following prototype:
  1222.  */
  1223. SOM_Scope void  SOMLINK car_TrapTest(Car *somSelf)
  1224. {
  1225.   PSZ      pszTrap = NULL;
  1226.   jmp_buf  saveState;
  1227.   CarData *somThis = CarGetData(somSelf);
  1228.   CarMethodDebug("Car","car_TrapTest");
  1229.  
  1230.    memcpy(saveState, jmpState, sizeof(jmpState));
  1231.    if (!setjmp(jmpState))   /* no exception?*/
  1232.    {
  1233.       /*
  1234.        *   Normal code for this method goes here
  1235.        */
  1236.  
  1237.       *pszTrap = 'a';
  1238.    }
  1239.    else   /* we just returned from exception handler */
  1240.    {
  1241.       /*
  1242.        *   An exception just occurred in this method.  We should put any
  1243.        *   cleanup/recovery code in this code block and then return the
  1244.        *   error to the caller.
  1245.        */
  1246.  
  1247.       WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, pszTrapMessage,
  1248.                       "Exception Handler Test",
  1249.                       999, MB_MOVEABLE | MB_OK | MB_ERROR);
  1250.    }
  1251.  
  1252.    memcpy(jmpState, saveState, sizeof(jmpState));
  1253.  
  1254. }   /* end car_TrapTest() */
  1255.  
  1256. /**************************  CLASS METHODS SECTION  ***************************
  1257. *****                                                                     *****
  1258. *****              Do not put any code in this section unless             *****
  1259. *****                     it is an object CLASS method                    *****
  1260. *****                                                                     *****
  1261. ******************************************************************************/
  1262. #undef SOM_CurrentClass
  1263. #define SOM_CurrentClass SOMMeta
  1264.  
  1265.  
  1266. /*
  1267.  *
  1268.  *  METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  1269.  *                                                         (X) PUBLIC
  1270.  *  DESCRIPTION:
  1271.  *
  1272.  *    This method returns the module handle of this class.  If this is the
  1273.  *    first invocation, DosQueryModuleHandle is called to save the handle
  1274.  *    for future invocations.
  1275.  *
  1276.  *  RETURN:
  1277.  *
  1278.  *    0              Unsuccessful
  1279.  *    non-zero       module handle
  1280.  *
  1281.  */
  1282.  
  1283.  
  1284. /*
  1285.  * METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  1286.  *                                                        (X) PUBLIC
  1287.  * DESCRIPTION:
  1288.  *
  1289.  *   This method returns the module handle of this class.  If this is the
  1290.  *   first invocation, DosQueryModuleHandle is called to save the handle
  1291.  *   for future invocations.
  1292.  *
  1293.  * RETURN:
  1294.  *
  1295.  *   0              Unsuccessful
  1296.  *   non-zero       module handle
  1297.  */
  1298.  
  1299. SOM_Scope HMODULE   SOMLINK carM_clsQueryModuleHandle(M_Car *somSelf)
  1300. {
  1301.  APIRET rc;
  1302.  
  1303.     /* M_CarData *somThis = M_CarGetData(somSelf); */
  1304.     M_CarMethodDebug("M_Car","carM_clsQueryModuleHandle");
  1305.  
  1306.    /*
  1307.     *   Make sure we already have module handle
  1308.     */
  1309.  
  1310.     if (hmod == NULLHANDLE)
  1311.     {
  1312.      zString zsPathName;
  1313.      somId id;
  1314.        /*
  1315.         *   Retrieve registered pathname of our module (DLL) and query the
  1316.         *   module handle.
  1317.         */
  1318.        id = SOM_IdFromString("Car");
  1319.        zsPathName =
  1320.        _somLocateClassFile( SOMClassMgrObject, id ,
  1321.                             Car_MajorVersion, Car_MinorVersion);
  1322.        /* Free the som id because we don't need it anymore. */
  1323.        SOMFree( (VOID*)id);
  1324.  
  1325.        rc =
  1326.        DosQueryModuleHandle( zsPathName, &hmod);
  1327.        if (rc)
  1328.        {
  1329.           DebugBox("carM_wpclsInitData", "Failed to load module");
  1330.           return;
  1331.        }
  1332.  
  1333.     }   /* end if (hmod == NULLHANDLE) */
  1334.  
  1335.     return (hmod);
  1336.  
  1337. }   /* end carM_clsQueryModuleHandle() */
  1338.  
  1339. /*
  1340.  *
  1341.  *  METHOD: wpclsQueryStyle                                ( ) PRIVATE
  1342.  *                                                         (X) PUBLIC
  1343.  *  DESCRIPTION:
  1344.  *
  1345.  *     The wpclsQueryStyle method is called to allow the class object
  1346.  *     to specify the default object class style for its instances.
  1347.  *
  1348.  *  REMARKS:
  1349.  *
  1350.  *     This method can be called at any time in order to determine the
  1351.  *     default style for instances of this class.
  1352.  *
  1353.  *     This method should be overridden in order to modify the default
  1354.  *     object style for instances of this class.
  1355.  *
  1356.  */
  1357.  
  1358. SOM_Scope ULONG   SOMLINK carM_wpclsQueryStyle(M_Car *somSelf)
  1359. {
  1360.     /* M_CarData *somThis = M_CarGetData(somSelf); */
  1361.     M_CarMethodDebug("M_Car","carM_wpclsQueryStyle");
  1362.  
  1363.     /*
  1364.      *   Modify style bits as described in programming reference.  This
  1365.      *   particular style (link) is also disabled in wpFilterPopupMenu()
  1366.      */
  1367.     return (parent_wpclsQueryStyle(somSelf) | CLSSTYLE_NEVERLINK);
  1368. }
  1369.  
  1370. /*
  1371.  *
  1372.  *  METHOD: wpclsInitData                                  ( ) PRIVATE
  1373.  *                                                         (X) PUBLIC
  1374.  *  DESCRIPTION:
  1375.  *
  1376.  *    Initalize the class data
  1377.  *
  1378.  */
  1379.  
  1380. SOM_Scope void SOMLINK carM_wpclsInitData(M_Car *somSelf)
  1381. {
  1382.  ULONG rc, i;
  1383.  PCLASSFIELDINFO pCFI;
  1384.  
  1385.     /* M_CarData *somThis  = M_CarGetData(somSelf); */
  1386.     M_CarMethodDebug("M_Car","carM_wpclsInitData");
  1387.  
  1388.     /*
  1389.      *   Call the parent class method first
  1390.      */
  1391.     parent_wpclsInitData(somSelf);
  1392.  
  1393.     /*
  1394.      *   Get class title
  1395.      */
  1396.     if (!WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle(somSelf), ID_TITLE,
  1397.                          sizeof(szCarClassTitle), szCarClassTitle))
  1398.                               /* Load string failed: use the parent's string */
  1399.        strcpy(szCarClassTitle, parent_wpclsQueryTitle(somSelf));
  1400.  
  1401.    /*
  1402.     *   Initialize everything needed for the CLASSFIELDINFO structures
  1403.     *   for the Car object class
  1404.     */
  1405.  
  1406.    for (i=0, pCFI=fieldinfo; i < NUM_CAR_FIELDS; i++, pCFI++)
  1407.    {
  1408.       memset((PCH) pCFI, 0, sizeof(CLASSFIELDINFO));               /* zero's */
  1409.  
  1410.       pCFI->cb        = sizeof(CLASSFIELDINFO);
  1411.       pCFI->flData    = CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
  1412.       pCFI->flTitle   = CFA_CENTER | CFA_SEPARATOR | CFA_HORZSEPARATOR |
  1413.                         CFA_STRING | CFA_FITITLEREADONLY;
  1414.       pCFI->pNextFieldInfo = pCFI + 1;       /* point to next CLASSFIELDINFO */
  1415.       pCFI->pTitleData = (PVOID) apszCarColTitles[i];
  1416.       pCFI->flCompare  = COMPARE_SUPPORTED | SORTBY_SUPPORTED;
  1417.  
  1418.       switch (i)
  1419.       {
  1420.          case INDEX_MAKE:
  1421.  
  1422.             pCFI->flData           |= CFA_STRING;
  1423.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(CARDETAILS,pszMake));
  1424.             pCFI->ulLenFieldData    = sizeof(PSZ);
  1425.             pCFI->DefaultComparison = CMP_EQUAL;
  1426.  
  1427.             break;
  1428.  
  1429.          case INDEX_MODEL:
  1430.  
  1431.             pCFI->flData           |= CFA_STRING;
  1432.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(CARDETAILS,pszModel));
  1433.             pCFI->ulLenFieldData    = sizeof(PSZ);
  1434.             pCFI->DefaultComparison = CMP_EQUAL;
  1435.  
  1436.             break;
  1437.  
  1438.          case INDEX_COLOR:
  1439.  
  1440.             pCFI->flData           |= CFA_STRING;
  1441.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(CARDETAILS,pszColor));
  1442.             pCFI->ulLenFieldData    = sizeof(PSZ);
  1443.             pCFI->DefaultComparison = CMP_EQUAL;
  1444.  
  1445.             break;
  1446.  
  1447.          case INDEX_SALE_DATE:
  1448.  
  1449.             pCFI->flData           |= CFA_DATE;
  1450.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(CARDETAILS,cdateSale));
  1451.             pCFI->ulLenFieldData    = sizeof(CDATE);
  1452.             pCFI->ulLenCompareValue = sizeof(CDATE);
  1453.             pCFI->DefaultComparison = CMP_GREATER;
  1454.  
  1455.             break;
  1456.  
  1457.          case INDEX_PRICE:
  1458.  
  1459.             pCFI->flData           |= CFA_ULONG;
  1460.             pCFI->offFieldData      = (ULONG)(FIELDOFFSET(CARDETAILS,ulPrice));
  1461.             pCFI->ulLenFieldData    = sizeof(ULONG);
  1462.             pCFI->ulLenCompareValue = sizeof(ULONG);
  1463.             pCFI->DefaultComparison = CMP_GREATER;
  1464.  
  1465.             break;
  1466.  
  1467.       }   /* end switch(i) */
  1468.  
  1469.    }   /* end for (i=0, pCFI=fieldinfo; i < NUM_CAR_FIELDS; i++, pCFI++)  */
  1470.  
  1471.    fieldinfo[NUM_CAR_FIELDS-1].pNextFieldInfo = NULL;/* terminate linked list */
  1472.  
  1473. }   /* end carM_ wpclsInitData() */
  1474.  
  1475. /*
  1476.  *
  1477.  *  METHOD: wpclsUnInitData                                ( ) PRIVATE
  1478.  *                                                         (X) PUBLIC
  1479.  *  DESCRIPTION:
  1480.  *
  1481.  *    Free any class data
  1482.  *
  1483.  */
  1484.  
  1485. SOM_Scope void SOMLINK carM_wpclsUnInitData(M_Car *somSelf)
  1486. {
  1487.     M_CarMethodDebug("M_Car","carM_wpclsUnInitData");
  1488.  
  1489.     parent_wpclsUnInitData(somSelf);
  1490.  
  1491. }   /* end carM_wpclsUnInitData() */
  1492.  
  1493. /*
  1494.  *
  1495.  *  METHOD: wpclsQueryTitle                                ( ) PRIVATE
  1496.  *                                                         (X) PUBLIC
  1497.  *  DESCRIPTION:
  1498.  *
  1499.  *    Return the string "New car".
  1500.  *
  1501.  */
  1502.  
  1503. SOM_Scope PSZ SOMLINK carM_wpclsQueryTitle(M_Car *somSelf)
  1504. {
  1505.                               /* M_CarData *somThis = M_CarGetData(somSelf); */
  1506.     M_CarMethodDebug("M_Car","carM_wpclsQueryTitle");
  1507.  
  1508.     /*
  1509.      *   Return the class title for a car
  1510.      */
  1511.  
  1512.     if (*szCarClassTitle )
  1513.        return( szCarClassTitle );
  1514.     else
  1515.        return( parent_wpclsQueryTitle(somSelf));
  1516.  
  1517. }   /* end carM_wpclsQueryTitle() */
  1518.  
  1519. /*
  1520.  *
  1521.  *  METHOD: wpclsQueryIconDdata                            ( ) PRIVATE
  1522.  *                                                         (X) PUBLIC
  1523.  *  DESCRIPTION:
  1524.  *
  1525.  *    Return the class icon
  1526.  *
  1527.  */
  1528.  
  1529. SOM_Scope ULONG SOMLINK carM_wpclsQueryIconData(M_Car *somSelf,
  1530.                   PICONINFO pIconInfo)
  1531. {
  1532.    APIRET rc;
  1533.  
  1534.    M_CarMethodDebug("M_Car","carM_wpclsQueryIconData");
  1535.  
  1536.    if (pIconInfo)
  1537.    {
  1538.       /*
  1539.        *   fill in icon information
  1540.        */
  1541.       pIconInfo->fFormat = ICON_RESOURCE;
  1542.       pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  1543.       pIconInfo->resid= ID_ICON;
  1544.    }
  1545.  
  1546.    return (sizeof(ICONINFO));
  1547.  
  1548. }   /* end carM_wpclsQueryIconData() */
  1549.  
  1550. /*
  1551.  *
  1552.  *  METHOD: wpclsQueryDefaultHelp                          ( ) PRIVATE
  1553.  *                                                         (X) PUBLIC
  1554.  *  DESCRIPTION:
  1555.  *
  1556.  *    Process input from the extra menu option that we added.
  1557.  *
  1558.  */
  1559.  
  1560. SOM_Scope BOOL SOMLINK carM_wpclsQueryDefaultHelp(M_Car *somSelf,
  1561.                 PULONG pHelpPanelId,
  1562.                 PSZ pszHelpLibrary)
  1563. {
  1564.                               /* M_CarData *somThis = M_CarGetData(somSelf); */
  1565.     M_CarMethodDebug("M_Car","carM_wpclsQueryDefaultHelp");
  1566.  
  1567.     if (pHelpPanelId)                           /* set default help panel id */
  1568.        *pHelpPanelId   = ID_HELP_DEFAULT;
  1569.  
  1570.     if (pszHelpLibrary)                                /* copy help filename */
  1571.        strcpy(pszHelpLibrary, szHelpLibrary);
  1572.  
  1573.     return (TRUE);
  1574.  
  1575. }   /* end carM_wpclsQueryDefaultHelp() */
  1576.  
  1577. /*
  1578.  *
  1579.  *  METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  1580.  *                                                         (X) PUBLIC
  1581.  *  DESCRIPTION:
  1582.  *
  1583.  *    Returns the default view for a new instance of this object.
  1584.  *
  1585.  *  REMARKS:
  1586.  *
  1587.  *    Tell the system what our default open view is...
  1588.  *
  1589.  */
  1590.  
  1591. SOM_Scope ULONG SOMLINK carM_wpclsQueryDefaultView(M_Car *somSelf)
  1592. {
  1593.                               /* M_CarData *somThis = M_CarGetData(somSelf); */
  1594.     M_CarMethodDebug("M_Car","carM_wpclsQueryDefaultView");
  1595.  
  1596.    /*  return (ID_OPENCAR); */
  1597.     return (OPEN_CAR);
  1598.  
  1599. }   /* end carM_wpclsQueryDefaultView() */
  1600.  
  1601. /*
  1602.  *
  1603.  *  METHOD: wpclsQueryDetailsInfo                          ( ) PRIVATE
  1604.  *                                                         (X) PUBLIC
  1605.  *  DESCRIPTION:
  1606.  *
  1607.  *    Appends the car specific chain of FIELDINFO structures describing the
  1608.  *    details data of this object to *ppClassFieldInfo (if ppClassFieldInfo
  1609.  *    is NON-NULL).  In this case it also sets *ppClassFieldInfo to the
  1610.  *    head of the linked list.
  1611.  *
  1612.  *    Adds the number of bytes required by the details data for car to *pSize
  1613.  *    (if pSize is NON-NULL).
  1614.  *
  1615.  *  REMARKS:
  1616.  *
  1617.  *    Add details data for this object.
  1618.  *
  1619.  */
  1620.  
  1621. SOM_Scope ULONG SOMLINK carM_wpclsQueryDetailsInfo(M_Car *somSelf,
  1622.                 PCLASSFIELDINFO *ppClassFieldInfo,
  1623.                 PULONG pSize)
  1624. {
  1625.  ULONG           cParentColumns;
  1626.  PCLASSFIELDINFO pCFI;
  1627.  ULONG           i;
  1628.  
  1629.     /* M_CarData *somThis = M_CarGetData(somSelf); */
  1630.     M_CarMethodDebug("M_Car","carM_wpclsQueryDetailsInfo");
  1631.  
  1632.    /*
  1633.     *   Always call the parent method first to retrieve number of details
  1634.     *   columns and parent's data already defined in details buffer.
  1635.     */
  1636.  
  1637.    cParentColumns =
  1638.    parent_wpclsQueryDetailsInfo(somSelf, ppClassFieldInfo, pSize);
  1639.  
  1640.    /*
  1641.     *   If pSize is non-NULL, we must add the size of our deatils column
  1642.     *   data structure.
  1643.     */
  1644.  
  1645.    if (pSize)
  1646.       *pSize += sizeof(CARDETAILS);                           /* adjust size */
  1647.  
  1648.    /*
  1649.     *   If the request was for the chained fieldinfo structures
  1650.     *   (ppClassFieldInfo is non-NULL), link them in
  1651.     *
  1652.     *   eventually the chain will look like
  1653.     *
  1654.     *   Grandad - Dad - Me - Kid - Grandkid
  1655.     *
  1656.     *   I will be getting the pointer to the beginning of the chain
  1657.     *
  1658.     *   If the beginning of the chain is 0, I will assign the address
  1659.     *   of my first CLASSFIELDINFO structure to *ppClassFieldInfo.
  1660.     *   Otherwise *pp points to the first column description in the
  1661.     *   chain.  We need to walk the chain and link our CLASSFIELDINFO
  1662.     *   structures at the end.
  1663.     */
  1664.  
  1665.    if (ppClassFieldInfo)
  1666.    {
  1667.       /*
  1668.        *   Find the last link in the chain;  Then link our CLASSFIELDINFO
  1669.        *   structures to the chain.
  1670.        */
  1671.  
  1672.       if (*ppClassFieldInfo)
  1673.       {
  1674.          pCFI = *ppClassFieldInfo;
  1675.          for (i=0;i<cParentColumns;i++)
  1676.             pCFI = (pCFI->pNextFieldInfo) ? pCFI->pNextFieldInfo : pCFI;
  1677.  
  1678.          pCFI->pNextFieldInfo = fieldinfo;
  1679.       }
  1680.       else
  1681.          *ppClassFieldInfo = fieldinfo;
  1682.    }
  1683.    return ((ULONG) (cParentColumns + NUM_CAR_FIELDS));
  1684.  
  1685. }   /* end carM_wpclsQueryDetailsInfo() */
  1686.  
  1687. /*
  1688.  *
  1689.  *  METHOD: wpclsQueryInstanceFilter                       ( ) PRIVATE
  1690.  *                                                         (X) PUBLIC
  1691.  *  DESCRIPTION:
  1692.  *
  1693.  *     The wpclsQueryInstanceFilter method is called to allow the class
  1694.  *     object to specify the file title filters for instances of its
  1695.  *     class.
  1696.  *
  1697.  *  REMARKS:
  1698.  *
  1699.  *     A pointer to a string containing file title filter(s).  This
  1700.  *     string can contain several file title filters separated by a
  1701.  *     comma.  Example: "*.TXT, *.DOC"
  1702.  *
  1703.  *  Note:  Overriding this method will cause any data file with the extension
  1704.  *         ".CAR" to become a data object of the class "Car."
  1705.  *
  1706.  */
  1707.  
  1708. SOM_Scope PSZ   SOMLINK carM_wpclsQueryInstanceFilter(M_Car *somSelf)
  1709. {
  1710.     /* M_CarData *somThis = M_CarGetData(somSelf); */
  1711.     M_CarMethodDebug("M_Car","carM_wpclsQueryInstanceFilter");
  1712.  
  1713.     return (szCarInstanceFilter);
  1714. }
  1715.  
  1716.  
  1717. /*
  1718.  *
  1719.  *  METHOD: wpclsQueryDetails                              ( ) PRIVATE
  1720.  *                                                         (X) PUBLIC
  1721.  *  DESCRIPTION:
  1722.  *
  1723.  *     Specify default details to display in details view
  1724.  *
  1725.  *  REMARKS:
  1726.  *
  1727.  *     A pointer details structure is modified and returned.
  1728.  *     Note: this is purely virtual at the moment (parent class doesn't
  1729.  *     do anything).
  1730.  */
  1731.  
  1732. SOM_Scope PCLASSDETAILS   SOMLINK carM_wpclsQueryDetails(M_Car *somSelf)
  1733. {
  1734.     /* M_CarData *somThis = M_CarGetData(somSelf); */
  1735.     M_CarMethodDebug("M_Car","carM_wpclsQueryDetails");
  1736.  
  1737.     return (parent_wpclsQueryDetails(somSelf));
  1738. }
  1739.  
  1740.  
  1741. /**************************  ORDINARY CODE SECTION  ***************************
  1742. *****                                                                     *****
  1743. *****                  Any non-method code should go here.                *****
  1744. *****                                                                     *****
  1745. ******************************************************************************/
  1746. #undef SOM_CurrentClass
  1747.  
  1748.  
  1749. /***************************************************************************
  1750. *                                                                          *
  1751. *       ROUTINE:    CarInit ( )                                            *
  1752. *                                                                          *
  1753. *       DESCRIPTION:    Car Initialization                                 *
  1754. *                                                                          *
  1755. *       RETURNS:    Handle of car frame window, NULL if error              *
  1756. *                                                                          *
  1757. ***************************************************************************/
  1758. HWND CarInit (Car* somSelf)
  1759. {
  1760.    HAB  hab;                                       /* PM anchor block handle */
  1761.    HWND hwndFrame = NULLHANDLE;                       /* Frame window handle */
  1762.    HWND hwndClient = NULLHANDLE;
  1763.    PWINDOWDATA pWindowData;
  1764.    BOOL fSuccess;
  1765.    SWCNTRL    swcEntry;                                      /* Switch Entry */
  1766.    FRAMECDATA flFrameCtlData;                              /* Frame Ctl Data */
  1767.  
  1768.    hab = WinQueryAnchorBlock(HWND_DESKTOP);
  1769.    if (!WinRegisterClass( hab , szCarWindowClass, (PFNWP)CarWndProc ,
  1770.                             CS_SIZEREDRAW | CS_SYNCPAINT, sizeof(pWindowData)))
  1771.    {
  1772.       DebugBox("CarInit", "Failure in WinRegisterClass");
  1773.       return NULLHANDLE ;
  1774.    }
  1775.  
  1776.    /*
  1777.     *   Allocate some instance specific data in Window words of Frame window.
  1778.     *   This will ensure our window procedure can use this object's methods
  1779.     *   (our window proc isn't passed a * somSelf pointer).
  1780.     */
  1781.    pWindowData = (PWINDOWDATA) _wpAllocMem(somSelf, sizeof(*pWindowData), NULL);
  1782.  
  1783.    if (!pWindowData)
  1784.    {
  1785.       DebugBox("CarInit", "wpAllocMem failed to allocate pWindowData");
  1786.       return NULLHANDLE;
  1787.    }
  1788.  
  1789.    memset((PVOID) pWindowData, 0, sizeof(*pWindowData));
  1790.    pWindowData->cb = sizeof(*pWindowData);             /* first field = size */
  1791.    pWindowData->somSelf = somSelf;
  1792.  
  1793.    /* Create a frame window
  1794.     */
  1795.    flFrameCtlData.cb            = sizeof( flFrameCtlData );
  1796.    flFrameCtlData.flCreateFlags = FCF_SIZEBORDER | FCF_TITLEBAR | FCF_SYSMENU |
  1797.                                   FCF_MINMAX ;
  1798.    flFrameCtlData.hmodResources = hmod;
  1799.    flFrameCtlData.idResources   = ID_ICON;
  1800.  
  1801.    hwndFrame =                                        /* create frame window */
  1802.    WinCreateWindow(
  1803.       HWND_DESKTOP,               /* parent-window handle                    */
  1804.       WC_FRAME,                   /* pointer to registered class name        */
  1805.       _wpQueryTitle(somSelf),     /* pointer to window text                  */
  1806.       0,                          /* window style                            */
  1807.       0, 0, 0, 0,                 /* position of window                      */
  1808.       NULLHANDLE,                 /* owner-window handle                     */
  1809.       HWND_TOP,                   /* handle to sibling window                */
  1810.       (USHORT) ID_FRAME,          /* window identifier                       */
  1811.       (PVOID) &flFrameCtlData,    /* pointer to buffer                       */
  1812.       NULL);      ;               /* pointer to structure with pres. params. */
  1813.  
  1814.    if (!hwndFrame)
  1815.    {
  1816.       DebugBox("CarInit", "Failure in WinCreateWindow");
  1817.       return NULLHANDLE;
  1818.    }
  1819.    hwndClient =         /* use WinCreateWindow so we can pass pres params */
  1820.    WinCreateWindow(
  1821.       hwndFrame,               /* parent-window handle                    */
  1822.       szCarWindowClass,        /* pointer to registered class name        */
  1823.       NULL,                    /* pointer to window text                  */
  1824.       0,                       /* window style                            */
  1825.       0, 0, 0, 0,              /* position of window                      */
  1826.       hwndFrame,               /* owner-window handle                     */
  1827.       HWND_TOP,                /* handle to sibling window                */
  1828.       (USHORT)FID_CLIENT,      /* window identifier                       */
  1829.       pWindowData,             /* pointer to buffer                       */
  1830.       NULL);                   /* pointer to structure with pres. params. */
  1831.  
  1832.    if (!hwndClient)
  1833.    {
  1834.       WinDestroyWindow(hwndFrame);
  1835.       return NULLHANDLE;
  1836.    }
  1837.  
  1838.    WinSendMsg(hwndFrame,WM_SETICON,MPFROMP(_wpQueryIcon(somSelf)),NULL);
  1839.    WinSetWindowText(WinWindowFromID(hwndFrame,(USHORT)FID_TITLEBAR),
  1840.                                                          _wpQueryTitle(somSelf));
  1841.  
  1842.    /*
  1843.     * Restore the Window Position
  1844.     */
  1845.    fSuccess =
  1846.    WinRestoreWindowPos(
  1847.       szCarClassTitle,                                        /* class title */
  1848.       _wpQueryTitle(somSelf),                                /* object title */
  1849.       hwndFrame);
  1850.  
  1851.    if (!fSuccess)
  1852.    {
  1853.     SWP        swp;
  1854.  
  1855.       /* Get the dimensions and the shell's suggested
  1856.        * location for the window
  1857.        */
  1858.       WinQueryTaskSizePos(hab,0,&swp);
  1859.  
  1860.       /* Set the frame window position
  1861.        */
  1862.       swp.fl               = SWP_SIZE|SWP_MOVE|SWP_RESTORE|SWP_ZORDER;
  1863.       WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx,
  1864.                      swp.cy, swp.fl);
  1865.    }
  1866.  
  1867.    WinShowWindow(hwndFrame,TRUE);
  1868.    WinStartTimer(hab, hwndClient, CAR_TIMER, (ULONG)100);
  1869.  
  1870.    return hwndFrame;                                              /* success */
  1871.  
  1872. }   /* end CarInit() */
  1873.  
  1874.  
  1875. /******************************************************************************
  1876. *
  1877. *   CarWndProc()
  1878. *
  1879. *   DESCRIPTION: Car Window Procedure
  1880. *
  1881. ******************************************************************************/
  1882. MRESULT EXPENTRY CarWndProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
  1883. {
  1884.   ULONG    MenuId;
  1885.   PWINDOWDATA pWindowData;
  1886.   HWND     hwndFrame;
  1887.   CHAR     acBuffer[10];
  1888.   BOOL     fSuccess;
  1889.  
  1890.    hwndFrame = WinQueryWindow(hwnd, QW_PARENT);
  1891.  
  1892.    switch( msg )
  1893.    {
  1894.       case WM_CREATE:
  1895.  
  1896.         pWindowData = (PWINDOWDATA) mp1;
  1897.  
  1898.         if (pWindowData == NULL)
  1899.         {
  1900.            DebugBox("CarWndProc:WM_CREATE", "couldn't get window words");
  1901.            return FALSE;
  1902.         }
  1903.         /*
  1904.          *   Fill in the class view/usage details and window specific data
  1905.          *   for this instance.
  1906.          */
  1907.         pWindowData->UseItem.type    = USAGE_OPENVIEW;
  1908.         pWindowData->ViewItem.view   = OPEN_CAR;
  1909.         pWindowData->ViewItem.handle = hwndFrame;
  1910.         pWindowData->x               = 10;
  1911.         pWindowData->y               = 10;
  1912.         pWindowData->xDir            = CAR_RIGHT;
  1913.         pWindowData->yDir            = CAR_UP;
  1914.  
  1915.         /*
  1916.          *   Set window pointer with object pointer and instance view info.
  1917.          *   Then add view to the in-use list so wpSwitchTo works.
  1918.          */
  1919.         WinSetWindowPtr(hwnd, QWL_USER, pWindowData);
  1920.         _wpAddToObjUseList(pWindowData->somSelf,&pWindowData->UseItem);
  1921.         _wpRegisterView(pWindowData->somSelf, hwndFrame,
  1922.                                              _wpQueryTitle(pWindowData->somSelf));
  1923.         WinSetFocus( HWND_DESKTOP, hwndFrame);
  1924.  
  1925.         break;
  1926.  
  1927.       case WM_COMMAND:
  1928.  
  1929.         break;
  1930.  
  1931.       case WM_TIMER:
  1932.  
  1933.          pWindowData = (PWINDOWDATA) WinQueryWindowPtr(hwnd, QWL_USER);
  1934.  
  1935.          if (pWindowData == NULL)
  1936.          {
  1937.             DebugBox("CarWndProc:WM_TIMER", "couldn't get window words");
  1938.             return FALSE;
  1939.          }
  1940.          else
  1941.          {
  1942.           RECTL  rectl;
  1943.             /*
  1944.              *   If the car's brakes are off, we move the car by modifying it's
  1945.              *   x,y position.  Direction (xDir, yDir) changes when the car's
  1946.              *   position reaches a border of the window.  The distance it
  1947.              *   moves is based on the speed contained in an instance variable.
  1948.              */
  1949.  
  1950.             if (_QueryBrakes(pWindowData->somSelf) == FALSE)
  1951.             {
  1952.                WinQueryWindowRect(hwnd,&rectl);
  1953.  
  1954.                if (pWindowData->x <= 0)                   /* at left border? */
  1955.                   pWindowData->xDir = CAR_RIGHT;              /* mult. by  1 */
  1956.                else
  1957.                   if (pWindowData->x >= rectl.xRight - ICON_WIDTH)
  1958.                      pWindowData->xDir = CAR_LEFT;            /* mult. by -1 */
  1959.  
  1960.                if (pWindowData->y <= 0)                 /* at bottom border? */
  1961.                   pWindowData->yDir = CAR_UP;                 /* mult. by  1 */
  1962.                else
  1963.                   if (pWindowData->y >= rectl.yTop - ICON_HEIGHT)
  1964.                      pWindowData->yDir = CAR_DOWN;            /* mult. by -1 */
  1965.  
  1966.                pWindowData->x +=
  1967.                   pWindowData->xDir * _QuerySpeed(pWindowData->somSelf);
  1968.  
  1969.                pWindowData->y +=
  1970.                   pWindowData->yDir * _QuerySpeed(pWindowData->somSelf);
  1971.  
  1972.                WinInvalidateRect(hwnd, &rectl, TRUE);  /* invalidate car region */
  1973.             }
  1974.          }
  1975.          break;
  1976.  
  1977.       case WM_PAINT:
  1978.          pWindowData = (PWINDOWDATA) WinQueryWindowPtr(hwnd, QWL_USER);
  1979.  
  1980.          if (pWindowData == NULL)
  1981.          {
  1982.             DebugBox("CarWndProc:WM_PAINT", "couldn't get window words");
  1983.             return FALSE;
  1984.          }
  1985.          else
  1986.          {
  1987.           HPS    hps;
  1988.           RECTL  rectl;
  1989.  
  1990.            hps = WinBeginPaint( hwnd, (HPS)NULLHANDLE, &rectl);
  1991.            WinFillRect( hps, &rectl, SYSCLR_WINDOW);
  1992.            WinDrawPointer(hps, pWindowData->x, pWindowData->y,
  1993.                           _wpQueryIcon(pWindowData->somSelf), DP_NORMAL);
  1994.            WinEndPaint( hps );
  1995.          }
  1996.          break;
  1997.  
  1998.       case WM_CLOSE:
  1999.          {
  2000.           HAB hab;
  2001.  
  2002.             hab = WinQueryAnchorBlock(HWND_DESKTOP);
  2003.             WinStopTimer(hab,hwnd,CAR_TIMER);
  2004.  
  2005.             pWindowData = (PWINDOWDATA) WinQueryWindowPtr(hwnd, QWL_USER);
  2006.  
  2007.             if (pWindowData == NULL)
  2008.             {
  2009.                DebugBox("CarWndProc:WM_CLOSE", "couldn't get window words");
  2010.                return FALSE;
  2011.             }
  2012.             fSuccess =
  2013.             WinStoreWindowPos(szCarClassTitle,_wpQueryTitle(pWindowData->somSelf),
  2014.                                                                         hwndFrame);
  2015.             _wpDeleteFromObjUseList(pWindowData->somSelf,&pWindowData->UseItem);
  2016.             _wpFreeMem(pWindowData->somSelf,(PBYTE)pWindowData);
  2017.  
  2018.             WinPostMsg( hwnd, WM_QUIT, 0, 0 );
  2019.             WinDestroyWindow ( hwndFrame ) ;
  2020.          }
  2021.          break;
  2022.  
  2023.       default:
  2024.          return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  2025.    }
  2026.    return FALSE;
  2027.  
  2028. }   /* end CarWndProc() */
  2029.  
  2030. /******************************************************************************
  2031. *
  2032. *   DashBoardDlgProc()
  2033. *
  2034. *   DESCRIPTION: Dialog Procedure for Dashboaard settings page
  2035. *
  2036. ******************************************************************************/
  2037. MRESULT EXPENTRY DashBoardDlgProc(HWND hwndDlg, ULONG msg,
  2038.                                   MPARAM mp1, MPARAM mp2)
  2039. {
  2040.  DASHDLGDATA * pDashDlgData;
  2041.  CHAR          acBuffer[10];
  2042.  
  2043.    switch (msg)
  2044.    {
  2045.       case WM_INITDLG:
  2046.       {
  2047.          USHORT    usCount;
  2048.          SLDCDATA  SliderData;
  2049.          WNDPARAMS wprm;
  2050.  
  2051.          /*
  2052.           *   Store some instance specific data in Window words of this dialog.
  2053.           *   This will ensure our dialog procedure can access this objects
  2054.           *   data (our dialog proc isn't always passed a *somSelf pointer).
  2055.           */
  2056.          pDashDlgData =
  2057.             (PDASHDLGDATA) _wpAllocMem((Car *)mp2, sizeof(*pDashDlgData), NULL);
  2058.          if (pDashDlgData)
  2059.          {
  2060.             memset((PVOID) pDashDlgData, 0, sizeof(*pDashDlgData));
  2061.             pDashDlgData->cb = sizeof(*pDashDlgData);
  2062.             pDashDlgData->somSelf = (Car *) mp2;   /* pointer to this object */
  2063.             pDashDlgData->PrevBrakes = _QueryBrakes(pDashDlgData->somSelf);
  2064.             pDashDlgData->PrevSpeed  = _QuerySpeed(pDashDlgData->somSelf);
  2065.          }
  2066.          else
  2067.          {
  2068.             DebugBox("DashboardDlgProc:WM_INITDLG", "Couldn't allocate window words");
  2069.             break;
  2070.          }
  2071.  
  2072.          WinSetWindowPtr(hwndDlg, QWL_USER, pDashDlgData);
  2073.  
  2074.          SliderData.cbSize = sizeof(SLDCDATA);
  2075.          SliderData.usScale1Increments = 10;
  2076.          SliderData.usScale1Spacing = 20;
  2077.          SliderData.usScale2Increments = 10;
  2078.          SliderData.usScale2Spacing = 20;
  2079.  
  2080.          wprm.fsStatus = WPM_CTLDATA;
  2081.          wprm.cchText = 0;
  2082.          wprm.cbPresParams = 0;
  2083.          wprm.cbCtlData = 0;
  2084.          wprm.pCtlData = &SliderData;
  2085.          WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,
  2086.                           WM_SETWINDOWPARAMS,(MPARAM)&wprm,(MPARAM)NULL ) ;
  2087.  
  2088.          for (usCount = 0; usCount < 10; usCount++ )
  2089.          {
  2090.             WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,
  2091.                 SLM_SETTICKSIZE,MPFROM2SHORT(usCount,5),NULL);
  2092.  
  2093.            _itoa((usCount*10),acBuffer,10);
  2094.             WinSendDlgItemMsg(hwndDlg, ID_SPEEDSLIDER, SLM_SETSCALETEXT,
  2095.                MPFROMSHORT(usCount), MPFROMP(acBuffer));
  2096.          }
  2097.          WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,SLM_SETSLIDERINFO,
  2098.             MPFROM2SHORT(SMA_SLIDERARMDIMENSIONS,NULL),
  2099.             MPFROM2SHORT(20,40));
  2100.  
  2101.          WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,SLM_SETSLIDERINFO,
  2102.             MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE),
  2103.             MPFROMSHORT((SHORT)_QuerySpeed(pDashDlgData->somSelf)/10));
  2104.  
  2105.          WinSetDlgItemText(hwndDlg,ID_SPEEDDATA,
  2106.             _ltoa(_QuerySpeed(pDashDlgData->somSelf),acBuffer,10));
  2107.  
  2108.          if (_QueryBrakes(pDashDlgData->somSelf) == FALSE)
  2109.          {
  2110.             WinSendDlgItemMsg(hwndDlg,ID_GO,BM_SETCHECK,(MPARAM)1L, MPVOID);
  2111.          }
  2112.          else
  2113.          {
  2114.             WinSendDlgItemMsg(hwndDlg,ID_STOP,BM_SETCHECK,(MPARAM)1L, MPVOID);
  2115.          }
  2116.  
  2117.          return (MRESULT) TRUE;
  2118.  
  2119.       }   /* end case WM_INITDLG: */
  2120.  
  2121.       case WM_DESTROY:
  2122.  
  2123.          pDashDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2124.          if (pDashDlgData == NULL)
  2125.          {
  2126.             DebugBox("DashboardDlgProc:WM_DESTROY", "couldn't get window words");
  2127.             break;
  2128.          }
  2129.          _wpFreeMem(pDashDlgData->somSelf,(PBYTE)pDashDlgData);
  2130.          return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  2131.  
  2132.       case WM_COMMAND:
  2133.  
  2134.          pDashDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2135.          if (pDashDlgData == NULL)
  2136.          {
  2137.             DebugBox("DashboardDlgProc:WM_COMMAND", "couldn't get window words");
  2138.             break;
  2139.          }
  2140.  
  2141.          switch (SHORT1FROMMP(mp1))
  2142.          {
  2143.             case ID_UNDO:
  2144.                _SetBrakes(pDashDlgData->somSelf, pDashDlgData->PrevBrakes);
  2145.                _SetSpeed(pDashDlgData->somSelf, pDashDlgData->PrevSpeed);
  2146.  
  2147.                WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,SLM_SETSLIDERINFO,
  2148.                   MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE),
  2149.                   MPFROMSHORT((SHORT)(_QuerySpeed(pDashDlgData->somSelf)/10)));
  2150.  
  2151.                WinSetDlgItemText(hwndDlg,ID_SPEEDDATA,
  2152.                   _ltoa(_QuerySpeed(pDashDlgData->somSelf),acBuffer,10));
  2153.  
  2154.                if (_QueryBrakes(pDashDlgData->somSelf) == FALSE)
  2155.                {
  2156.                   WinSendDlgItemMsg(hwndDlg,ID_GO,BM_SETCHECK,
  2157.                      (MPARAM)1L, MPVOID);
  2158.                }
  2159.                else
  2160.                {
  2161.                   WinSendDlgItemMsg(hwndDlg,ID_STOP,BM_SETCHECK,
  2162.                      (MPARAM)1L, MPVOID);
  2163.                }
  2164.  
  2165.                break;
  2166.  
  2167.             case ID_DEFAULT:
  2168.                /*
  2169.                 *   preserve previous values
  2170.                 */
  2171.                pDashDlgData->PrevBrakes = _QueryBrakes(pDashDlgData->somSelf);
  2172.                pDashDlgData->PrevSpeed  = _QuerySpeed(pDashDlgData->somSelf);
  2173.  
  2174.                _SetBrakes(pDashDlgData->somSelf, DEFAULT_BRAKEFLAG);
  2175.                _SetSpeed(pDashDlgData->somSelf, DEFAULT_SPEED);
  2176.  
  2177.                WinSendDlgItemMsg(hwndDlg,ID_SPEEDSLIDER,SLM_SETSLIDERINFO,
  2178.                   MPFROM2SHORT(SMA_SLIDERARMPOSITION, SMA_INCREMENTVALUE),
  2179.                   MPFROMSHORT((SHORT)(_QuerySpeed(pDashDlgData->somSelf)/10)));
  2180.  
  2181.                WinSetDlgItemText(hwndDlg,ID_SPEEDDATA,
  2182.                   _ltoa(_QuerySpeed(pDashDlgData->somSelf), acBuffer,10));
  2183.  
  2184.                WinSendDlgItemMsg(hwndDlg,ID_GO,BM_SETCHECK,
  2185.                   (MPARAM)1L, MPVOID);
  2186.  
  2187.                break;
  2188.  
  2189.             case ID_HELP:
  2190.  
  2191.                break;
  2192.  
  2193.          }   /* end switch (SHORT1FROMMP(mp1)) */
  2194.  
  2195.          return (MRESULT) TRUE;
  2196.  
  2197.       case WM_CONTROL:
  2198.       {
  2199.          ULONG temp;
  2200.  
  2201.          pDashDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2202.          if (pDashDlgData == NULL)
  2203.          {
  2204.             DebugBox("DashboardDlgProc:WM_CONTROL", "couldn't get window words");
  2205.             break;
  2206.          }
  2207.  
  2208.          switch (SHORT1FROMMP(mp1))
  2209.          {
  2210.             case ID_GO:
  2211.                if ((USHORT) SHORT2FROMMP(mp1) == BN_CLICKED)
  2212.                {
  2213.                   pDashDlgData->PrevBrakes = _QueryBrakes(pDashDlgData->somSelf);
  2214.                   _SetBrakes(pDashDlgData->somSelf, FALSE);
  2215.                }
  2216.                break;
  2217.  
  2218.             case ID_STOP:
  2219.                if ((USHORT) SHORT2FROMMP(mp1) == BN_CLICKED)
  2220.                {
  2221.                   pDashDlgData->PrevBrakes = _QueryBrakes(pDashDlgData->somSelf);
  2222.                   _SetBrakes(pDashDlgData->somSelf, TRUE);
  2223.                }
  2224.                break;
  2225.  
  2226.             case ID_SPEEDSLIDER:
  2227.                if ((USHORT) SHORT2FROMMP(mp1) == SLN_CHANGE)
  2228.                {
  2229.                   pDashDlgData->PrevSpeed  = _QuerySpeed(pDashDlgData->somSelf);
  2230.                   temp = (ULONG) WinSendDlgItemMsg(hwndDlg, ID_SPEEDSLIDER,
  2231.                      SLM_QUERYSLIDERINFO,
  2232.                      MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_INCREMENTVALUE),
  2233.                      NULL);
  2234.                   temp = temp * 10;
  2235.                   WinSetDlgItemText(hwndDlg,ID_SPEEDDATA,
  2236.                                    _ltoa(temp,acBuffer,10));
  2237.                   _SetSpeed(pDashDlgData->somSelf, temp);
  2238.                }
  2239.                break;
  2240.  
  2241.          }   /* end switch (SHORT1FROMMP(mp1)) */
  2242.  
  2243.          return (MRESULT) TRUE;
  2244.          break;
  2245.  
  2246.       }   /* end case WM_CONTROL: */
  2247.  
  2248.    }   /* end switch (msg) */
  2249.  
  2250.    return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  2251.  
  2252. }   /* end DashBoardDlgProc() */
  2253.  
  2254. /******************************************************************************
  2255. *
  2256. *   HornBeepDlgProc()
  2257. *
  2258. *   DESCRIPTION:  Dialog Procedure for Horn Beep settings page
  2259. *
  2260. ******************************************************************************/
  2261. MRESULT EXPENTRY HornBeepDlgProc(HWND hwndDlg, ULONG msg,
  2262.                                   MPARAM mp1, MPARAM mp2)
  2263. {
  2264.  HORNDLGDATA * pHornDlgData;
  2265.  CHAR acBuffer[10];
  2266.  
  2267.    switch (msg)
  2268.    {
  2269.       case WM_INITDLG:
  2270.       {
  2271.          /*
  2272.           *   Store some instance specific data in Window words of this dialog.
  2273.           *   This will ensure our dialog procedure can access this objects
  2274.           *   data (our dialog proc isn't always passed a *somSelf pointer).
  2275.           */
  2276.          pHornDlgData =
  2277.             (PHORNDLGDATA) _wpAllocMem((Car *) mp2, sizeof(*pHornDlgData), NULL);
  2278.          if (pHornDlgData)
  2279.          {
  2280.             memset((PVOID) pHornDlgData, 0, sizeof(*pHornDlgData));
  2281.             pHornDlgData->cb = sizeof(*pHornDlgData);
  2282.             pHornDlgData->somSelf = (Car *) mp2;  /* pointer to this object */
  2283.             pHornDlgData->PrevDuration = _QueryDuration(pHornDlgData->somSelf);
  2284.             pHornDlgData->PrevHighTone = _QueryHighTone(pHornDlgData->somSelf);
  2285.             pHornDlgData->PrevLowTone  = _QueryLowTone(pHornDlgData->somSelf);
  2286.          }
  2287.          else
  2288.          {
  2289.             DebugBox("HornBeepDlgProc", "Couldn't allocate window words");
  2290.             break;
  2291.          }
  2292.  
  2293.          WinSetWindowPtr(hwndDlg, QWL_USER, pHornDlgData);
  2294.  
  2295.          WinSendDlgItemMsg( hwndDlg, ID_HITONE, SPBM_SETLIMITS,
  2296.             MPFROMLONG(1000), MPFROMLONG(0));
  2297.  
  2298.          WinSendDlgItemMsg( hwndDlg, ID_HITONE, SPBM_SETCURRENTVALUE,
  2299.             MPFROMLONG(_QueryHighTone(pHornDlgData->somSelf)), MPFROMLONG(0));
  2300.  
  2301.          WinSendDlgItemMsg( hwndDlg, ID_LOTONE, SPBM_SETLIMITS,
  2302.             MPFROMLONG(1000), MPFROMLONG(0));
  2303.  
  2304.          WinSendDlgItemMsg( hwndDlg, ID_LOTONE, SPBM_SETCURRENTVALUE,
  2305.             MPFROMLONG(_QueryLowTone(pHornDlgData->somSelf)), MPFROMLONG(0));
  2306.  
  2307.          return (MRESULT) TRUE;
  2308.          break;
  2309.  
  2310.       }   /* end case WM_INITDLG: */
  2311.  
  2312.       case WM_DESTROY:
  2313.  
  2314.          pHornDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2315.  
  2316.          if (pHornDlgData == NULL)
  2317.          {
  2318.             DebugBox("HornBeepDlgProc", "Couldn't get window words");
  2319.             break;
  2320.          }
  2321.  
  2322.          _wpFreeMem(pHornDlgData->somSelf,(PBYTE)pHornDlgData);
  2323.          return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  2324.  
  2325.       case WM_COMMAND:
  2326.  
  2327.          pHornDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2328.          if (pHornDlgData == NULL)
  2329.          {
  2330.             DebugBox("HornBeepDlgProc", "Couldn't get window words");
  2331.             break;
  2332.          }
  2333.  
  2334.          switch (SHORT1FROMMP(mp1))
  2335.          {
  2336.             case ID_UNDO:
  2337.  
  2338.                WinSendDlgItemMsg( hwndDlg, ID_HITONE, SPBM_SETCURRENTVALUE,
  2339.                   MPFROMLONG(pHornDlgData->PrevHighTone),
  2340.                   MPFROMLONG(0));
  2341.  
  2342.                WinSendDlgItemMsg( hwndDlg, ID_LOTONE, SPBM_SETCURRENTVALUE,
  2343.                   MPFROMLONG(pHornDlgData->PrevLowTone),
  2344.                   MPFROMLONG(0));
  2345.  
  2346.                break;
  2347.  
  2348.             case ID_DEFAULT:
  2349.                /*
  2350.                 *   preserve previous values
  2351.                 */
  2352.                pHornDlgData->PrevHighTone =
  2353.                   _QueryHighTone(pHornDlgData->somSelf);
  2354.                pHornDlgData->PrevLowTone =
  2355.                   _QueryLowTone(pHornDlgData->somSelf);
  2356.  
  2357.                _SetHighTone(pHornDlgData->somSelf, DEFAULT_HITONE);
  2358.                _SetLowTone(pHornDlgData->somSelf, DEFAULT_LOTONE);
  2359.  
  2360.                WinSendDlgItemMsg( hwndDlg, ID_HITONE, SPBM_SETCURRENTVALUE,
  2361.                   MPFROMLONG(DEFAULT_HITONE), MPFROMLONG(0));
  2362.  
  2363.                WinSendDlgItemMsg( hwndDlg, ID_LOTONE, SPBM_SETCURRENTVALUE,
  2364.                   MPFROMLONG(DEFAULT_LOTONE), MPFROMLONG(0));
  2365.                break;
  2366.  
  2367.             case ID_HELP:
  2368.                break;
  2369.  
  2370.          }   /* end switch (SHORT1FROMMP(mp1)) */
  2371.  
  2372.          return (MRESULT) TRUE;
  2373.          break;
  2374.  
  2375.       case WM_CONTROL:
  2376.       {
  2377.        ULONG temp;
  2378.  
  2379.          pHornDlgData = WinQueryWindowPtr(hwndDlg, QWL_USER);
  2380.  
  2381.          if (pHornDlgData == NULL)
  2382.          {
  2383.             DebugBox("HornBeepDlgProc", "Couldn't get window words");
  2384.             break;
  2385.          }
  2386.  
  2387.          switch (SHORT2FROMMP(mp1))
  2388.          {
  2389.             case SPBN_ENDSPIN:
  2390.  
  2391.                /*
  2392.                 *   preserve previous values
  2393.                 */
  2394.                pHornDlgData->PrevHighTone =
  2395.                   _QueryHighTone(pHornDlgData->somSelf);
  2396.                pHornDlgData->PrevLowTone =
  2397.                   _QueryLowTone(pHornDlgData->somSelf);
  2398.  
  2399.                WinSendDlgItemMsg( hwndDlg, ID_HITONE, SPBM_QUERYVALUE,
  2400.                   (MPARAM)&temp, MPFROM2SHORT(0,SPBQ_UPDATEIFVALID));
  2401.                _SetHighTone(pHornDlgData->somSelf, temp);
  2402.  
  2403.                WinSendDlgItemMsg( hwndDlg, ID_LOTONE, SPBM_QUERYVALUE,
  2404.                   (MPARAM)&temp, MPFROM2SHORT(0,SPBQ_UPDATEIFVALID));
  2405.                _SetLowTone(pHornDlgData->somSelf, temp);
  2406.  
  2407.                break;
  2408.  
  2409.          }   /* end switch (SHORT2FROMMP(mp1)) */
  2410.  
  2411.       }   /* end case WM_CONTROL: */
  2412.  
  2413.       return (MRESULT) TRUE;
  2414.       break;
  2415.  
  2416.    }   /* end switch(msg) */
  2417.  
  2418.    return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  2419.  
  2420. }   /* end HornBeepDlgProc() */
  2421.  
  2422. /******************************************************************************
  2423. *
  2424. *   _Exception()
  2425. *
  2426. *   DESCRIPTION:  Exception handler routine for this object.
  2427. *
  2428. *   PURPOSE: To notify user when an illegal memory access is made
  2429. *
  2430. *   METHOD:  Whenever a memory protection exception occurs, a message
  2431. *            box is put on the screen to inform the user.
  2432. *
  2433. *   RETURNS: Returns HANDLED if memory exception,
  2434. *            otherwise, returns NOT_HANDLED
  2435. *
  2436. ******************************************************************************/
  2437. ULONG _Exception(EXCEPTIONREPORTRECORD       *parg,
  2438.                  EXCEPTIONREGISTRATIONRECORD *pRegisRecord,
  2439.                  PCONTEXTRECORD               pContextRecord,
  2440.                  PVOID                        pvSpare)
  2441. {
  2442.    LONG  rc;
  2443.    CHAR  szText[CCHMAXPATH];
  2444.  
  2445.    switch (parg->ExceptionNum)
  2446.    {
  2447.       case XCPT_ACCESS_VIOLATION:
  2448.  
  2449.          /*
  2450.           *   Notify the user when memory access violation occurs.
  2451.           */
  2452.          WinAlarm(HWND_DESKTOP, WA_ERROR);
  2453.          longjmp(jmpState, ERROR_PROTECTION_VIOLATION);
  2454.          break;
  2455.  
  2456.       case XCPT_PROCESS_TERMINATE:
  2457.       case XCPT_ASYNC_PROCESS_TERMINATE:
  2458.       case XCPT_SIGNAL:
  2459.       default:
  2460.          /*
  2461.           *   For more exceptions, see the header files or the programming
  2462.           *   reference(s).
  2463.           */
  2464.          break;
  2465.  
  2466.    }   /* end switch (parg->ExceptionNum) */
  2467.  
  2468.    return(XCPT_CONTINUE_SEARCH);
  2469.  
  2470. }   /* end _Exception() */
  2471.  
  2472. /********************************  END car.c  ********************************/
  2473.