home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WTIMER.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  3KB  |  109 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WTimer -- Wrapper for the Windows 95 Timer control.
  14.  *
  15.  *   Events:
  16.  *
  17.  *      Timer --
  18.  *
  19.  *************************************************************************/
  20.  
  21. #ifndef _WTIMER_HPP_INCLUDED
  22. #define _WTIMER_HPP_INCLUDED
  23.  
  24. #ifndef _WNO_PRAGMA_PUSH
  25. #pragma pack(push,8);
  26. #pragma enum int;
  27. #endif
  28.  
  29. #ifndef _WWINDOW_HPP_INCLUDED
  30. #  include "wwindow.hpp"
  31. #endif
  32. #ifndef _WSEMAPHR_HPP_INCLUDED
  33. #  include "wsemaphr.hpp"
  34. #endif
  35.  
  36. class WTimer;
  37.  
  38. struct WTimerEventData : public WEventData {
  39.     WDWord      systemTime;
  40. };
  41.  
  42. class WCMCLASS WTimer : public WEventGenerator {
  43.     WDeclareSubclass( WTimer, WEventGenerator );
  44.     
  45.     public:
  46.  
  47.         /**********************************************************
  48.          * Constructors and Destructors
  49.          *********************************************************/
  50.  
  51.         WTimer();
  52.     
  53.         ~WTimer();
  54.     
  55.         /**********************************************************
  56.          * Properties
  57.          *********************************************************/
  58.  
  59.         // TickCount
  60.         //
  61.         //    Returns the number of milliseconds since the system
  62.         //    was started.
  63.  
  64.         static WDWord GetTickCount();
  65.  
  66.         /**********************************************************
  67.          * Methods
  68.          *********************************************************/
  69.  
  70.         // Start
  71.         //
  72.         //    Start the timer.  The timer will tick with the given
  73.         //    interval.  If count is 0, the timer will tick continuously
  74.         //    until stopped, otherwise it will only tick the given
  75.         //    number of times.
  76.  
  77.         WBool Start( WDWord interval, WInt tickCount=0 );
  78.  
  79.         // Stop
  80.         //
  81.         //    Stop a currently running timer.
  82.  
  83.         WBool Stop();
  84.     
  85.         // Tick
  86.         //
  87.         //    Call the timer's event handler as if a tick had occurred.
  88.         //    If 0 is passed for the tickTime, the current time is
  89.         //    used.
  90.  
  91.         WBool Tick( WDWord tickTime=0 );
  92.  
  93.         /**********************************************************
  94.          * Data members
  95.          *********************************************************/
  96.  
  97.     private:
  98.         WInt            _id;
  99.         WInt            _count;
  100.         WCallbackProc   _procInst;
  101. };
  102.  
  103. #ifndef _WNO_PRAGMA_PUSH
  104. #pragma enum pop;
  105. #pragma pack(pop);
  106. #endif
  107.  
  108. #endif // _WTIMER_HPP_INCLUDED
  109.