如何区分不同的定时器
代码如下,但是在回调函数中加上了if判断过后,就不执行输出了,不加的话,还正常!!
//Timer Test
#include <iostream>
#include <windows.h>
using namespace std;
VOID CALLBACK DoTimerFunc(HWND hwnd, UINT uMsg,UINT_PTR idEvent, DWORD dwTime)
{
if(idEvent==100)
{
cout<<"100"<<endl;
}
}
int main()
{
MSG msg;
SetTimer(NULL,100,1000,(TIMERPROC)DoTimerFunc);
while(GetMessage(&msg,NULL,NULL,NULL))
{
if(msg.message==WM_TIMER)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}