TIMER API
-
does anyone has a sample code on timer which allows you to call any procedure you want to call say, every 30 ms ? Thanks for helping
VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time ) { .................. } // Set timer SetTimer(hwnd, // handle to main window IDT_TIMER1, // timer identifier 30, // 30ms interval (TIMERPROC) MyTimerProc); // timer callback // Delete timer BOOL KillTimer( HWND hwnd, // handle to window UINT_PTR uIDEvent // timer identifier );
-
does anyone has a sample code on timer which allows you to call any procedure you want to call say, every 30 ms ? Thanks for helping
Standard timers are not very accurate, since they depend on windows messages. If you have a lot of messages in your queue, then timer requests can be delayed. You're better off using the multimedia timers, which have a much higher resolution than normal timers and are waitable (using WaitFor(Single/Multiple)Object(s)).
-
VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time ) { .................. } // Set timer SetTimer(hwnd, // handle to main window IDT_TIMER1, // timer identifier 30, // 30ms interval (TIMERPROC) MyTimerProc); // timer callback // Delete timer BOOL KillTimer( HWND hwnd, // handle to window UINT_PTR uIDEvent // timer identifier );