home *** CD-ROM | disk | FTP | other *** search
/ The Developer Connection…ice Driver Kit for OS/2 3 / DEV3-D1.ISO / devtools / gik2 / ewyio2eu.d2x / EWYHAEH.C < prev    next >
Encoding:
Text File  |  1993-08-04  |  10.2 KB  |  190 lines

  1. /*
  2. GIK/2 1.0.1 EWYHAEH.C 5621-432 (C) COPYRIGHT IBM CORP 1991, 1993.  ALL RIGHTS RESERVED.  LICENSED MATERIALS - PROPERTY OF IBM.
  3. */
  4. /**********************************************************************/
  5. /*                                                                    */
  6. /*                         MODULE PROLOGUE                            */
  7. /*                                                                    */
  8. /* COMPONENT NAME:   CLOCK EXAMPLE                                    */
  9. /*                                                                    */
  10. /* MODULE NAME:      EWYHAEH.C                                        */
  11. /*                                                                    */
  12. /* DESCRIPTIVE NAME: Graphics Interface Kit/2 - Clock Example         */
  13. /*                                                                    */
  14. /* PURPOSE:          Event handle functions                           */
  15. /*                                                                    */
  16. /* COPYRIGHT:        (C) 1991, 1993 IBM Corporation                   */
  17. /*                                                                    */
  18. /* DISCLAIMER OF WARRANTIES.  The following [enclosed] code is        */
  19. /* sample code created by IBM Corporation. This sample code is not    */
  20. /* part of any standard or IBM product and is provided to you solely  */
  21. /* for the purpose of assisting you in the development of your        */
  22. /* applications.  The code is provided "AS IS", without               */
  23. /* warranty of any kind.  IBM shall not be liable for any damages     */
  24. /* arising out of your use of the sample code, even if they have been */
  25. /* advised of the possibility of such damages.                        */
  26. /*                                                                    */
  27. /**********************************************************************/
  28.  
  29. ;
  30.  
  31. /*--------------------------------------------------------------------*/
  32. /* INCLUDE RELATED DEFINES                                            */
  33. /*--------------------------------------------------------------------*/
  34.  
  35. #define  INCL_DOS                      /* OS/2 definitions            */
  36. #define  INCL_PM                       /* PM definitions              */
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /* HEADER FILES                                                       */
  40. /*--------------------------------------------------------------------*/
  41.  
  42. #include <os2.h>                       /* OS/2 header file            */
  43. #include <ewyga.h>                     /* GIK/2 header file           */
  44. #include <string.h>
  45. #include "EWYHADF.H"                   /* Generated header file       */
  46. #include "EWYHA.H"                     /* Header file                 */
  47.  
  48. /*--------------------------------------------------------------------*/
  49. /* Module Data                                                        */
  50. /*--------------------------------------------------------------------*/
  51.  
  52. extern PFNWP M_OldWinProc;
  53.  
  54. /*--------------------------------------------------------------------*/
  55. /* LOCAL FUNCTION PROTOTYPES                                          */
  56. /*--------------------------------------------------------------------*/
  57.  
  58. SHORT GSENTRY EvExit(DHND,SHORT,EVS_EXIT *);
  59. SHORT GSENTRY EvInit(DHND,SHORT,EVS_INIT *);
  60.  
  61. /**********************************************************************/
  62. /* EvExit                                                             */
  63. /*                                                                    */
  64. /* Parameters:                                                        */
  65. /*    DHND                     dhnd  (I): Diagram handle.             */
  66. /*    SHORT                    ev_id (I): Identifies the event.       */
  67. /*    EVS_EXIT                 *pEvs (I): Pointer to instance of event*/
  68. /*                                        data type.                  */
  69. /*     SHORT close (I):            Indicator that specifies whether   */
  70. /*                                 the event is triggered during the  */
  71. /*                                 processing of the WM_CLOSE or the  */
  72. /*                                 WM_DESTROY message                 */
  73. /*                                 It is one of the following:        */
  74. /*                                   GS_YES. The WM_CLOSE message is  */
  75. /*                                           processed.               */
  76. /*                                   GS_NO.  The WM_DESTROY message is*/
  77. /*                                           processed.               */
  78. /*     HAB   hab (I):              Handle to anchor block             */
  79. /*     HWND  hwnd_client (I):      Handle to client window            */
  80. /*     HWND  hwnd_frame (I):       Handle to frame window             */
  81. /*     SHORT delay_mode (I):       Indicates whether the function     */
  82. /*                                 GsDelay is currently processing.   */
  83. /*                                 It is GS_YES or GS_NO              */
  84. /*                                                                    */
  85. /* Returns:                                                           */
  86. /*   GS_NO        Any changes made to symbols remain and the action   */
  87. /*                stops.                                              */
  88. /*   GS_NO_1      Any changes made to symbols remain and the action   */
  89. /*                stops.                                              */
  90. /*   GS_RESTORE   Any changes made to symbols since the last undo     */
  91. /*                checkpoint are undone and the action stops.         */
  92. /*   GS_RESTORE_1 Any changes made to symbols since the last undo     */
  93. /*                checkpoint are undone and the action stops.         */
  94. /*   GS_YES       The default processing continues.                   */
  95. /*                                                                    */
  96. /* Description:                                                       */
  97. /*    The function handles the event EV_EXIT.                         */
  98. /**********************************************************************/
  99.  
  100. SHORT GSENTRY EvExit(DHND dhnd,SHORT ev_id,EVS_EXIT *pEvs)
  101. {
  102.   GsPutDiagModify(dhnd, GS_NO);        /* tricky supress the
  103.                                           SaveUnsaved changes pop-up  */
  104.   WinStopTimer(pEvs->hab,
  105.                pEvs->hwnd_client,
  106.                0);                     /* stop timer                  */
  107.  
  108.   /*------------------------------------------------------------------*/
  109.   /* Bye                                                              */
  110.   /*------------------------------------------------------------------*/
  111.  
  112.   return (GS_YES);
  113. }
  114.  
  115. /**********************************************************************/
  116. /* EvInit                                                             */
  117. /*                                                                    */
  118. /* Parameters:                                                        */
  119. /*    DHND                     dhnd  (I): Diagram handle.             */
  120. /*    SHORT                    ev_id (I): Identifies the event.       */
  121. /*    EVS_INIT                 *pEvs (I): Pointer to instance of event*/
  122. /*                                        data type.                  */
  123. /*     VOID *pInit_data (I):       Pointer passed from the customizing*/
  124. /*                                 code to the parameter pInit_data of*/
  125. /*                                 the GIK/2 function GsInitWin       */
  126. /*     HAB  hab (I):               Handle to anchor block             */
  127. /*     HWND hwnd_client (I):       Handle to client window            */
  128. /*     HWND hwnd_frame (I):        Handle to frame window             */
  129. /*                                                                    */
  130. /* Returns:                                                           */
  131. /*   GS_NO        The window is closed.                               */
  132. /*   GS_YES       The initialization of the GIK/2 window continues.   */
  133. /*                                                                    */
  134. /* Description:                                                       */
  135. /*    The function handles the event EV_INIT.                         */
  136. /**********************************************************************/
  137.  
  138. SHORT GSENTRY EvInit(DHND dhnd,SHORT ev_id,EVS_INIT *pEvs)
  139. {
  140.   SHORT            i;
  141.   SHORT            f;
  142.   ULONG            cst;
  143.  
  144.   /*------------------------------------------------------------------*/
  145.   /* Do some beeping at startup                                       */
  146.   /*------------------------------------------------------------------*/
  147.  
  148.   f = 440;
  149.   for (i = 0; i < 9; i++, f = f+f)
  150.   {
  151.     DosBeep(f,
  152.             30);
  153.   }
  154.  
  155.   /*------------------------------------------------------------------*/
  156.   /* Disable the drag select and adding of bendpoitns                 */
  157.   /*------------------------------------------------------------------*/
  158.  
  159.   GsGetDiagConstraint(dhnd, &cst);
  160.   cst &= ~(GS_CST_DIAG_DRAG_SELECT|GS_CST_DIAG_ADD_BP|
  161.      GS_CST_DIAG_DELETION|GS_CST_DIAG_MOVEMENT|GS_CST_DIAG_SIZE|
  162.      GS_CST_DIAG_SELECTION);
  163.   GsPutDiagConstraint(dhnd, cst);
  164.  
  165.   /*------------------------------------------------------------------*/
  166.   /* Initialize a clock style                                         */
  167.   /*------------------------------------------------------------------*/
  168.  
  169.   ActionH(dhnd, AID_STYLE_MARS, 0, 0); /* use action handler itself to
  170.                                           initialize the clock style  */
  171.  
  172.   /*------------------------------------------------------------------*/
  173.   /* Subclass the window to get timer ticks and /* start the system   */
  174.   /* timer to get a WM_TIMER message ever 500ms                       */
  175.   /*------------------------------------------------------------------*/
  176.  
  177.   M_OldWinProc = WinSubclassWindow(pEvs->hwnd_client,
  178.                                    (PFNWP)MyWinProc);
  179.   WinStartTimer(pEvs->hab,
  180.                 pEvs->hwnd_client,
  181.                 0,
  182.                 500);
  183.  
  184.   /*------------------------------------------------------------------*/
  185.   /* Bye                                                              */
  186.   /*------------------------------------------------------------------*/
  187.  
  188.   return (GS_YES);
  189. }
  190.