且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在基于MFC对话框的应用程序中使用计时器?

更新时间:2023-11-19 21:59:16

只需使用SetTimer方法,并传递两个参数:计时器ID(任意数字)和超时(以毫秒为单位).然后编写OnTimer实现,并在BEGIN_MESSAGE_MAP...END_MESSAGE_MAP内写一个条目ON_WM_TIMER.

Just use SetTimer method, and pass two arguments: Timer ID (any number), and the timeout in milliseconds. Then write up OnTimer implementation, and an entry ON_WM_TIMER inside BEGIN_MESSAGE_MAP...END_MESSAGE_MAP.

CWnd :: SetTimer 接受3个参数,但仅需要2个.将第三个参数传递为NULL.

CWnd::SetTimer takes 3 parameters, but only 2 are required. Pass third argument as NULL.

CWnd :: OnTimer