home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tolkit45.zip / os2tk45 / samples / wps / car / car.c next >
C/C++ Source or Header  |  1999-05-11  |  77KB  |  2,489 lines

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