Add 'hook' flag for messages. Add a test for CBT hook messages.
[wine] / dlls / user / tests / sysparams.c
1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
2  *
3  * Copyright 2002 Andriy Palamarchuk
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #include "wine/test.h"
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winuser.h"
30
31 #ifndef SPI_GETDESKWALLPAPER
32 # define SPI_GETDESKWALLPAPER 0x0073
33 #endif
34
35 static int strict;
36
37 #define eq(received, expected, label, type) \
38         ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
39
40
41 #define SPI_SETBEEP_REGKEY           "Control Panel\\Sound"
42 #define SPI_SETBEEP_VALNAME          "Beep"
43 #define SPI_SETMOUSE_REGKEY             "Control Panel\\Mouse"
44 #define SPI_SETMOUSE_VALNAME1           "MouseThreshold1"
45 #define SPI_SETMOUSE_VALNAME2           "MouseThreshold2"
46 #define SPI_SETMOUSE_VALNAME3           "MouseSpeed"
47 #define SPI_SETBORDER_REGKEY         "Control Panel\\Desktop\\WindowMetrics"
48 #define SPI_SETBORDER_VALNAME        "BorderWidth"
49 #define SPI_SETKEYBOARDSPEED_REGKEY             "Control Panel\\Keyboard"
50 #define SPI_SETKEYBOARDSPEED_VALNAME            "KeyboardSpeed"
51 #define SPI_SETSCREENSAVETIMEOUT_REGKEY         "Control Panel\\Desktop"
52 #define SPI_SETSCREENSAVETIMEOUT_VALNAME        "ScreenSaveTimeOut"
53 #define SPI_SETSCREENSAVEACTIVE_REGKEY          "Control Panel\\Desktop"
54 #define SPI_SETSCREENSAVEACTIVE_VALNAME         "ScreenSaveActive"
55 #define SPI_SETGRIDGRANULARITY_REGKEY           "Control Panel\\Desktop"
56 #define SPI_SETGRIDGRANULARITY_VALNAME          "GridGranularity"
57 #define SPI_SETKEYBOARDDELAY_REGKEY             "Control Panel\\Keyboard"
58 #define SPI_SETKEYBOARDDELAY_VALNAME            "KeyboardDelay"
59 #define SPI_SETICONTITLEWRAP_REGKEY1            "Control Panel\\Desktop\\WindowMetrics"
60 #define SPI_SETICONTITLEWRAP_REGKEY2            "Control Panel\\Desktop"
61 #define SPI_SETICONTITLEWRAP_VALNAME            "IconTitleWrap"
62 #define SPI_SETMENUDROPALIGNMENT_REGKEY1        "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
63 #define SPI_SETMENUDROPALIGNMENT_REGKEY2        "Control Panel\\Desktop"
64 #define SPI_SETMENUDROPALIGNMENT_VALNAME        "MenuDropAlignment"
65 #define SPI_SETDOUBLECLKWIDTH_REGKEY1           "Control Panel\\Mouse"
66 #define SPI_SETDOUBLECLKWIDTH_REGKEY2           "Control Panel\\Desktop"
67 #define SPI_SETDOUBLECLKWIDTH_VALNAME           "DoubleClickWidth"
68 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1          "Control Panel\\Mouse"
69 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2          "Control Panel\\Desktop"
70 #define SPI_SETDOUBLECLKHEIGHT_VALNAME          "DoubleClickHeight"
71 #define SPI_SETDOUBLECLICKTIME_REGKEY           "Control Panel\\Mouse"
72 #define SPI_SETDOUBLECLICKTIME_VALNAME          "DoubleClickSpeed"
73 #define SPI_SETMOUSEBUTTONSWAP_REGKEY           "Control Panel\\Mouse"
74 #define SPI_SETMOUSEBUTTONSWAP_VALNAME          "SwapMouseButtons"
75 #define SPI_SETWORKAREA_REGKEY                  "Control Panel\\Desktop"
76 #define SPI_SETWORKAREA_VALNAME                 "WINE_WorkArea"
77 #define SPI_SETSHOWSOUNDS_REGKEY     "Control Panel\\Accessibility\\ShowSounds"
78 #define SPI_SETSHOWSOUNDS_VALNAME    "On"
79 #define SPI_SETDRAGFULLWINDOWS_REGKEY           "Control Panel\\Desktop"
80 #define SPI_SETDRAGFULLWINDOWS_VALNAME          "DragFullWindows"
81 #define SPI_SETMOUSEHOVERWIDTH_REGKEY           "Control Panel\\Mouse"
82 #define SPI_SETMOUSEHOVERWIDTH_VALNAME          "MouseHoverWidth"
83 #define SPI_SETMOUSEHOVERHEIGHT_REGKEY          "Control Panel\\Mouse"
84 #define SPI_SETMOUSEHOVERHEIGHT_VALNAME         "MouseHoverHeight"
85 #define SPI_SETMOUSEHOVERTIME_REGKEY            "Control Panel\\Mouse"
86 #define SPI_SETMOUSEHOVERTIME_VALNAME           "MouseHoverTime"
87 #define SPI_SETMOUSESCROLLLINES_REGKEY          "Control Panel\\Desktop"
88 #define SPI_SETMOUSESCROLLLINES_VALNAME         "WheelScrollLines"
89 #define SPI_SETMENUSHOWDELAY_REGKEY             "Control Panel\\Desktop"
90 #define SPI_SETMENUSHOWDELAY_VALNAME            "MenuShowDelay"
91 #define SPI_SETDESKWALLPAPER_REGKEY             "Control Panel\\Desktop"
92 #define SPI_SETDESKWALLPAPER_VALNAME            "Wallpaper"
93 /* FIXME - don't have access to Windows with this action (W95, NT5.0). Set real values */
94 #define SPI_SETKEYBOARDPREF_REGKEY      "Control Panel\\Desktop"
95 #define SPI_SETKEYBOARDPREF_VALNAME     "WINE_WorkArea"
96 #define SPI_SETSCREENREADER_REGKEY      "Control Panel\\Desktop"
97 #define SPI_SETSCREENREADER_VALNAME     "???"
98
99 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
100 #define WINE_CURRENT_USER_REGKEY     "Wine"
101
102 static HWND ghTestWnd;
103
104 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
105 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
106                                               LPARAM lParam );
107 static int change_counter;
108 static int change_last_param;
109
110 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
111                                               LPARAM lParam )
112 {
113     switch (msg) {
114
115     case WM_SETTINGCHANGE:
116         if (change_counter>0) {
117             ok(0,"too many changes counter=%d last change=%d\n",
118                change_counter,change_last_param);
119         }
120         change_counter++;
121         change_last_param = wParam;
122         break;
123
124     case WM_DESTROY:
125         PostQuitMessage( 0 );
126         break;
127
128     default:
129         return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
130     }
131
132     return 0;
133 }
134
135 /*
136 Performs testing for system parameters messages
137 params:
138  - system parameter id
139  - supposed value of the registry key
140 */
141 static void test_change_message( int action, int optional )
142 {
143     if (change_counter==0 && optional==1)
144         return;
145     ok( 1 == change_counter,
146         "Missed a message: change_counter=%d\n", change_counter );
147     change_counter = 0;
148     ok( action == change_last_param,
149         "Wrong action got %d expected %d\n", change_last_param, action );
150     change_last_param = 0;
151 }
152
153 /*
154  * Tests the HKEY_CURRENT_USER subkey value.
155  * The value should contain string value.
156  *
157  * Params:
158  * lpsSubKey - subkey name
159  * lpsRegName - registry entry name
160  * lpsTestValue - value to test
161  */
162 static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName, LPCSTR testValue )
163 {
164     CHAR  value[MAX_PATH];
165     DWORD valueLen;
166     DWORD type;
167     HKEY hKey;
168     LONG rc;
169     int found=0;
170
171     *value='\0';
172     valueLen=sizeof(value);
173     RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
174     rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
175     RegCloseKey( hKey );
176     if (rc==ERROR_SUCCESS)
177     {
178         ok( !strcmp( testValue, value ),
179             "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
180             subKey1, valName, testValue, value );
181         found++;
182     }
183     else if (strict)
184     {
185         ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
186            subKey1, valName);
187     }
188     if (subKey2 && !strict)
189     {
190         *value='\0';
191         valueLen=sizeof(value);
192         RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
193         rc=RegQueryValueExA( hKey, valName, NULL, &type, value, &valueLen );
194         RegCloseKey( hKey );
195         if (rc==ERROR_SUCCESS)
196         {
197             ok( !strcmp( testValue, value ),
198                 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
199                 subKey2, valName, testValue, value );
200             found++;
201         }
202     }
203     ok(found,"Missing registry entry: %s in %s or %s\n",
204        valName, subKey1, (subKey2?subKey2:"<n/a>") );
205 }
206
207 #define test_reg_key( subKey, valName, testValue ) \
208     _test_reg_key( subKey, NULL, valName, testValue )
209 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
210     _test_reg_key( subKey1, subKey2, valName, testValue )
211
212 static void test_SPI_SETBEEP( void )                   /*      2 */
213 {
214     BOOL rc;
215     BOOL old_b;
216     BOOL b;
217     BOOL curr_val;
218
219     trace("testing SPI_{GET,SET}BEEP\n");
220     rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
221     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
222
223     curr_val = TRUE;
224     rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
225     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
226     test_change_message( SPI_SETBEEP, 0 );
227     test_reg_key( SPI_SETBEEP_REGKEY,
228                   SPI_SETBEEP_VALNAME,
229                   curr_val ? "Yes" : "No" );
230     rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
231     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
232     eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
233     rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
234     if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
235     {
236         ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
237         eq( b, curr_val, "SystemParametersInfoW", "%d" );
238     }
239
240     /* is a message sent for the second change? */
241     rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
242     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
243     test_change_message( SPI_SETBEEP, 0 );
244
245     curr_val = FALSE;
246     rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
247     if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
248         rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
249     ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
250     test_change_message( SPI_SETBEEP, 0 );
251     test_reg_key( SPI_SETBEEP_REGKEY,
252                   SPI_SETBEEP_VALNAME,
253                   curr_val ? "Yes" : "No" );
254     rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
255     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
256     eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
257     rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
258     if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
259     {
260         ok(rc!=0,"SystemParametersInfoW: rc=%d err=%ld\n",rc,GetLastError());
261         eq( b, curr_val, "SystemParametersInfoW", "%d" );
262     }
263     ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" );
264
265     rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
266     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
267 }
268
269 static const char *setmouse_valuenames[3] = {
270     SPI_SETMOUSE_VALNAME1,
271     SPI_SETMOUSE_VALNAME2,
272     SPI_SETMOUSE_VALNAME3
273 };
274
275 /*
276  * Runs check for one setting of spi_setmouse.
277  */
278 static void run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change,
279                                    int nchange )
280 {
281     BOOL rc;
282     INT mi[3];
283     static int aw_turn = 0;
284
285     char buf[20];
286     int i;
287
288     aw_turn++;
289     rc=0;
290     if (aw_turn % 2!=0)        /* call unicode version each second call */
291         rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
292     if (aw_turn % 2==0 || (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
293         rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
294     ok(rc!=0,"SystemParametersInfo: rc=%d err=%ld\n",rc,GetLastError());
295     test_change_message( SPI_SETMOUSE, 0 );
296     for (i = 0; i < 3; i++)
297     {
298         sprintf( buf, "%d", curr_val[i] );
299         test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
300     }
301
302     rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
303     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
304     for (i = 0; i < 3; i++)
305     {
306         ok(mi[i] == curr_val[i],
307            "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
308     }
309
310     rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
311     if (rc!=0 && GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
312     {
313         ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
314         for (i = 0; i < 3; i++)
315         {
316             ok(mi[i] == curr_val[i],
317                "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
318         }
319     }
320
321 #if 0  /* FIXME: this always fails for me  - AJ */
322     for (i = 0; i < nchange; i++)
323     {
324         POINT mv;
325         mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
326         mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
327         GetCursorPos( &mv );
328         ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load.\n" );
329         ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load.\n" );
330     }
331 #endif
332 }
333
334 static void test_SPI_SETMOUSE( void )                  /*      4 */
335 {
336     BOOL rc;
337     INT old_mi[3];
338
339     /* win nt default values - 6, 10, 1 */
340     INT curr_val[3] = {6, 10, 1};
341
342     /* requested and projected mouse movements */
343     POINT req_change[] =   { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
344     POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
345     POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
346     POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
347     POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
348     POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
349     POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
350     POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
351     POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
352
353     int nchange = sizeof( req_change ) / sizeof( POINT );
354
355     trace("testing SPI_{GET,SET}MOUSE\n");
356     rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
357     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
358
359     run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange );
360
361     /* acceleration change */
362     curr_val[2] = 2;
363     run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
364
365     /* acceleration change */
366     curr_val[2] = 3;
367     run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
368
369     /* acceleration change */
370     curr_val[2] = 0;
371     run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
372
373     /* threshold change */
374     curr_val[2] = 1;
375     curr_val[0] = 7;
376     run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
377
378     /* threshold change */
379     curr_val[2] = 2;
380     curr_val[0] = 6;
381     curr_val[1] = 6;
382     run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
383
384     /* threshold change */
385     curr_val[1] = 7;
386     run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
387
388     /* threshold change */
389     curr_val[1] = 5;
390     run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
391
392     rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
393     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
394 }
395
396 #if 0
397 static void test_setborder(UINT curr_val)
398 {
399     BOOL rc;
400     UINT border;
401     INT frame;
402     char buf[10];
403
404     rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
405     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
406     test_change_message( SPI_SETBORDER, 1 );
407     sprintf( buf, "%d", curr_val );
408     test_reg_key( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf );
409
410     if (curr_val == 0)
411         curr_val = 1;
412     rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
413     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
414     eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
415
416     frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
417     eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
418     eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
419     eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" );
420     eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" );
421 }
422
423 static void test_SPI_SETBORDER( void )                 /*      6 */
424 {
425     BOOL rc;
426     UINT old_border;
427
428     /* These tests hang when XFree86 4.0 for Windows is running (tested on
429      *  WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
430      * running.
431      */
432     if (FindWindowA( NULL, "Cygwin/XFree86" ))
433         return;
434
435     trace("testing SPI_{GET,SET}BORDER\n");
436     rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
437     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
438
439     test_setborder(1);
440     test_setborder(0);
441     test_setborder(7);
442     test_setborder(20);
443
444     /* This will restore sane values if the test hang previous run. */
445     if ( old_border == 7 || old_border == 20 )
446         old_border = -15;
447
448     rc=SystemParametersInfoA( SPI_SETBORDER, old_border, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
449     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
450 }
451 #endif
452
453 static void test_SPI_SETKEYBOARDSPEED( void )          /*     10 */
454 {
455     BOOL rc;
456     UINT old_speed;
457     const UINT vals[]={0,20,31};
458     int i;
459
460     trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
461     rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
462     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
463
464     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
465     {
466         UINT v;
467         char buf[10];
468
469         rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, vals[i], 0,
470                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
471         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
472         test_change_message( SPI_SETKEYBOARDSPEED, 0 );
473         sprintf( buf, "%d", vals[i] );
474         test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
475
476         rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &v, 0 );
477         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
478         eq( v, vals[i], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
479     }
480
481     rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
482     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
483 }
484
485 static void test_SPI_ICONHORIZONTALSPACING( void )     /*     13 */
486 {
487     BOOL rc;
488     INT old_spacing;
489     INT spacing;
490     INT curr_val;
491
492     trace("testing SPI_ICONHORIZONTALSPACING\n");
493     /* default value: 75 */
494     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
495     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
496
497     /* do not increase the value as it would upset the user's icon layout */
498     curr_val = (old_spacing > 32 ? old_spacing-1 : 32);
499     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
500                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
501     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
502     test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
503     /* The registry keys depend on the Windows version and the values too
504      * => don't test them
505      */
506
507     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
508     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
509     eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
510     eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
511
512     curr_val = 10;
513     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
514                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
515     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
516     curr_val = 32;      /*min value*/
517     test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
518
519     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
520     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
521     eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d" );
522     eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
523
524     rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE );
525     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
526 }
527
528 static void test_SPI_SETSCREENSAVETIMEOUT( void )      /*     14 */
529 {
530     BOOL rc;
531     UINT old_timeout;
532     const UINT vals[]={0,32767};
533     int i;
534
535     trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
536     rc=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
537     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
538
539     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
540     {
541         UINT v;
542         char buf[10];
543
544         rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, vals[i], 0,
545                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
546         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
547         test_change_message( SPI_SETSCREENSAVETIMEOUT, 0 );
548         sprintf( buf, "%d", vals[i] );
549         test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
550                       SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
551
552         SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &v, 0 );
553         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
554         eq( v, vals[i], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
555     }
556
557     rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
558                               SPIF_UPDATEINIFILE );
559     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
560 }
561
562 static void test_SPI_SETSCREENSAVEACTIVE( void )       /*     17 */
563 {
564     BOOL rc;
565     BOOL old_b;
566     const UINT vals[]={TRUE,FALSE};
567     int i;
568
569     trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
570     rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
571     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
572
573     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
574     {
575         UINT v;
576
577         rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, vals[i], 0,
578                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
579         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
580         test_change_message( SPI_SETSCREENSAVEACTIVE, 0 );
581         test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
582                       SPI_SETSCREENSAVEACTIVE_VALNAME,
583                       vals[i] ? "1" : "0" );
584
585         rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &v, 0 );
586         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
587         eq( v, vals[i], "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
588     }
589
590     rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
591     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
592 }
593
594 static void test_SPI_SETGRIDGRANULARITY( void )        /*     19 */
595 {
596     /* ??? */;
597 }
598
599 static void test_SPI_SETKEYBOARDDELAY( void )          /*     23 */
600 {
601     BOOL rc;
602     UINT old_delay;
603     const UINT vals[]={0,3};
604     int i;
605
606     trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
607     rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
608     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
609
610     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
611     {
612         UINT delay;
613         char buf[10];
614
615         rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, vals[i], 0,
616                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
617         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
618         test_change_message( SPI_SETKEYBOARDDELAY, 0 );
619         sprintf( buf, "%d", vals[i] );
620         test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
621                       SPI_SETKEYBOARDDELAY_VALNAME, buf );
622
623         rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
624         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
625         eq( delay, vals[i], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
626     }
627
628     rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
629     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
630 }
631
632 static void test_SPI_ICONVERTICALSPACING( void )       /*     24 */
633 {
634     BOOL rc;
635     INT old_spacing;
636     INT spacing;
637     INT curr_val;
638
639     trace("testing SPI_ICONVERTICALSPACING\n");
640     /* default value: 75 */
641     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
642     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
643
644     /* do not increase the value as it would upset the user's icon layout */
645     curr_val = old_spacing-1;
646     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
647                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
648     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
649     test_change_message( SPI_ICONVERTICALSPACING, 0 );
650     /* The registry keys depend on the Windows version and the values too
651      * => don't test them
652      */
653
654     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
655     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
656     eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
657     eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
658
659     curr_val = 10;
660     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
661                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
662     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
663     curr_val = 32;      /*min value*/
664     test_change_message( SPI_ICONVERTICALSPACING, 0 );
665
666     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
667     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
668     eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
669     eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
670
671     rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
672                               SPIF_UPDATEINIFILE );
673     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
674 }
675
676 static void test_SPI_SETICONTITLEWRAP( void )          /*     26 */
677 {
678     BOOL rc;
679     BOOL old_b;
680     const UINT vals[]={TRUE,FALSE};
681     int i;
682
683     /* These tests hang when XFree86 4.0 for Windows is running (tested on
684      * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
685      * running.
686      */
687     if (FindWindowA( NULL, "Cygwin/XFree86" ))
688         return;
689
690     trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
691     rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
692     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
693
694     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
695     {
696         UINT v;
697
698         rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0,
699                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
700         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
701         test_change_message( SPI_SETICONTITLEWRAP, 1 );
702         test_reg_key_ex( SPI_SETICONTITLEWRAP_REGKEY1,
703                          SPI_SETICONTITLEWRAP_REGKEY2,
704                          SPI_SETICONTITLEWRAP_VALNAME,
705                          vals[i] ? "1" : "0" );
706
707         rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
708         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
709         eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
710     }
711
712     rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
713     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
714 }
715
716 static void test_SPI_SETMENUDROPALIGNMENT( void )      /*     28 */
717 {
718     BOOL rc;
719     BOOL old_b;
720     const UINT vals[]={TRUE,FALSE};
721     int i;
722
723     trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
724     rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
725     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
726
727     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
728     {
729         UINT v;
730
731         rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, vals[i], 0,
732                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
733         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
734         test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
735         test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
736                          SPI_SETMENUDROPALIGNMENT_REGKEY2,
737                          SPI_SETMENUDROPALIGNMENT_VALNAME,
738                          vals[i] ? "1" : "0" );
739
740         rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
741         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
742         eq( v, vals[i], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
743         eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), (int)vals[i],
744             "SM_MENUDROPALIGNMENT", "%d" );
745     }
746
747     rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
748                               SPIF_UPDATEINIFILE );
749     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
750 }
751
752 static void test_SPI_SETDOUBLECLKWIDTH( void )         /*     29 */
753 {
754     BOOL rc;
755     INT old_width;
756     const UINT vals[]={0,10000};
757     int i;
758
759     trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
760     old_width = GetSystemMetrics( SM_CXDOUBLECLK );
761
762     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
763     {
764         char buf[10];
765
766         rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, vals[i], 0,
767                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
768         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
769         test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
770         sprintf( buf, "%d", vals[i] );
771         test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
772                          SPI_SETDOUBLECLKWIDTH_REGKEY2,
773                          SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
774         eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
775             "SM_CXDOUBLECLK", "%d" );
776     }
777
778     rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
779                               SPIF_UPDATEINIFILE );
780     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
781 }
782
783 static void test_SPI_SETDOUBLECLKHEIGHT( void )        /*     30 */
784 {
785     BOOL rc;
786     INT old_height;
787     const UINT vals[]={0,10000};
788     int i;
789
790     trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
791     old_height = GetSystemMetrics( SM_CYDOUBLECLK );
792
793     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
794     {
795         char buf[10];
796
797         rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, vals[i], 0,
798                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
799         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
800         test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
801         sprintf( buf, "%d", vals[i] );
802         test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
803                          SPI_SETDOUBLECLKHEIGHT_REGKEY2,
804                          SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
805         eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
806             "SM_CYDOUBLECLK", "%d" );
807     }
808
809     rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
810                               SPIF_UPDATEINIFILE );
811     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
812 }
813
814 static void test_SPI_SETDOUBLECLICKTIME( void )        /*     32 */
815 {
816     BOOL rc;
817     UINT curr_val;
818     UINT saved_val;
819     UINT old_time;
820     char buf[10];
821
822     trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
823     old_time = GetDoubleClickTime();
824
825     curr_val = 0;
826     rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
827                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
828     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
829     test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
830     sprintf( buf, "%d", curr_val );
831     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
832                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
833     curr_val = 500; /* used value for 0 */
834     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
835
836     curr_val = 1000;
837     rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
838                              SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
839     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
840     test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
841     sprintf( buf, "%d", curr_val );
842     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
843                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
844     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
845
846     saved_val = curr_val;
847
848     curr_val = 0;
849     SetDoubleClickTime( curr_val );
850     sprintf( buf, "%d", saved_val );
851     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
852                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
853     curr_val = 500; /* used value for 0 */
854     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
855
856     curr_val = 1000;
857     SetDoubleClickTime( curr_val );
858     sprintf( buf, "%d", saved_val );
859     test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
860                   SPI_SETDOUBLECLICKTIME_VALNAME, buf );
861     eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
862
863     rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
864     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
865 }
866
867 static void test_SPI_SETMOUSEBUTTONSWAP( void )        /*     33 */
868 {
869     BOOL rc;
870     BOOL old_b;
871     const UINT vals[]={TRUE,FALSE};
872     int i;
873
874     trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
875     old_b = GetSystemMetrics( SM_SWAPBUTTON );
876
877     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
878     {
879         rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
880                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
881         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
882         test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
883         test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
884                       SPI_SETMOUSEBUTTONSWAP_VALNAME,
885                       vals[i] ? "1" : "0" );
886         eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i],
887             "SM_SWAPBUTTON", "%d" );
888     }
889
890     rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
891                               SPIF_UPDATEINIFILE );
892     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
893 }
894
895 static void test_SPI_SETFASTTASKSWITCH( void )         /*     36 */
896 {
897     BOOL rc;
898     BOOL v;
899
900     trace("testing SPI_GETFASTTASKSWITCH\n");
901     rc=SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &v, 0 );
902     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
903     /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
904      * works. That sure simplifies testing!
905      */
906 }
907
908 static void test_SPI_SETDRAGFULLWINDOWS( void )        /*     37 */
909 {
910     BOOL rc;
911     BOOL old_b;
912     const UINT vals[]={TRUE,FALSE};
913     int i;
914
915     trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
916     rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
917     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_CALL_NOT_IMPLEMENTED))
918     {
919         /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
920         trace("SPI_{GET,SET}DRAGFULLWINDOWS not supported on this platform\n");
921         return;
922     }
923     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
924
925     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
926     {
927         UINT v;
928
929         rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, vals[i], 0,
930                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
931         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
932         test_change_message( SPI_SETDRAGFULLWINDOWS, 0 );
933         test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
934                       SPI_SETDRAGFULLWINDOWS_VALNAME,
935                       vals[i] ? "1" : "0" );
936
937         rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &v, 0 );
938         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
939         eq( v, vals[i], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
940     }
941
942     rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
943     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
944 }
945
946 static void test_SPI_SETWORKAREA( void )               /*     47 */
947 {
948     BOOL rc;
949     RECT old_area;
950     RECT area;
951     RECT curr_val;
952
953     trace("testing SPI_{GET,SET}WORKAREA\n");
954     rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
955     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
956
957     /* Modify the work area only minimally as this causes the icons that
958      * fall outside it to be moved around thus requiring the user to
959      * reposition them manually one by one.
960      * Changing the work area by just one pixel should make this occurence
961      * reasonably unlikely.
962      */
963     curr_val.left = old_area.left;
964     curr_val.top = old_area.top;
965     curr_val.right = old_area.right-1;
966     curr_val.bottom = old_area.bottom-1;
967     rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
968                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
969     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
970     test_change_message( SPI_SETWORKAREA, 0 );
971     rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
972     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
973     eq( area.left,   curr_val.left,   "left",   "%ld" );
974     eq( area.top,    curr_val.top,    "top",    "%ld" );
975     eq( area.right,  curr_val.right,  "right",  "%ld" );
976     eq( area.bottom, curr_val.bottom, "bottom", "%ld" );
977
978     rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area,
979                               SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
980     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
981     test_change_message( SPI_SETWORKAREA, 0 );
982     rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
983     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
984     eq( area.left,   old_area.left,   "left",   "%ld" );
985     eq( area.top,    old_area.top,    "top",    "%ld" );
986     eq( area.right,  old_area.right,  "right",  "%ld" );
987     eq( area.bottom, old_area.bottom, "bottom", "%ld" );
988 }
989
990 static void test_SPI_SETSHOWSOUNDS( void )             /*     57 */
991 {
992     BOOL rc;
993     BOOL old_b;
994     const UINT vals[]={TRUE,FALSE};
995     int i;
996
997     trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
998     SetLastError(0);
999     rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
1000     if (rc==0 && GetLastError()==0)
1001     {
1002         /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1003         trace("SPI_{GET,SET}SHOWSOUNDS not supported on this platform\n");
1004         return;
1005     }
1006     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1007
1008     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1009     {
1010         UINT v;
1011
1012         rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, vals[i], 0,
1013                                   SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1014         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1015         test_change_message( SPI_SETSHOWSOUNDS, 0 );
1016         test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
1017                       SPI_SETSHOWSOUNDS_VALNAME,
1018                       vals[i] ? "1" : "0" );
1019
1020         rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &v, 0 );
1021         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1022         eq( v, vals[i], "SPI_GETSHOWSOUNDS", "%d" );
1023         eq( GetSystemMetrics( SM_SHOWSOUNDS ), (int)vals[i],
1024             "SM_SHOWSOUNDS", "%d" );
1025     }
1026
1027     rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
1028     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1029 }
1030
1031 static void test_SPI_SETKEYBOARDPREF( void )           /*     69 */
1032 {
1033     /* TODO!!! - don't have version of Windows which has this */
1034 }
1035
1036 static void test_SPI_SETSCREENREADER( void )           /*     71 */
1037 {
1038     /* TODO!!! - don't have version of Windows which has this */
1039 }
1040
1041 static void test_SPI_SETMOUSEHOVERWIDTH( void )      /*     99 */
1042 {
1043     BOOL rc;
1044     UINT old_width;
1045     const UINT vals[]={0,32767};
1046     int i;
1047
1048     trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n");
1049     rc=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &old_width, 0 );
1050     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1051     {
1052         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1053          * what MSDN states (Verified on Win98SE)
1054          */
1055         trace("SPI_{GET,SET}MOUSEHOVERWIDTH not supported on this platform\n");
1056         return;
1057     }
1058     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1059     
1060     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1061     {
1062         UINT v;
1063         char buf[10];
1064
1065         rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, vals[i], 0,
1066                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1067         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1068         test_change_message( SPI_SETMOUSEHOVERWIDTH, 0 );
1069         sprintf( buf, "%d", vals[i] );
1070         test_reg_key( SPI_SETMOUSEHOVERWIDTH_REGKEY,
1071                       SPI_SETMOUSEHOVERWIDTH_VALNAME, buf );
1072
1073         SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &v, 0 );
1074         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1075         eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERWIDTH", "%d" );
1076     }
1077
1078     rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, old_width, 0,
1079                               SPIF_UPDATEINIFILE );
1080     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1081 }
1082
1083 static void test_SPI_SETMOUSEHOVERHEIGHT( void )      /*     101 */
1084 {
1085     BOOL rc;
1086     UINT old_height;
1087     const UINT vals[]={0,32767};
1088     int i;
1089
1090     trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n");
1091     rc=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &old_height, 0 );
1092     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1093     {
1094         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1095          * what MSDN states (Verified on Win98SE)
1096          */
1097         trace("SPI_{GET,SET}MOUSEHOVERHEIGHT not supported on this platform\n");
1098         return;
1099     }
1100     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1101     
1102     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1103     {
1104         UINT v;
1105         char buf[10];
1106
1107         rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, vals[i], 0,
1108                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1109         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1110         test_change_message( SPI_SETMOUSEHOVERHEIGHT, 0 );
1111         sprintf( buf, "%d", vals[i] );
1112         test_reg_key( SPI_SETMOUSEHOVERHEIGHT_REGKEY,
1113                       SPI_SETMOUSEHOVERHEIGHT_VALNAME, buf );
1114
1115         SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &v, 0 );
1116         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1117         eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERHEIGHT", "%d" );
1118     }
1119
1120     rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, old_height, 0,
1121                               SPIF_UPDATEINIFILE );
1122     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1123 }
1124
1125 static void test_SPI_SETMOUSEHOVERTIME( void )      /*     103 */
1126 {
1127     BOOL rc;
1128     UINT old_time;
1129     const UINT vals[]={0,32767};
1130     int i;
1131
1132     trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n");
1133     rc=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &old_time, 0 );
1134     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1135     {
1136         /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
1137          * what MSDN states (Verified on Win98SE)
1138          */
1139         trace("SPI_{GET,SET}MOUSEHOVERTIME not supported on this platform\n");
1140         return;
1141     }
1142     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1143     
1144     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1145     {
1146         UINT v;
1147         char buf[10];
1148
1149         rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, vals[i], 0,
1150                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1151         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1152         test_change_message( SPI_SETMOUSEHOVERTIME, 0 );
1153         sprintf( buf, "%d", vals[i] );
1154         test_reg_key( SPI_SETMOUSEHOVERTIME_REGKEY,
1155                       SPI_SETMOUSEHOVERTIME_VALNAME, buf );
1156
1157         SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &v, 0 );
1158         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1159         eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERTIME", "%d" );
1160     }
1161
1162     rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, old_time, 0,
1163                               SPIF_UPDATEINIFILE );
1164     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1165 }
1166
1167 static void test_SPI_SETWHEELSCROLLLINES( void )      /*     105 */
1168 {
1169     BOOL rc;
1170     UINT old_lines;
1171     const UINT vals[]={0,32767};
1172     int i;
1173
1174     trace("testing SPI_{GET,SET}WHEELSCROLLLINES\n");
1175     rc=SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &old_lines, 0 );
1176     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1177
1178     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1179     {
1180         UINT v;
1181         char buf[10];
1182
1183         rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, vals[i], 0,
1184                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1185         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1186         test_change_message( SPI_SETWHEELSCROLLLINES, 0 );
1187         sprintf( buf, "%d", vals[i] );
1188         test_reg_key( SPI_SETMOUSESCROLLLINES_REGKEY,
1189                       SPI_SETMOUSESCROLLLINES_VALNAME, buf );
1190
1191         SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &v, 0 );
1192         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1193         eq( v, vals[i], "SPI_{GET,SET}MOUSESCROLLLINES", "%d" );
1194     }
1195
1196     rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, old_lines, 0,
1197                               SPIF_UPDATEINIFILE );
1198     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1199 }
1200
1201 static void test_SPI_SETMENUSHOWDELAY( void )      /*     107 */
1202 {
1203     BOOL rc;
1204     UINT old_delay;
1205     const UINT vals[]={0,32767};
1206     int i;
1207
1208     trace("testing SPI_{GET,SET}MENUSHOWDELAY\n");
1209     rc=SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &old_delay, 0 );
1210     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1211
1212     for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1213     {
1214         UINT v;
1215         char buf[10];
1216
1217         rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, vals[i], 0,
1218                                SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1219         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1220         test_change_message( SPI_SETMENUSHOWDELAY, 0 );
1221         sprintf( buf, "%d", vals[i] );
1222         test_reg_key( SPI_SETMENUSHOWDELAY_REGKEY,
1223                       SPI_SETMENUSHOWDELAY_VALNAME, buf );
1224
1225         SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &v, 0 );
1226         ok(rc!=0,"%d: rc=%d err=%ld\n",i,rc,GetLastError());
1227         eq( v, vals[i], "SPI_{GET,SET}MENUSHOWDELAY", "%d" );
1228     }
1229
1230     rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, old_delay, 0,
1231                               SPIF_UPDATEINIFILE );
1232     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1233 }
1234
1235 static void test_SPI_SETWALLPAPER( void )              /*   115 */
1236 {
1237     BOOL rc;
1238     char oldval[260];
1239     char newval[260];
1240
1241     trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
1242     SetLastError(0);
1243     rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
1244     if (rc==0 && (GetLastError()==0 || GetLastError()==ERROR_INVALID_SPI_VALUE))
1245     {
1246         /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
1247          * unimplemented on NT4
1248          */
1249         trace("SPI_{GET,SET}DESKWALLPAPER not supported on this platform\n");
1250         return;
1251     }
1252     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1253
1254     strcpy(newval, "");
1255     rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1256     ok(rc!=0,"SystemParametersInfoA: rc=%d err=%ld\n",rc,GetLastError());
1257     test_change_message(SPI_SETDESKWALLPAPER, 0);
1258
1259     rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
1260     ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%ld\n",rc,GetLastError());
1261
1262     test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
1263 }
1264
1265 /*
1266  * Registry entries for the system parameters.
1267  * Names are created by 'SET' flags names.
1268  * We assume that corresponding 'GET' entries use the same registry keys.
1269  */
1270 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
1271 {
1272     test_SPI_SETBEEP();                         /*      1 */
1273     test_SPI_SETMOUSE();                        /*      4 */
1274     /* Messes up systems settings on Win9x */
1275     /*test_SPI_SETBORDER();*/                   /*      6 */
1276     test_SPI_SETKEYBOARDSPEED();                /*     10 */
1277     test_SPI_ICONHORIZONTALSPACING();           /*     13 */
1278     test_SPI_SETSCREENSAVETIMEOUT();            /*     14 */
1279     test_SPI_SETSCREENSAVEACTIVE();             /*     17 */
1280     test_SPI_SETGRIDGRANULARITY();              /*     19 */
1281     test_SPI_SETKEYBOARDDELAY();                /*     23 */
1282     test_SPI_ICONVERTICALSPACING();             /*     24 */
1283     test_SPI_SETICONTITLEWRAP();                /*     26 */
1284     test_SPI_SETMENUDROPALIGNMENT();            /*     28 */
1285     test_SPI_SETDOUBLECLKWIDTH();               /*     29 */
1286     test_SPI_SETDOUBLECLKHEIGHT();              /*     30 */
1287     test_SPI_SETDOUBLECLICKTIME();              /*     32 */
1288     test_SPI_SETMOUSEBUTTONSWAP();              /*     33 */
1289     test_SPI_SETFASTTASKSWITCH();               /*     36 */
1290     test_SPI_SETDRAGFULLWINDOWS();              /*     37 */
1291     test_SPI_SETWORKAREA();                     /*     47 */
1292     test_SPI_SETSHOWSOUNDS();                   /*     57 */
1293     test_SPI_SETKEYBOARDPREF();                 /*     69 */
1294     test_SPI_SETSCREENREADER();                 /*     71 */
1295     test_SPI_SETMOUSEHOVERWIDTH();              /*     99 */
1296     test_SPI_SETMOUSEHOVERHEIGHT();             /*    101 */
1297     test_SPI_SETMOUSEHOVERTIME();               /*    103 */
1298     test_SPI_SETWHEELSCROLLLINES();             /*    105 */
1299     test_SPI_SETMENUSHOWDELAY();                /*    107 */
1300     test_SPI_SETWALLPAPER();                    /*    115 */
1301     SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
1302     return 0;
1303 }
1304
1305 START_TEST(sysparams)
1306 {
1307     int argc;
1308     char** argv;
1309     WNDCLASSA wc;
1310     MSG msg;
1311     HANDLE hThread;
1312     DWORD dwThreadId;
1313     HANDLE hInstance = GetModuleHandleA( NULL );
1314
1315     argc = winetest_get_mainargs(&argv);
1316     strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
1317     trace("strict=%d\n",strict);
1318
1319     change_counter = 0;
1320     change_last_param = 0;
1321
1322     wc.lpszClassName = "SysParamsTestClass";
1323     wc.lpfnWndProc = SysParamsTestWndProc;
1324     wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
1325     wc.hInstance = hInstance;
1326     wc.hIcon = LoadIconA( 0, (LPSTR)IDI_APPLICATION );
1327     wc.hCursor = LoadCursorA( 0, (LPSTR)IDC_ARROW );
1328     wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1 );
1329     wc.lpszMenuName = 0;
1330     wc.cbClsExtra = 0;
1331     wc.cbWndExtra = 0;
1332     RegisterClassA( &wc );
1333
1334     ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
1335                                WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
1336
1337     hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
1338     assert( hThread );
1339     CloseHandle( hThread );
1340
1341     while( GetMessageA( &msg, 0, 0, 0 )) {
1342         TranslateMessage( &msg );
1343         DispatchMessageA( &msg );
1344     }
1345 }