home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / source / wpshidl / samples / wpcar / car.c next >
Encoding:
C/C++ Source or Header  |  1993-11-17  |  74.3 KB  |  2,510 lines

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