OSDN Git Service

とりあえず実行できるようになった。
[winaudioj/stedx.git] / timer.cpp
1 /*
2   ==============================================================================
3
4    This file is part of the async
5    Copyright 2005-11 by Satoshi Fujiwara.
6
7    async can be redistributed and/or modified under the terms of the
8    GNU General Public License, as published by the Free Software Foundation;
9    either version 2 of the License, or (at your option) any later version.
10
11    async is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with async; if not, visit www.gnu.org/licenses or write to the
18    Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
19    Boston, MA 02111-1307 USA
20
21   ==============================================================================
22 */
23
24 #include "StdAfx.h"
25
26 #if _DEBUG
27 #define _CRTDBG_MAP_ALLOC
28 #include <crtdbg.h>
29 #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
30 #endif
31
32 #include "sf_windows.h"
33 #include "timer.h"
34
35 namespace sf {
36 timer::timer(sf::base_window& window,uint32_t timeout) : window_(window),timeout_(timeout),timer_id_(0)
37 {
38
39 }
40 void timer::start(){
41   if(!::SetTimer(reinterpret_cast<HWND>(window_.raw_handle()),(UINT_PTR)&timer_id_,timeout_,NULL)){
42     throw timer::exception();
43   };
44 };
45
46 void timer::player_stop()
47 {
48   if(timer_id_)
49   {
50     ::KillTimer(reinterpret_cast<HWND>(window_.raw_handle()),(UINT_PTR)&timer_id_);
51     timer_id_ = 0;
52   }
53 };
54
55 }