VC++ MFC中,解释下OnTimer()这个函数,谢谢

来源:百度知道 编辑:UC知道 时间:2024/06/09 12:24:27
CWnd::OnTimer
Example See Also Send Feedback

The framework calls this member function after each interval specified in the SetTimer member function used to install a timer.

afx_msg void OnTimer(
UINT_PTR nIDEvent
);

nIDEvent 这个参数的意思是 定时的间隔时间吗?

nIDEvent 是SetTimer( UINT nIDEvent, UINT nElapse )函数中的nIDEvent对应,表示一个Timer事件的ID号。
比如你一个程序中同时用了3个SetTimer函数,3个函数的nIDEvent分别为1,2,3。则在OnTimer函数中通过nIDEvent来判断哪个SetTimer的消息事件。
注意:OnTimer函数一定是和SetTimer函数一起用的。
具体的你可以参看MSDN。

nIDEvent 是你前面用SetTimer()产生的,比如你用SetTimer产生了一个标识为1的东西,在OnTimer里面将参数设为1即可。------不知道我说的对不对,反正我一直这么用,也没啥错,呵呵