WM_TIMER这个消息里面写具体执行的东西 settimer()写间隔时间 CWnd::SetTimer UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );Return ValueThe timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.ParametersnIDEventSpecifies a nonzero timer identifier.nElapseSpecifies the time-out value, in milliseconds.lpfnTimerSpecifies the address of the application-supplied TimerProc callback function that processes the WM_TIMER messages. If this parameter is NULL, the WM_TIMER messages are placed in the application’s message queue and handled by the CWnd object.
settimer()写间隔时间
CWnd::SetTimer
UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );Return ValueThe timer identifier of the new timer if the function is successful. An application passes this value to the KillTimer member function to kill the timer. Nonzero if successful; otherwise 0.ParametersnIDEventSpecifies a nonzero timer identifier.nElapseSpecifies the time-out value, in milliseconds.lpfnTimerSpecifies the address of the application-supplied TimerProc callback function that processes the WM_TIMER messages. If this parameter is NULL, the WM_TIMER messages are placed in the application’s message queue and handled by the CWnd object.
比如在程序启动时设置UINT timer=SetTimer(1,1000,NULL),即为一秒定时器,然后处理OnTimer()函数,程序结束前,KillTimer(timer).
如果你想使用高精度定时,那采用GetTickCount(),他的精度是1微秒。
QueryPerformanceFrequerncy()得到高精度计时器频率。
QueryPerformanceCounter得到高精度计时器的当前计数值。
这也许就是vc开发周期相对长的原因,不过可能也是他独具魅力的原因。
函数的时候需要加哪个头文件啊,我这里没有MSDN,我刚开始学VC,哪位朋友能给一个应用此API函数的例子不胜感激!