?? timer.cpp
字號:
// Timer.cpp: implementation of the CTimer class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SimSensor.h"
#include "Timer.h"
#include "Msg.h"
#include "Node.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTimer::CTimer()
{
m_uID = NULL;
m_Type = ONCE;
}
CTimer::~CTimer()
{
}
void CTimer::SetMyTimer(UINT uElapse,bool Type)
{
m_Type = Type;
m_uID = (UINT)timeSetEvent(uElapse,0,(LPTIMECALLBACK)TimeProc,(DWORD)this,(Type?TIME_ONESHOT:TIME_PERIODIC));
if (m_uID==NULL) TRACE("timeSetEvent fail!\n");
}
void CTimer::SendTimerMsg(int MsgType)
{
CMsg *pMsg ;
pMsg = new CMsg;
pMsg->Type = MsgType; //collectdata Msg
((CNode *)m_pNode)->MsgBuff.InsertMsg(pMsg);
}
void CTimer::Band(LPVOID pNode)
{
m_pNode = pNode;
}
void CTimer::EndTimer()
{
if (m_uID) {
timeKillEvent(m_uID);
m_uID = NULL;
}
}
VOID CALLBACK CTimer::TimeProc(
UINT uID,
UINT uMsg,
DWORD dwUser,
DWORD dw1,
DWORD dw2
)
{
CTimer *pTimer = (CTimer *)dwUser;
if ( ONCE == pTimer->m_Type ) {
//pTimer->SendTimerMsg (100);
::MessageBox(NULL,"Timer ONCE arrived!","hehe",MB_OK);
}else
//pTimer->SendTimerMsg (101);
::MessageBox(NULL,"Timer CONTINUE arrived!","hehe",MB_OK);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -