How to create timer in WinApi (C++)?
+3
A:
SetTimer. A window handle is needed, and the timer will not be delivered if you aren't pumping messages.
John Knoeller
2010-01-24 20:22:43
+5
A:
Call the SetTimer function. This allows you to specify a callback function, or to have Windows post you a WM_TIMER message.
itowlson
2010-01-24 20:23:30
as per nobugz - this will not work in console applications or non gui threads. threads must be pumping messages to generate SetTimer callbacks.
Chris Becke
2010-01-26 21:33:52
+1
A:
You cannot not know this if you write GUI code. Which makes it likely you want to use CreateTimerQueueTimer().
Hans Passant
2010-01-24 20:43:41
Yes, CreateTimerQueueTimer is your friend. Beware that the callback is executed on a threadpool thread so use proper locking.
Hans Passant
2010-01-24 21:57:15