home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ICLUI.ZIP / HELLO6 / ATIMEHDR.CPP < prev    next >
Text File  |  1993-02-23  |  5KB  |  81 lines

  1. /******************************************************************************/
  2. /* HELLO WORLD SAMPLE PROGRAM - Version 6: Class Implementation (ATIMEHDR.CPP)*/
  3. /*                                                                            */
  4. /* COPYRIGHT: Copyright (C) International Business Machines Corp., 1992,1993. */
  5. /*                                                                            */
  6. /* DISCLAIMER OF WARRANTIES:                                                  */
  7. /*   The following [enclosed] code is sample code created by IBM              */
  8. /*   Corporation.  This sample code is not part of any standard IBM product   */
  9. /*   and is provided to you solely for the purpose of assisting you in the    */
  10. /*   development of your applications.  The code is provided "AS IS",         */
  11. /*   without warranty of any kind.  IBM shall not be liable for any damages   */
  12. /*   arising out of your use of the sample code, even if they have been       */
  13. /*   advised of the possibility of such damages.                              */
  14. /******************************************************************************/
  15. // NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE
  16.  
  17. //**************************************************************************
  18. // The entire file was created at version 6                                *
  19. //**************************************************************************
  20.  
  21. #include <ithread.hpp>                  //IThread for Timer Call to PM
  22. #include <iwindow.hpp>                  //IWindow
  23. #define INCL_WINTIMER                   //Include OS/2 Timer Calls
  24. #include <os2.h>                        //os2.h to call beep if error
  25. #include "atimehdr.hpp"                 //Include ATimeHandler Class header
  26.  
  27. //**************************************************************************
  28. // ATimeHandler :: handleEventsFor(...)                                    *
  29. //   handleEventsFor                                                       *
  30. //**************************************************************************
  31. IHandler & ATimeHandler :: handleEventsFor( IWindow *window )
  32. {
  33.   if (window)                           //Is Window been Specified?
  34.   {                                     //
  35.     WinStartTimer(                      //Start Timer
  36.       (HAB)IThread::current().anchorBlock(),//Anchor Block (HAB in PM)
  37.       (HWND)window->handle(),           //Return Window Handle
  38.       1,                                //Timer ID
  39.       1000UL);                          //Set to tick every second
  40.   } /* endif */                         //
  41.   return IHandler::handleEventsFor(window);//Call my parent for processing
  42. } /* end ATimeHandler :: handleEventsFor(...) */
  43.  
  44. //**************************************************************************
  45. // ATimeHandler :: stopHandlingEventsFor(...)                              *
  46. //   handleEventsFor                                                       *
  47. //**************************************************************************
  48. IHandler & ATimeHandler :: stopHandlingEventsFor(IWindow *window )
  49. {
  50.   if (window)                           //Is Window been Specified?
  51.   {                                     //
  52.     WinStopTimer(                       //Stop Timer
  53.       (HAB)IThread::current().anchorBlock(),//Anchor Block (HAB in PM)
  54.       (HWND)window->handle(),           //Return Window Handle
  55.       1);                               //Timer ID
  56.   } /* endif */                         //
  57.   return IHandler::stopHandlingEventsFor(window);//Call my parent for processing
  58. } /* end ATimeHandler :: stopHandlingEventsFor(...) */
  59.  
  60. //**************************************************************************
  61. // ATimeHandler :: tick(IEvent& evt)                                       *
  62. //   Tick Event                                                            *
  63. //**************************************************************************
  64. Boolean ATimeHandler :: tick(IEvent& evt)//Default Tick Processing
  65. {                                       //
  66.   return false;                         //Return true
  67. } /* end ATimeHandler :: stopTimer() */
  68.  
  69. /**************************************************************/
  70. /* Dispatch command functions for this handler.               */
  71. /**************************************************************/
  72. Boolean ATimeHandler::dispatchHandlerEvent(IEvent& evt)
  73. {
  74.   if ((evt.eventId() == WM_TIMER) &&    //Is this a WM_TIMER Event and
  75.       (evt.parameter1() == 1))          //  Is this our TimerID?
  76.   {                                     //  Yes, this is a WM_TIMER Event
  77.     return tick(evt);                   //Call Tick and Return
  78.   } /* endif */                         //
  79.   return false;                         //Return Command not Processed
  80. } /* end ATimeHandler :: dispatchHandlerEvent(IEvent& evt) */
  81.