MFC普通定时器应用
1.添加WM_TIMER消息
1.进入资源视图属性页
2.进入消息,添加消息WM_TIMER
2.设置定时器
1.在合适的地方(一般在初始化中,注意使用的变量的位置)设置定期器
UINT_PTR SetTimer(UINT_PTR nIDEvent, UINT nElapse,
void (CALLBACK* lpfnTimer)(HWND, UINT, UINT_PTR, DWORD));
参数:
nIDEvent 定时器ID
nElapse 定时时间,单位为ms
void (CALLBACK* lpfnTimer)(HWND, UINT, UINT_PTR, DWORD) 回调函数,一般为null,表示为默认的ontimer函数。
3.关闭定时器
BOOL KillTimer(UINT_PTR nIDEvent);