timer.cpp
来自「播放被H264_AAC所压缩的avi文件的播放器。」· C++ 代码 · 共 60 行
CPP
60 行
// 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 + =
减小字号Ctrl + -
显示快捷键?