#include
#include
#include
int count =0;
VOID CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
count++;
printf("WM_TIMER in work thread count=%d\n",count);
}
DWORD CALLBACK Thread(PVOID pvoid)
{
MSGmsg;
PeekMessage(&msg,NULL,WM_USER,WM_USER,PM_NOREMOVE);
UINTtimerid=SetTimer(NULL,111,3000,TimerProc);
BOOLbRet;
while( (bRet = GetMessage(&msg,NULL,0,0))!= 0)
{
if(bRet==-1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
KillTimer(NULL,timerid);
printf("thread end here\n");
return 0;
}
int
main()
{
DWORD dwThreadId;
HANDLE hThread=
CreateThread(NULL,0,Thread,0,0,&dwThreadId);
_getch();
return 0;
}
在main()函数中,代码麻烦详细解释下,如果定时器时间到了,响应的代码写在那里?
其实不需要太懂,我只想知道,我如何使用这些代码,我将自己的代码加在那里(定时器相应后的代码,我自己写的与定时器无关的代码)
|