blob: 5e68ba49c2369989946eeb8d646fab6fc150d4f3 [file] [log] [blame]
Alexandre Julliard401710d1993-09-04 10:09:32 +00001/*
2 * Timer functions
3 *
4 * Copyright 1993 Alexandre Julliard
5 */
6
Marcus Meissner61afa331999-02-22 10:16:00 +00007#include "winuser.h"
Alexandre Julliardb817f4f1996-03-14 18:08:34 +00008#include "queue.h"
Ulrich Weigand1babe5b1998-12-24 15:16:08 +00009#include "task.h"
Alexandre Julliardca22b331996-07-12 19:02:39 +000010#include "winproc.h"
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +000011#include "services.h"
Alexandre Julliardaca05781994-10-17 18:12:41 +000012#include "debug.h"
Alexandre Julliard401710d1993-09-04 10:09:32 +000013
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000014DEFAULT_DEBUG_CHANNEL(timer)
15
Alexandre Julliard401710d1993-09-04 10:09:32 +000016
Alexandre Julliard5f721f81994-01-04 20:14:34 +000017typedef struct tagTIMER
Alexandre Julliard401710d1993-09-04 10:09:32 +000018{
Alexandre Julliarda3960291999-02-26 11:11:13 +000019 HWND hwnd;
Alexandre Julliardca22b331996-07-12 19:02:39 +000020 HQUEUE16 hq;
21 UINT16 msg; /* WM_TIMER or WM_SYSTIMER */
Alexandre Julliarda3960291999-02-26 11:11:13 +000022 UINT id;
23 UINT timeout;
Alexandre Julliard5f721f81994-01-04 20:14:34 +000024 struct tagTIMER *next;
Alexandre Julliard8b915631996-06-16 16:16:05 +000025 DWORD expires; /* Next expiration, or 0 if already expired */
Alexandre Julliardca22b331996-07-12 19:02:39 +000026 HWINDOWPROC proc;
Alexandre Julliard401710d1993-09-04 10:09:32 +000027} TIMER;
28
29#define NB_TIMERS 34
30#define NB_RESERVED_TIMERS 2 /* for SetSystemTimer */
31
32static TIMER TimersArray[NB_TIMERS];
33
Alexandre Julliard5f721f81994-01-04 20:14:34 +000034static TIMER * pNextTimer = NULL; /* Next timer to expire */
35
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000036static CRITICAL_SECTION csTimer;
37
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000038 /* Duration from 'time' until expiration of the timer */
39#define EXPIRE_TIME(pTimer,time) \
40 (((pTimer)->expires <= (time)) ? 0 : (pTimer)->expires - (time))
41
Alexandre Julliard401710d1993-09-04 10:09:32 +000042
43/***********************************************************************
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000044 * TIMER_Init
45 *
46 * Initialize critical section for the timer.
47 */
48BOOL TIMER_Init( void )
49{
50 InitializeCriticalSection( &csTimer );
51 MakeCriticalSectionGlobal( &csTimer );
52
53 return TRUE;
54}
55
56
57/***********************************************************************
Alexandre Julliard5f721f81994-01-04 20:14:34 +000058 * TIMER_InsertTimer
59 *
60 * Insert the timer at its place in the chain.
Alexandre Julliard401710d1993-09-04 10:09:32 +000061 */
Alexandre Julliard5f721f81994-01-04 20:14:34 +000062static void TIMER_InsertTimer( TIMER * pTimer )
Alexandre Julliard401710d1993-09-04 10:09:32 +000063{
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000064 EnterCriticalSection( &csTimer );
65
Alexandre Julliard5f721f81994-01-04 20:14:34 +000066 if (!pNextTimer || (pTimer->expires < pNextTimer->expires))
Alexandre Julliard401710d1993-09-04 10:09:32 +000067 {
Alexandre Julliard5f721f81994-01-04 20:14:34 +000068 pTimer->next = pNextTimer;
69 pNextTimer = pTimer;
Alexandre Julliard401710d1993-09-04 10:09:32 +000070 }
Alexandre Julliard5f721f81994-01-04 20:14:34 +000071 else
72 {
73 TIMER * ptr = pNextTimer;
74 while (ptr->next && (pTimer->expires >= ptr->next->expires))
75 ptr = ptr->next;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000076 pTimer->next = ptr->next;
Alexandre Julliard5f721f81994-01-04 20:14:34 +000077 ptr->next = pTimer;
78 }
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000079
80 LeaveCriticalSection( &csTimer );
Alexandre Julliard5f721f81994-01-04 20:14:34 +000081}
82
83
84/***********************************************************************
85 * TIMER_RemoveTimer
86 *
87 * Remove the timer from the chain.
88 */
89static void TIMER_RemoveTimer( TIMER * pTimer )
90{
Alexandre Julliardef702d81996-05-28 18:54:58 +000091 TIMER **ppTimer = &pNextTimer;
92
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000093 EnterCriticalSection( &csTimer );
94
Alexandre Julliardef702d81996-05-28 18:54:58 +000095 while (*ppTimer && (*ppTimer != pTimer)) ppTimer = &(*ppTimer)->next;
96 if (*ppTimer) *ppTimer = pTimer->next;
Alexandre Julliard5f721f81994-01-04 20:14:34 +000097 pTimer->next = NULL;
Stephane Lussier35ffc5d1999-03-25 13:23:26 +000098
99 LeaveCriticalSection( &csTimer );
100
Alexandre Julliard8b915631996-06-16 16:16:05 +0000101 if (!pTimer->expires) QUEUE_DecTimerCount( pTimer->hq );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000102}
103
Alexandre Julliardef702d81996-05-28 18:54:58 +0000104
105/***********************************************************************
106 * TIMER_ClearTimer
107 *
108 * Clear and remove a timer.
109 */
110static void TIMER_ClearTimer( TIMER * pTimer )
111{
112 TIMER_RemoveTimer( pTimer );
Alexandre Julliardef702d81996-05-28 18:54:58 +0000113 pTimer->hwnd = 0;
114 pTimer->msg = 0;
115 pTimer->id = 0;
116 pTimer->timeout = 0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000117 WINPROC_FreeProc( pTimer->proc, WIN_PROC_TIMER );
Alexandre Julliardef702d81996-05-28 18:54:58 +0000118}
119
120
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000121/***********************************************************************
Alexandre Julliardef702d81996-05-28 18:54:58 +0000122 * TIMER_RemoveWindowTimers
123 *
124 * Remove all timers for a given window.
125 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000126void TIMER_RemoveWindowTimers( HWND hwnd )
Alexandre Julliardef702d81996-05-28 18:54:58 +0000127{
128 int i;
129 TIMER *pTimer;
130
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000131 EnterCriticalSection( &csTimer );
132
Alexandre Julliardef702d81996-05-28 18:54:58 +0000133 for (i = NB_TIMERS, pTimer = TimersArray; i > 0; i--, pTimer++)
134 if ((pTimer->hwnd == hwnd) && pTimer->timeout)
135 TIMER_ClearTimer( pTimer );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000136
137 LeaveCriticalSection( &csTimer );
Alexandre Julliardef702d81996-05-28 18:54:58 +0000138}
139
140
141/***********************************************************************
142 * TIMER_RemoveQueueTimers
143 *
144 * Remove all timers for a given queue.
145 */
Alexandre Julliardca22b331996-07-12 19:02:39 +0000146void TIMER_RemoveQueueTimers( HQUEUE16 hqueue )
Alexandre Julliardef702d81996-05-28 18:54:58 +0000147{
148 int i;
149 TIMER *pTimer;
150
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000151 EnterCriticalSection( &csTimer );
152
Alexandre Julliardef702d81996-05-28 18:54:58 +0000153 for (i = NB_TIMERS, pTimer = TimersArray; i > 0; i--, pTimer++)
154 if ((pTimer->hq == hqueue) && pTimer->timeout)
155 TIMER_ClearTimer( pTimer );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000156
157 LeaveCriticalSection( &csTimer );
Alexandre Julliardef702d81996-05-28 18:54:58 +0000158}
159
160
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000161/***********************************************************************
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000162 * TIMER_RestartTimers
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000163 *
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000164 * Restart an expired timer.
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000165 */
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000166static void TIMER_RestartTimer( TIMER * pTimer, DWORD curTime )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000167{
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000168 TIMER_RemoveTimer( pTimer );
169 pTimer->expires = curTime + pTimer->timeout;
170 TIMER_InsertTimer( pTimer );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000171}
172
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000173/***********************************************************************
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000174 * TIMER_CheckTimers
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000175 *
Alexandre Julliard8b915631996-06-16 16:16:05 +0000176 * Mark expired timers and wake the appropriate queues.
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000177 */
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000178static void CALLBACK TIMER_CheckTimers( ULONG_PTR forceTimer )
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000179{
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000180 static HANDLE ServiceHandle = INVALID_HANDLE_VALUE;
181 static LONG ServiceTimeout = 0;
182
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000183 TIMER *pTimer;
Alexandre Julliard8b915631996-06-16 16:16:05 +0000184 DWORD curTime = GetTickCount();
185
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000186 EnterCriticalSection( &csTimer );
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000187
188 TRACE(timer, "Called at %ld (%s)\n", curTime, forceTimer? "manual" : "auto" );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000189
190 pTimer = pNextTimer;
191
Alexandre Julliard8b915631996-06-16 16:16:05 +0000192 while (pTimer && !pTimer->expires) /* Skip already expired timers */
193 pTimer = pTimer->next;
194 while (pTimer && (pTimer->expires <= curTime))
195 {
196 pTimer->expires = 0;
197 QUEUE_IncTimerCount( pTimer->hq );
198 pTimer = pTimer->next;
199 }
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000200
201 /* Install service callback with appropriate timeout, so that
202 we get called again once the next timer has expired */
203
204 if (pTimer)
205 {
206 LONG timeout = pTimer->expires - curTime;
207
208 if ( forceTimer || timeout != ServiceTimeout )
209 {
210 if ( ServiceHandle != INVALID_HANDLE_VALUE )
211 SERVICE_Delete( ServiceHandle );
212
213 ServiceHandle = SERVICE_AddTimer( timeout * 1000L,
214 TIMER_CheckTimers, FALSE );
215 ServiceTimeout = timeout;
216
217 TRACE(timer, "Installed service callback with timeout %ld\n", timeout );
218 }
219 }
220 else
221 {
222 if ( ServiceHandle != INVALID_HANDLE_VALUE )
223 {
224 SERVICE_Delete( ServiceHandle );
225 ServiceHandle = INVALID_HANDLE_VALUE;
226 ServiceTimeout = 0;
227
228 TRACE(timer, "Deleted service callback\n" );
229 }
230 }
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000231
232 LeaveCriticalSection( &csTimer );
Alexandre Julliard8b915631996-06-16 16:16:05 +0000233}
234
235
236/***********************************************************************
237 * TIMER_GetTimerMsg
238 *
239 * Build a message for an expired timer.
240 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000241BOOL TIMER_GetTimerMsg( MSG *msg, HWND hwnd,
242 HQUEUE16 hQueue, BOOL remove )
Alexandre Julliard8b915631996-06-16 16:16:05 +0000243{
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000244 TIMER *pTimer;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000245 DWORD curTime = GetTickCount();
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000246
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000247 EnterCriticalSection( &csTimer );
248
249 pTimer = pNextTimer;
250
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000251 if (hwnd) /* Find first timer for this window */
252 while (pTimer && (pTimer->hwnd != hwnd)) pTimer = pTimer->next;
Alexandre Julliard8b915631996-06-16 16:16:05 +0000253 else /* Find first timer for this queue */
254 while (pTimer && (pTimer->hq != hQueue)) pTimer = pTimer->next;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000255
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000256 if (!pTimer || (pTimer->expires > curTime))
257 {
258 LeaveCriticalSection( &csTimer );
259 return FALSE; /* No timer */
260 }
261
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000262 TRACE(timer, "Timer expired: %04x, %04x, %04x, %08lx\n",
Alexandre Julliard8b915631996-06-16 16:16:05 +0000263 pTimer->hwnd, pTimer->msg, pTimer->id, (DWORD)pTimer->proc);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000264
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000265 if (remove)
266 {
267 TIMER_RestartTimer( pTimer, curTime ); /* Restart it */
268 TIMER_CheckTimers( TRUE );
269 }
270
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000271 /* Build the message */
Stephane Lussierb3a99de1999-02-09 15:35:12 +0000272 msg->hwnd = pTimer->hwnd;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000273 msg->message = pTimer->msg;
Stephane Lussierb3a99de1999-02-09 15:35:12 +0000274 msg->wParam = pTimer->id;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000275 msg->lParam = (LONG)pTimer->proc;
276 msg->time = curTime;
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000277
278 LeaveCriticalSection( &csTimer );
279
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000280 return TRUE;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000281}
282
283
284/***********************************************************************
285 * TIMER_SetTimer
286 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000287static UINT TIMER_SetTimer( HWND hwnd, UINT id, UINT timeout,
288 WNDPROC16 proc, WINDOWPROCTYPE type, BOOL sys )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000289{
290 int i;
291 TIMER * pTimer;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000292
Alexandre Julliard401710d1993-09-04 10:09:32 +0000293 if (!timeout) return 0;
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000294
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000295 EnterCriticalSection( &csTimer );
296
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000297 /* Check if there's already a timer with the same hwnd and id */
298
Alexandre Julliardaca05781994-10-17 18:12:41 +0000299 for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
300 if ((pTimer->hwnd == hwnd) && (pTimer->id == id) &&
301 (pTimer->timeout != 0))
302 {
303 /* Got one: set new values and return */
Alexandre Julliardaca05781994-10-17 18:12:41 +0000304 TIMER_RemoveTimer( pTimer );
Alexandre Julliard8b915631996-06-16 16:16:05 +0000305 pTimer->timeout = timeout;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000306 WINPROC_FreeProc( pTimer->proc, WIN_PROC_TIMER );
Alexandre Julliardca22b331996-07-12 19:02:39 +0000307 pTimer->proc = (HWINDOWPROC)0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000308 if (proc) WINPROC_SetProc( &pTimer->proc, proc,
309 type, WIN_PROC_TIMER );
Alexandre Julliard8b915631996-06-16 16:16:05 +0000310 pTimer->expires = GetTickCount() + timeout;
Alexandre Julliardaca05781994-10-17 18:12:41 +0000311 TIMER_InsertTimer( pTimer );
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000312 TIMER_CheckTimers( TRUE );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000313 LeaveCriticalSection( &csTimer );
Alexandre Julliardaca05781994-10-17 18:12:41 +0000314 return id;
315 }
Alexandre Julliard940d58c1994-09-16 09:24:37 +0000316
Alexandre Julliard401710d1993-09-04 10:09:32 +0000317 /* Find a free timer */
318
319 for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
320 if (!pTimer->timeout) break;
321
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000322 if ( (i >= NB_TIMERS) ||
323 (!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) )
324 {
325 LeaveCriticalSection( &csTimer );
326 return 0;
327 }
328
Alexandre Julliard401710d1993-09-04 10:09:32 +0000329 if (!hwnd) id = i + 1;
330
331 /* Add the timer */
332
333 pTimer->hwnd = hwnd;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000334 pTimer->hq = (hwnd) ? GetThreadQueue16( GetWindowThreadProcessId( hwnd, NULL ) )
335 : GetFastQueue16( );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000336 pTimer->msg = sys ? WM_SYSTIMER : WM_TIMER;
337 pTimer->id = id;
338 pTimer->timeout = timeout;
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000339 pTimer->expires = GetTickCount() + timeout;
Alexandre Julliardca22b331996-07-12 19:02:39 +0000340 pTimer->proc = (HWINDOWPROC)0;
Alexandre Julliarddf2673b1997-03-29 17:20:20 +0000341 if (proc) WINPROC_SetProc( &pTimer->proc, proc, type, WIN_PROC_TIMER );
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000342 TRACE(timer, "Timer added: %p, %04x, %04x, %04x, %08lx\n",
Alexandre Julliardca22b331996-07-12 19:02:39 +0000343 pTimer, pTimer->hwnd, pTimer->msg, pTimer->id,
344 (DWORD)pTimer->proc );
Alexandre Julliard5f721f81994-01-04 20:14:34 +0000345 TIMER_InsertTimer( pTimer );
Ulrich Weigand9dcaeca1999-05-02 11:30:39 +0000346 TIMER_CheckTimers( TRUE );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000347
348 LeaveCriticalSection( &csTimer );
349
Alexandre Julliardca22b331996-07-12 19:02:39 +0000350 if (!id) return TRUE;
351 else return id;
Alexandre Julliard401710d1993-09-04 10:09:32 +0000352}
353
354
355/***********************************************************************
356 * TIMER_KillTimer
357 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000358static BOOL TIMER_KillTimer( HWND hwnd, UINT id, BOOL sys )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000359{
360 int i;
361 TIMER * pTimer;
362
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000363 EnterCriticalSection( &csTimer );
364
Alexandre Julliardef702d81996-05-28 18:54:58 +0000365 /* Find the timer */
Alexandre Julliard401710d1993-09-04 10:09:32 +0000366
367 for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
368 if ((pTimer->hwnd == hwnd) && (pTimer->id == id) &&
369 (pTimer->timeout != 0)) break;
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000370
371 if ( (i >= NB_TIMERS) ||
372 (!sys && (i >= NB_TIMERS-NB_RESERVED_TIMERS)) ||
373 (!sys && (pTimer->msg != WM_TIMER)) ||
374 (sys && (pTimer->msg != WM_SYSTIMER)) )
375 {
376 LeaveCriticalSection( &csTimer );
377 return FALSE;
378 }
Alexandre Julliard401710d1993-09-04 10:09:32 +0000379
Alexandre Julliardef702d81996-05-28 18:54:58 +0000380 /* Delete the timer */
Alexandre Julliard401710d1993-09-04 10:09:32 +0000381
Alexandre Julliardef702d81996-05-28 18:54:58 +0000382 TIMER_ClearTimer( pTimer );
Stephane Lussier35ffc5d1999-03-25 13:23:26 +0000383
384 LeaveCriticalSection( &csTimer );
385
Alexandre Julliard401710d1993-09-04 10:09:32 +0000386 return TRUE;
387}
388
389
390/***********************************************************************
Alexandre Julliardca22b331996-07-12 19:02:39 +0000391 * SetTimer16 (USER.10)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000392 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000393UINT16 WINAPI SetTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout,
394 TIMERPROC16 proc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000395{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000396 TRACE(timer, "%04x %d %d %08lx\n",
Alexandre Julliardca22b331996-07-12 19:02:39 +0000397 hwnd, id, timeout, (LONG)proc );
398 return TIMER_SetTimer( hwnd, id, timeout, (WNDPROC16)proc,
399 WIN_PROC_16, FALSE );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000400}
401
402
403/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000404 * SetTimer32 (USER32.511)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000405 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000406UINT WINAPI SetTimer( HWND hwnd, UINT id, UINT timeout,
407 TIMERPROC proc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000408{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000409 TRACE(timer, "%04x %d %d %08lx\n",
Alexandre Julliardca22b331996-07-12 19:02:39 +0000410 hwnd, id, timeout, (LONG)proc );
411 return TIMER_SetTimer( hwnd, id, timeout, (WNDPROC16)proc,
412 WIN_PROC_32A, FALSE );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000413}
414
415
416/***********************************************************************
Alexandre Julliardca22b331996-07-12 19:02:39 +0000417 * SetSystemTimer16 (USER.11)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000418 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000419UINT16 WINAPI SetSystemTimer16( HWND16 hwnd, UINT16 id, UINT16 timeout,
420 TIMERPROC16 proc )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000421{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000422 TRACE(timer, "%04x %d %d %08lx\n",
Alexandre Julliardca22b331996-07-12 19:02:39 +0000423 hwnd, id, timeout, (LONG)proc );
424 return TIMER_SetTimer( hwnd, id, timeout, (WNDPROC16)proc,
425 WIN_PROC_16, TRUE );
426}
427
428
429/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000430 * SetSystemTimer32 (USER32.509)
Alexandre Julliardca22b331996-07-12 19:02:39 +0000431 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000432UINT WINAPI SetSystemTimer( HWND hwnd, UINT id, UINT timeout,
433 TIMERPROC proc )
Alexandre Julliardca22b331996-07-12 19:02:39 +0000434{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000435 TRACE(timer, "%04x %d %d %08lx\n",
Alexandre Julliardca22b331996-07-12 19:02:39 +0000436 hwnd, id, timeout, (LONG)proc );
437 return TIMER_SetTimer( hwnd, id, timeout, (WNDPROC16)proc,
438 WIN_PROC_32A, TRUE );
439}
440
441
442/***********************************************************************
443 * KillTimer16 (USER.12)
444 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000445BOOL16 WINAPI KillTimer16( HWND16 hwnd, UINT16 id )
Alexandre Julliardca22b331996-07-12 19:02:39 +0000446{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000447 TRACE(timer, "%04x %d\n", hwnd, id );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000448 return TIMER_KillTimer( hwnd, id, FALSE );
449}
450
451
452/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000453 * KillTimer32 (USER32.354)
Alexandre Julliard401710d1993-09-04 10:09:32 +0000454 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000455BOOL WINAPI KillTimer( HWND hwnd, UINT id )
Alexandre Julliard401710d1993-09-04 10:09:32 +0000456{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000457 TRACE(timer, "%04x %d\n", hwnd, id );
Alexandre Julliardca22b331996-07-12 19:02:39 +0000458 return TIMER_KillTimer( hwnd, id, FALSE );
459}
460
461
462/***********************************************************************
463 * KillSystemTimer16 (USER.182)
464 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000465BOOL16 WINAPI KillSystemTimer16( HWND16 hwnd, UINT16 id )
Alexandre Julliardca22b331996-07-12 19:02:39 +0000466{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000467 TRACE(timer, "%04x %d\n", hwnd, id );
Alexandre Julliardca22b331996-07-12 19:02:39 +0000468 return TIMER_KillTimer( hwnd, id, TRUE );
469}
470
471
472/***********************************************************************
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000473 * KillSystemTimer32 (USER32.353)
Alexandre Julliardca22b331996-07-12 19:02:39 +0000474 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000475BOOL WINAPI KillSystemTimer( HWND hwnd, UINT id )
Alexandre Julliardca22b331996-07-12 19:02:39 +0000476{
Alexandre Julliarda69b88b1998-03-15 20:29:56 +0000477 TRACE(timer, "%04x %d\n", hwnd, id );
Alexandre Julliard401710d1993-09-04 10:09:32 +0000478 return TIMER_KillTimer( hwnd, id, TRUE );
479}