00001 #ifndef MMTIMER_H
00002 #define MMTIMER_H
00003 #if _MSC_VER >= 1000
00004 #pragma once
00005 #endif // _MSC_VER >= 1000
00006 #include "WBWin.h"
00007 namespace Spr {
00008
00009
00010
00011
00012 class SPR_DLL WBMMTimer{
00013 static int count;
00014 int tick;
00015 public:
00016 typedef void MMTimerFunc(void* arg);
00017
00018 protected:
00019 static UINT resolution;
00020 UINT interval;
00021 MMTimerFunc* func;
00022 void* arg;
00023 UINT timerID;
00024 volatile bool bCreated;
00025 volatile bool bThread;
00026 volatile bool bRun;
00027 HANDLE hThread;
00028 static void CALLBACK TimerCallback(UINT uID, UINT, DWORD dwUser, DWORD, DWORD);
00029 static DWORD WINAPI ThreadCallback(void* arg);
00030 void BeginPeriod();
00031 void EndPeriod();
00032
00033 public:
00034 volatile int heavy;
00035
00036 WBMMTimer();
00037 ~WBMMTimer();
00038 UINT Resolution();
00039 void Resolution(UINT res);
00040 UINT Interval();
00041 void Interval(UINT i);
00042 void Set(MMTimerFunc* f, void* arg);
00043
00044 bool Create();
00045 bool Thread();
00046 bool IsCreated(){return bCreated;}
00047
00048 bool IsThread(){return bThread;}
00049
00050 void Release();
00051 };
00052
00053 }
00054 #endif