SomeUser
SomeUser

Reputation: 2041

How to create timer in WinApi (C++)?

How to create timer in WinApi (C++)?

Upvotes: 11

Views: 26742

Answers (5)

sankar
sankar

Reputation: 82

call the setTimer() Function. Suppose I called

SetTimer(hWnd,POST_CBIT_TIMER,500,NULL);

Call back function is

UINT nIdEvent ;//global member variable

case WM_TIMER:

if(nIDEvent == POST_CBIT_TIMER)
{

KillTimer(hParent,POST_CBIT_TIMER);


}
break;

Upvotes: 2

Swanand
Swanand

Reputation: 4115

A Good Example for CreateTimerQueueTimer : Here

Another is HERE

Upvotes: 4

Hans Passant
Hans Passant

Reputation: 941218

You cannot not know this if you write GUI code. Which makes it likely you want to use CreateTimerQueueTimer().

Upvotes: 7

itowlson
itowlson

Reputation: 74802

Call the SetTimer function. This allows you to specify a callback function, or to have Windows post you a WM_TIMER message.

Upvotes: 11

John Knoeller
John Knoeller

Reputation: 34128

SetTimer. A window handle is needed, and the timer will not be delivered if you aren't pumping messages.

Upvotes: 4

Related Questions