TA的每日心情 | 开心 2024-02-17 18:16 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
管理员
这里没有广告...
  
- 积分
- 10709

|
MFC中SetTimer设置定时器、OnTimer时间触发回调函数均是CWnd的成员函数,但前提是必须在有窗口的环境下。
对于ATL无窗口的情况,只能使用原始SetTimer Win32 API函数,如下:
回调函数:
VOID CALLBACK TimerProc(
HWND hwnd, // 定时器消息的窗口句柄
UINT message, // WM_TIMER 消息
INT_PTR idTimer, // 定时器标志
DWORD dwTime) // 当前系统启动计时
{
...
}
调用方法:
UINT nRet = SetTimer(NULL, // handle to main window
ID_TIMER, // 定时器标识
1000, // 1 秒间隔
(TIMERPROC)TimerProc); // 回调函数
|
|