📄 timer.cpp
字号:
// Timer.cpp: implementation of the Timer class.
//
//////////////////////////////////////////////////////////////////////
#include <windows.h>
#include "Timer.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//##ModelId=4753B7E9005E
Timer::Timer()
{
}
//##ModelId=4753B7E9005F
Timer::~Timer()
{
}
BOOL Timer::Create (UINT nPeriod, UINT nRes, DWORD dwUser, int pfnCallback(DWORD))
{
BOOL bRtn = TRUE; // assume success
// Set data members
m_nPeriod = nPeriod;
m_nRes = nRes;
m_dwUser = dwUser;
m_pfnCallback = pfnCallback;
// Create multimedia timer
if ((m_nIDTimer = timeSetEvent (m_nPeriod, m_nRes,TimeProc, (DWORD) this, TIME_PERIODIC)) == NULL)
{
bRtn = FALSE;
}
return (bRtn);
}
//##ModelId=4753B7E90060
void Timer::TimerStop(void)
{
timeKillEvent(m_nIDTimer);
}
//##ModelId=4753B7E9006D
void CALLBACK Timer::TimeProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
{
// dwUser contains ptr to Timer object
Timer * ptimer = (Timer *) dwUser;
ptimer->UID=uID;
// Call user-specified callback and pass back user specified data
(*(ptimer->m_pfnCallback) )(ptimer->m_dwUser);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -