64,641
社区成员
发帖
与我相关
我的任务
分享
void CALLBACK timer(HWND hwnd, UINT uMsg,UINT idEvent,DWORD dwTime) //CALLBACK
{
printf("hello!\n");
return;
}
int main()
{
MSG msg;
int send = SetTimer(NULL, 0, 3000, (TIMERPROC)timer); //每隔3秒调用一次timer函数。
while(1)
{
GetMessage (&msg, NULL, 0, 0);
TranslateMessage(&msg);
DispatchMessage(&msg);
}
KillTimer(NULL, send);
return 0;
}
MSG msg;
while (int ret = ::GetMessage(&msg, NULL, 0, 0) != 0)
{
if (ret == -1) break; // handle the error and possibly exit
else
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
}
return static_cast<int>(msg.wParam);