//要做其他事情可以自定义消息, 然后在消息循环那里加入对应的消息处理, 通
//过PostMessage/SendMessage来传消息```
#include
#include
VOID CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
int main(int argc, char* argv[])
{
SetTimer(NULL, 0, 2000, NULL);
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
switch (msg.message)
{
case WM_TIMER:
TimerProc(NULL, 0, 0, 0);
break;
default:
break;
}
}
return 0;
}
VOID CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
printf("Time Up!\n");
}
while (true)
{
// 要运行的东西写这里
Sleep(2000);
}
搜索 WM_TIMER