3个回答
展开全部
//要做其他事情可以自定义消息, 然后在消息循环那里加入对应的消息处理, 通
//过PostMessage/SendMessage来传消息```
#include <Windows.h>
#include <stdio.h>
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");
}
//过PostMessage/SendMessage来传消息```
#include <Windows.h>
#include <stdio.h>
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");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询