3a77134e7c4c0971ffb63d2edca8fc9ad79dc23c
[reactos.git] / rostests / winetests / user32 / 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 */
19
20 #include <assert.h>
21 #include <stdlib.h>
22 #include <stdarg.h>
23 #include <stdio.h>
24
25 #undef _WIN32_WINNT
26 #define _WIN32_WINNT 0x0600 /* For SPI_GETMOUSEHOVERWIDTH and more */
27 //#define _WIN32_IE 0x0700
28 #undef WINVER
29 #define WINVER 0x0600 /* For COLOR_MENUBAR, NONCLIENTMETRICS with padding */
30
31 #include "wine/test.h"
32 #include "windef.h"
33 #include "winbase.h"
34 #include "wingdi.h"
35 #include "winreg.h"
36 #include "winuser.h"
37 #include "winnls.h"
38
39 #ifndef SPI_GETDESKWALLPAPER
40 # define SPI_GETDESKWALLPAPER 0x0073
41 #endif
42
43 static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID);
44
45 static int strict;
46 static int dpi;
47 static int iswin9x;
48 static HDC hdc;
49
50 #define eq(received, expected, label, type) \
51 ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
52
53
54 #define SPI_SETBEEP_REGKEY "Control Panel\\Sound"
55 #define SPI_SETBEEP_VALNAME "Beep"
56 #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse"
57 #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1"
58 #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2"
59 #define SPI_SETMOUSE_VALNAME3 "MouseSpeed"
60 #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics"
61 #define SPI_SETBORDER_REGKEY2 "Control Panel\\Desktop"
62 #define SPI_SETBORDER_VALNAME "BorderWidth"
63 #define SPI_METRIC_REGKEY "Control Panel\\Desktop\\WindowMetrics"
64 #define SPI_SCROLLWIDTH_VALNAME "ScrollWidth"
65 #define SPI_SCROLLHEIGHT_VALNAME "ScrollHeight"
66 #define SPI_CAPTIONWIDTH_VALNAME "CaptionWidth"
67 #define SPI_CAPTIONHEIGHT_VALNAME "CaptionHeight"
68 #define SPI_CAPTIONFONT_VALNAME "CaptionFont"
69 #define SPI_SMCAPTIONWIDTH_VALNAME "SmCaptionWidth"
70 #define SPI_SMCAPTIONHEIGHT_VALNAME "SmCaptionHeight"
71 #define SPI_SMCAPTIONFONT_VALNAME "SmCaptionFont"
72 #define SPI_MENUWIDTH_VALNAME "MenuWidth"
73 #define SPI_MENUHEIGHT_VALNAME "MenuHeight"
74 #define SPI_MENUFONT_VALNAME "MenuFont"
75 #define SPI_STATUSFONT_VALNAME "StatusFont"
76 #define SPI_MESSAGEFONT_VALNAME "MessageFont"
77
78 #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard"
79 #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed"
80 #define SPI_ICONHORIZONTALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics"
81 #define SPI_ICONHORIZONTALSPACING_REGKEY2 "Control Panel\\Desktop"
82 #define SPI_ICONHORIZONTALSPACING_VALNAME "IconSpacing"
83 #define SPI_ICONVERTICALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics"
84 #define SPI_ICONVERTICALSPACING_REGKEY2 "Control Panel\\Desktop"
85 #define SPI_ICONVERTICALSPACING_VALNAME "IconVerticalSpacing"
86 #define SPI_MINIMIZEDMETRICS_REGKEY "Control Panel\\Desktop\\WindowMetrics"
87 #define SPI_MINWIDTH_VALNAME "MinWidth"
88 #define SPI_MINHORZGAP_VALNAME "MinHorzGap"
89 #define SPI_MINVERTGAP_VALNAME "MinVertGap"
90 #define SPI_MINARRANGE_VALNAME "MinArrange"
91 #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop"
92 #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut"
93 #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop"
94 #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive"
95 #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop"
96 #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity"
97 #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard"
98 #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay"
99 #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics"
100 #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop"
101 #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap"
102 #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
103 #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop"
104 #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment"
105 #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse"
106 #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop"
107 #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth"
108 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse"
109 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop"
110 #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight"
111 #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse"
112 #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed"
113 #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse"
114 #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons"
115 #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop"
116 #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
117 #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
118 #define SPI_SETSHOWSOUNDS_VALNAME "On"
119 #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Accessibility\\Keyboard Preference"
120 #define SPI_SETKEYBOARDPREF_VALNAME "On"
121 #define SPI_SETKEYBOARDPREF_REGKEY_LEGACY "Control Panel\\Accessibility"
122 #define SPI_SETKEYBOARDPREF_VALNAME_LEGACY "Keyboard Preference"
123 #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Accessibility\\Blind Access"
124 #define SPI_SETSCREENREADER_VALNAME "On"
125 #define SPI_SETSCREENREADER_REGKEY_LEGACY "Control Panel\\Accessibility"
126 #define SPI_SETSCREENREADER_VALNAME_LEGACY "Blind Access"
127 #define SPI_SETFONTSMOOTHING_REGKEY "Control Panel\\Desktop"
128 #define SPI_SETFONTSMOOTHING_VALNAME "FontSmoothing"
129 #define SPI_SETFONTSMOOTHINGTYPE_VALNAME "FontSmoothingType"
130 #define SPI_SETFONTSMOOTHINGCONTRAST_VALNAME "FontSmoothingGamma"
131 #define SPI_SETFONTSMOOTHINGORIENTATION_VALNAME "FontSmoothingOrientation"
132 #define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop"
133 #define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive"
134 #define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop"
135 #define SPI_SETPOWEROFFACTIVE_VALNAME "PowerOffActive"
136 #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
137 #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
138 #define SPI_SETSNAPTODEFBUTTON_REGKEY "Control Panel\\Mouse"
139 #define SPI_SETSNAPTODEFBUTTON_VALNAME "SnapToDefaultButton"
140 #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse"
141 #define SPI_SETMOUSEHOVERWIDTH_VALNAME "MouseHoverWidth"
142 #define SPI_SETMOUSEHOVERHEIGHT_REGKEY "Control Panel\\Mouse"
143 #define SPI_SETMOUSEHOVERHEIGHT_VALNAME "MouseHoverHeight"
144 #define SPI_SETMOUSEHOVERTIME_REGKEY "Control Panel\\Mouse"
145 #define SPI_SETMOUSEHOVERTIME_VALNAME "MouseHoverTime"
146 #define SPI_SETMOUSESCROLLCHARS_REGKEY "Control Panel\\Desktop"
147 #define SPI_SETMOUSESCROLLCHARS_VALNAME "WheelScrollChars"
148 #define SPI_SETMOUSESCROLLLINES_REGKEY "Control Panel\\Desktop"
149 #define SPI_SETMOUSESCROLLLINES_VALNAME "WheelScrollLines"
150 #define SPI_SETMENUSHOWDELAY_REGKEY "Control Panel\\Desktop"
151 #define SPI_SETMENUSHOWDELAY_VALNAME "MenuShowDelay"
152 #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop"
153 #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper"
154
155 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
156 #define WINE_CURRENT_USER_REGKEY "Wine"
157
158 static HWND ghTestWnd;
159
160 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam );
161 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
162 LPARAM lParam );
163 static int change_counter;
164 static int change_setworkarea_param, change_iconverticalspacing_param;
165 static int change_last_param;
166 static int last_bpp;
167 static BOOL displaychange_ok = FALSE, displaychange_test_active = FALSE;
168 static HANDLE displaychange_sem = 0;
169
170 static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam,
171 LPARAM lParam )
172 {
173 switch (msg) {
174
175 case WM_DISPLAYCHANGE:
176 ok(displaychange_ok, "Unexpected WM_DISPLAYCHANGE message\n");
177 last_bpp = wParam;
178 displaychange_ok = FALSE;
179 ReleaseSemaphore(displaychange_sem, 1, 0);
180 break;
181
182 case WM_SETTINGCHANGE:
183 if (change_counter>0) {
184 /* ignore these messages caused by resizing of toolbars */
185 if( wParam == SPI_SETWORKAREA){
186 change_setworkarea_param = 1;
187 break;
188 } else if( wParam == SPI_ICONVERTICALSPACING) {
189 change_iconverticalspacing_param = 1;
190 break;
191 } else if( displaychange_test_active)
192 break;
193 if( !change_last_param){
194 change_last_param = wParam;
195 break;
196 }
197 ok(0,"too many changes counter=%d last change=%d\n",
198 change_counter,change_last_param);
199 change_counter++;
200 change_last_param = wParam;
201 break;
202 }
203 change_counter++;
204 change_last_param = change_setworkarea_param = change_iconverticalspacing_param =0;
205 if( wParam == SPI_SETWORKAREA)
206 change_setworkarea_param = 1;
207 else if( wParam == SPI_ICONVERTICALSPACING)
208 change_iconverticalspacing_param = 1;
209 else
210 change_last_param = wParam;
211 break;
212
213 case WM_DESTROY:
214 PostQuitMessage( 0 );
215 break;
216
217 /* drop through */
218 default:
219 return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
220 }
221
222 return 0;
223 }
224
225 /*
226 Performs testing for system parameters messages
227 params:
228 - system parameter id
229 - supposed value of the registry key
230 */
231 static void test_change_message( int action, int optional )
232 {
233 if (change_counter==0 && optional==1)
234 return;
235 ok( 1 == change_counter,
236 "Missed a message: change_counter=%d\n", change_counter );
237 change_counter = 0;
238 ok( action == change_last_param ||
239 ( change_setworkarea_param && action == SPI_SETWORKAREA) ||
240 ( change_iconverticalspacing_param && action == SPI_ICONVERTICALSPACING),
241 "Wrong action got %d expected %d\n", change_last_param, action );
242 change_last_param = 0;
243 }
244
245 static BOOL test_error_msg ( int rc, const char *name )
246 {
247 DWORD last_error = GetLastError();
248
249 if (rc==0)
250 {
251 if (last_error==0xdeadbeef || last_error==ERROR_INVALID_SPI_VALUE || last_error==ERROR_INVALID_PARAMETER)
252 {
253 skip("%s not supported on this platform\n", name);
254 }
255 else if (last_error==ERROR_ACCESS_DENIED)
256 {
257 skip("%s does not have privileges to run\n", name);
258 }
259 else
260 {
261 trace("%s failed for reason: %d. Indicating test failure and skipping remainder of test\n",name,last_error);
262 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,last_error);
263 }
264 return FALSE;
265 }
266 else
267 {
268 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,last_error);
269 return TRUE;
270 }
271 }
272
273 /*
274 * Tests the HKEY_CURRENT_USER subkey value.
275 * The value should contain string value.
276 */
277 static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCSTR valName2,
278 const void *exp_value, DWORD exp_type, BOOL optional )
279 {
280 CHAR value[MAX_PATH];
281 DWORD valueLen;
282 DWORD type;
283 HKEY hKey;
284 LONG rc;
285 int found=0;
286
287 *value='\0';
288 valueLen=sizeof(value);
289 RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
290 rc=RegQueryValueExA( hKey, valName1, NULL, &type, (LPBYTE)value, &valueLen );
291 RegCloseKey( hKey );
292 if (rc==ERROR_SUCCESS)
293 {
294 ok( type == exp_type, "wrong type %u/%u\n", type, exp_type );
295 switch (exp_type)
296 {
297 case REG_DWORD:
298 ok( *(DWORD *)value == *(DWORD *)exp_value,
299 "Wrong value in registry: %s %s %08x/%08x\n",
300 subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value );
301 break;
302 case REG_SZ:
303 ok( !strcmp( exp_value, value ),
304 "Wrong value in registry: %s %s '%s' instead of '%s'\n",
305 subKey1, valName1, value, (const char *)exp_value );
306 break;
307 }
308 found++;
309 }
310 else if (strict)
311 {
312 ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
313 subKey1, valName1);
314 }
315 if (valName2)
316 {
317 *value='\0';
318 valueLen=sizeof(value);
319 RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey );
320 rc=RegQueryValueExA( hKey, valName2, NULL, &type, (LPBYTE)value, &valueLen );
321 RegCloseKey( hKey );
322 if (rc==ERROR_SUCCESS)
323 {
324 ok( type == exp_type, "wrong type %u/%u\n", type, exp_type );
325 switch (exp_type)
326 {
327 case REG_DWORD:
328 ok( *(DWORD *)value == *(DWORD *)exp_value,
329 "Wrong value in registry: %s %s %08x/%08x\n",
330 subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value );
331 break;
332 case REG_SZ:
333 ok( !strcmp( exp_value, value ),
334 "Wrong value in registry: %s %s '%s' instead of '%s'\n",
335 subKey1, valName1, value, (const char *)exp_value );
336 break;
337 }
338 found++;
339 }
340 else if (strict)
341 {
342 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
343 subKey1, valName2 );
344 }
345 }
346 if (subKey2 && !strict)
347 {
348 *value='\0';
349 valueLen=sizeof(value);
350 RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
351 rc=RegQueryValueExA( hKey, valName1, NULL, &type, (LPBYTE)value, &valueLen );
352 RegCloseKey( hKey );
353 if (rc==ERROR_SUCCESS)
354 {
355 ok( type == exp_type, "wrong type %u/%u\n", type, exp_type );
356 switch (exp_type)
357 {
358 case REG_DWORD:
359 ok( *(DWORD *)value == *(DWORD *)exp_value,
360 "Wrong value in registry: %s %s %08x/%08x\n",
361 subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value );
362 break;
363 case REG_SZ:
364 ok( !strcmp( exp_value, value ),
365 "Wrong value in registry: %s %s '%s' instead of '%s'\n",
366 subKey1, valName1, value, (const char *)exp_value );
367 break;
368 }
369 found++;
370 }
371 else if (strict)
372 {
373 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
374 subKey2, valName1 );
375 }
376 if (valName2)
377 {
378 *value='\0';
379 valueLen=sizeof(value);
380 RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey );
381 rc=RegQueryValueExA( hKey, valName2, NULL, &type, (LPBYTE)value, &valueLen );
382 RegCloseKey( hKey );
383 if (rc==ERROR_SUCCESS)
384 {
385 ok( type == exp_type, "wrong type %u/%u\n", type, exp_type );
386 switch (exp_type)
387 {
388 case REG_DWORD:
389 ok( *(DWORD *)value == *(DWORD *)exp_value,
390 "Wrong value in registry: %s %s %08x/%08x\n",
391 subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value );
392 break;
393 case REG_SZ:
394 ok( !strcmp( exp_value, value ),
395 "Wrong value in registry: %s %s '%s' instead of '%s'\n",
396 subKey1, valName1, value, (const char *)exp_value );
397 break;
398 }
399 found++;
400 }
401 else if (strict)
402 {
403 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
404 subKey2, valName2 );
405 }
406 }
407 }
408 ok(found || optional,
409 "Missing registry values: %s or %s in keys: %s or %s\n",
410 valName1, (valName2?valName2:"<n/a>"), subKey1, (subKey2?subKey2:"<n/a>") );
411 }
412
413 #define test_reg_key( subKey, valName, testValue ) \
414 _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, FALSE )
415 #define test_reg_key_optional( subKey, valName, testValue ) \
416 _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, TRUE )
417 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
418 _test_reg_key( subKey1, subKey2, valName, NULL, testValue, REG_SZ, FALSE )
419 #define test_reg_key_ex2( subKey1, subKey2, valName1, valName2, testValue ) \
420 _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, FALSE )
421 #define test_reg_key_ex2_optional( subKey1, subKey2, valName1, valName2, testValue ) \
422 _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, TRUE )
423 #define test_reg_key_dword( subKey, valName, testValue ) \
424 _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_DWORD, FALSE )
425
426 /* get a metric from the registry. If the value is negative
427 * it is assumed to be in twips and converted to pixels */
428 static UINT metricfromreg( const char *keyname, const char *valname, int dpi)
429 {
430 HKEY hkey;
431 char buf[64];
432 DWORD ret;
433 DWORD size, type;
434 int value;
435
436 RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey );
437 size = sizeof(buf);
438 ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)buf, &size );
439 RegCloseKey( hkey );
440 if( ret != ERROR_SUCCESS) return -1;
441 value = atoi( buf);
442 if( value < 0)
443 value = ( -value * dpi + 720) / 1440;
444 return value;
445 }
446
447 typedef struct
448 {
449 INT16 lfHeight;
450 INT16 lfWidth;
451 INT16 lfEscapement;
452 INT16 lfOrientation;
453 INT16 lfWeight;
454 BYTE lfItalic;
455 BYTE lfUnderline;
456 BYTE lfStrikeOut;
457 BYTE lfCharSet;
458 BYTE lfOutPrecision;
459 BYTE lfClipPrecision;
460 BYTE lfQuality;
461 BYTE lfPitchAndFamily;
462 CHAR lfFaceName[LF_FACESIZE];
463 } LOGFONT16, *LPLOGFONT16;
464
465 /* get logfont from the registry */
466 static int lffromreg( const char *keyname, const char *valname, LOGFONTA *plf)
467 {
468 HKEY hkey;
469 LOGFONTW lfw;
470 DWORD ret, size, type;
471
472 RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey );
473 size = sizeof( lfw);
474 ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)&lfw, &size );
475 RegCloseKey( hkey );
476 ok( ret == ERROR_SUCCESS, "Key \"%s\" value \"%s\" not found\n", keyname, valname);
477 if( ret != ERROR_SUCCESS)
478 return FALSE;
479 if( size <= sizeof( LOGFONT16)) {
480 LOGFONT16 *plf16 = (LOGFONT16*) &lfw;
481 plf->lfHeight = plf16->lfHeight;
482 plf->lfWidth = plf16->lfWidth;
483 plf->lfEscapement = plf16->lfEscapement;
484 plf->lfOrientation = plf16->lfOrientation;
485 plf->lfWeight = plf16->lfWeight;
486 plf->lfItalic = plf16->lfItalic;
487 plf->lfUnderline = plf16->lfUnderline;
488 plf->lfStrikeOut = plf16->lfStrikeOut;
489 plf->lfCharSet = plf16->lfCharSet;
490 plf->lfOutPrecision = plf16->lfOutPrecision;
491 plf->lfClipPrecision = plf16->lfClipPrecision;
492 plf->lfQuality = plf16->lfQuality;
493 plf->lfPitchAndFamily = plf16->lfPitchAndFamily;
494 memcpy( plf->lfFaceName, plf16->lfFaceName, LF_FACESIZE );
495 } else if( size <= sizeof( LOGFONTA)) {
496 plf = (LOGFONTA*) &lfw;
497 } else {
498 plf->lfHeight = lfw.lfHeight;
499 plf->lfWidth = lfw.lfWidth;
500 plf->lfEscapement = lfw.lfEscapement;
501 plf->lfOrientation = lfw.lfOrientation;
502 plf->lfWeight = lfw.lfWeight;
503 plf->lfItalic = lfw.lfItalic;
504 plf->lfUnderline = lfw.lfUnderline;
505 plf->lfStrikeOut = lfw.lfStrikeOut;
506 plf->lfCharSet = lfw.lfCharSet;
507 plf->lfOutPrecision = lfw.lfOutPrecision;
508 plf->lfClipPrecision = lfw.lfClipPrecision;
509 plf->lfQuality = lfw.lfQuality;
510 plf->lfPitchAndFamily = lfw.lfPitchAndFamily;
511 WideCharToMultiByte( CP_ACP, 0, lfw.lfFaceName, -1, plf->lfFaceName,
512 LF_FACESIZE, NULL, NULL);
513
514 }
515 return TRUE;
516 }
517
518 static void test_SPI_SETBEEP( void ) /* 2 */
519 {
520 BOOL rc;
521 BOOL old_b;
522 BOOL b;
523 BOOL curr_val;
524
525 trace("testing SPI_{GET,SET}BEEP\n");
526 SetLastError(0xdeadbeef);
527 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 );
528 if (!test_error_msg(rc,"SPI_{GET,SET}BEEP"))
529 return;
530
531 curr_val = TRUE;
532 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
533 if (!test_error_msg(rc,"SPI_SETBEEP")) return;
534 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
535 test_change_message( SPI_SETBEEP, 0 );
536 test_reg_key( SPI_SETBEEP_REGKEY,
537 SPI_SETBEEP_VALNAME,
538 curr_val ? "Yes" : "No" );
539 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
540 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
541 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
542 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
543 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
544 {
545 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc,GetLastError());
546 eq( b, curr_val, "SystemParametersInfoW", "%d" );
547 }
548
549 /* is a message sent for the second change? */
550 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
551 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
552 test_change_message( SPI_SETBEEP, 0 );
553
554 curr_val = FALSE;
555 rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
556 if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
557 rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
558 ok(rc!=0,"SystemParametersInfo: rc=%d err=%d\n",rc,GetLastError());
559 test_change_message( SPI_SETBEEP, 0 );
560 test_reg_key( SPI_SETBEEP_REGKEY,
561 SPI_SETBEEP_VALNAME,
562 curr_val ? "Yes" : "No" );
563 rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 );
564 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
565 eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" );
566 rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 );
567 if (rc!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED)
568 {
569 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc,GetLastError());
570 eq( b, curr_val, "SystemParametersInfoW", "%d" );
571 }
572 ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" );
573
574 rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE );
575 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
576 }
577
578 static const char *setmouse_valuenames[3] = {
579 SPI_SETMOUSE_VALNAME1,
580 SPI_SETMOUSE_VALNAME2,
581 SPI_SETMOUSE_VALNAME3
582 };
583
584 /*
585 * Runs check for one setting of spi_setmouse.
586 */
587 static BOOL run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change, int nchange )
588 {
589 BOOL rc;
590 INT mi[3];
591 static int aw_turn = 0;
592 static BOOL w_implemented = 1;
593
594 char buf[20];
595 int i;
596
597 aw_turn++;
598 rc=0;
599 if ((aw_turn % 2!=0) && (w_implemented))
600 {
601 /* call unicode on odd (non even) calls */
602 SetLastError(0xdeadbeef);
603 rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
604 if (rc==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
605 {
606 w_implemented = 0;
607 trace("SystemParametersInfoW not supported on this platform\n");
608 }
609 }
610
611 if ((aw_turn % 2==0) || (!w_implemented))
612 {
613 /* call ascii version on even calls or if unicode is not available */
614 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
615 }
616 if (!test_error_msg(rc,"SPI_SETMOUSE")) return FALSE;
617
618 ok(rc!=0,"SystemParametersInfo: rc=%d err=%d\n",rc,GetLastError());
619 test_change_message( SPI_SETMOUSE, 0 );
620 for (i = 0; i < 3; i++)
621 {
622 sprintf( buf, "%d", curr_val[i] );
623 test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf );
624 }
625
626 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 );
627 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
628 for (i = 0; i < 3; i++)
629 {
630 ok(mi[i] == curr_val[i],
631 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
632 }
633
634 if (w_implemented)
635 {
636 rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 );
637 ok(rc!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc,GetLastError());
638 for (i = 0; i < 3; i++)
639 {
640 ok(mi[i] == curr_val[i],
641 "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]);
642 }
643 }
644
645 if (0)
646 {
647 /* FIXME: this always fails for me - AJ */
648 for (i = 0; i < nchange; i++)
649 {
650 POINT mv;
651 mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 );
652 mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 );
653 GetCursorPos( &mv );
654 ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load.\n" );
655 ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load.\n" );
656 }
657 }
658 return TRUE;
659 }
660
661 static void test_SPI_SETMOUSE( void ) /* 4 */
662 {
663 BOOL rc;
664 INT old_mi[3];
665
666 /* win nt default values - 6, 10, 1 */
667 INT curr_val[3] = {6, 10, 1};
668
669 /* requested and projected mouse movements */
670 POINT req_change[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
671 POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
672 POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
673 POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
674 POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
675 POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
676 POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
677 POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
678 POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
679
680 int nchange = sizeof( req_change ) / sizeof( POINT );
681
682 trace("testing SPI_{GET,SET}MOUSE\n");
683 SetLastError(0xdeadbeef);
684 rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 );
685 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSE"))
686 return;
687
688 if (!run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange )) return;
689
690 /* acceleration change */
691 curr_val[2] = 2;
692 run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange );
693
694 /* acceleration change */
695 curr_val[2] = 3;
696 run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange );
697
698 /* acceleration change */
699 curr_val[2] = 0;
700 run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange );
701
702 /* threshold change */
703 curr_val[2] = 1;
704 curr_val[0] = 7;
705 run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange );
706
707 /* threshold change */
708 curr_val[2] = 2;
709 curr_val[0] = 6;
710 curr_val[1] = 6;
711 run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange );
712
713 /* threshold change */
714 curr_val[1] = 7;
715 run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange );
716
717 /* threshold change */
718 curr_val[1] = 5;
719 run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange );
720
721 rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE );
722 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
723 }
724
725 static BOOL test_setborder(UINT curr_val, int usesetborder, int dpi)
726 {
727 BOOL rc;
728 UINT border, regval;
729 INT frame;
730 NONCLIENTMETRICSA ncm;
731
732 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth);
733 rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
734 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
735 if( usesetborder) {
736 rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
737 if (!test_error_msg(rc,"SPI_SETBORDER")) return FALSE;
738 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
739 test_change_message( SPI_SETBORDER, 1 );
740 } else { /* set non client metrics */
741 ncm.iBorderWidth = curr_val;
742 rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncm, SPIF_UPDATEINIFILE|
743 SPIF_SENDCHANGE);
744 if (!test_error_msg(rc,"SPI_SETNONCLIENTMETRICS")) return FALSE;
745 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
746 test_change_message( SPI_SETNONCLIENTMETRICS, 1 );
747 }
748 if( curr_val) { /* skip if 0, some windows versions return 0 others 1 */
749 regval = metricfromreg( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_VALNAME, dpi);
750 if( regval != curr_val)
751 regval = metricfromreg( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, dpi);
752 ok( regval==curr_val, "wrong value in registry %d, expected %d\n", regval, curr_val);
753 }
754 /* minimum border width is 1 */
755 if (curr_val == 0) curr_val = 1;
756 /* should be the same as the non client metrics */
757 rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
758 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
759 eq( (UINT)ncm.iBorderWidth, curr_val, "NonClientMetric.iBorderWidth", "%d");
760 /* and from SPI_GETBORDER */
761 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 );
762 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
763 eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d");
764 /* test some SystemMetrics */
765 frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME );
766 eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" );
767 eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" );
768 eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" );
769 eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" );
770 return TRUE;
771 }
772
773 static void test_SPI_SETBORDER( void ) /* 6 */
774 {
775 BOOL rc;
776 UINT old_border;
777 NONCLIENTMETRICS ncmsave;
778 INT CaptionWidth,
779 PaddedBorderWidth;
780
781 ncmsave.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth);
782 rc=SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncmsave, 0);
783 if( !rc) {
784 win_skip("SPI_GETNONCLIENTMETRICS is not available\n");
785 return;
786 }
787 /* CaptionWidth from the registry may have different value of iCaptionWidth
788 * from the non client metrics (observed on WinXP).
789 * Fix this so we can safely restore settings with the nonclientmetrics */
790 CaptionWidth = metricfromreg(
791 "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi);
792 ncmsave.iCaptionWidth = CaptionWidth;
793
794 /* These tests hang when XFree86 4.0 for Windows is running (tested on
795 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
796 * running.
797 */
798 if (FindWindowA( NULL, "Cygwin/XFree86" ))
799 return;
800
801 trace("testing SPI_{GET,SET}BORDER\n");
802
803 SetLastError(0xdeadbeef);
804 rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 );
805 if (!test_error_msg(rc,"SPI_{GET,SET}BORDER"))
806 return;
807 /* FIXME: include new PaddedBorderWidth parameter */
808 PaddedBorderWidth = ncmsave.iBorderWidth - old_border;
809 if( PaddedBorderWidth){
810 win_skip( "Cannot reliably restore border width yet (PaddedBorderWidth = %d)\n",
811 PaddedBorderWidth);
812 return;
813 }
814 /* This will restore sane values if the test hang previous run. */
815 if ( old_border == 7 || old_border == 20 )
816 old_border = 1;
817
818 /* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to
819 * do it twice to make the intended change). So skip parts of the tests on
820 * those platforms */
821 if( !iswin9x) {
822 /* win2k3 fails if you set the same border twice, or if size is 0 */
823 if (!test_setborder(2, 1, dpi)) return;
824 test_setborder(1, 1, dpi);
825 test_setborder(3, 1, dpi);
826 }
827 if (!test_setborder(1, 0, dpi)) return;
828 test_setborder(0, 0, dpi);
829 test_setborder(3, 0, dpi);
830
831 rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncmsave,
832 SPIF_UPDATEINIFILE| SPIF_SENDCHANGE);
833 test_change_message( SPI_SETNONCLIENTMETRICS, 1 );
834 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",
835 rc,GetLastError());
836 }
837
838 static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
839 {
840 BOOL rc;
841 UINT old_speed;
842 const UINT vals[]={0,20,31};
843 unsigned int i;
844
845 trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
846 SetLastError(0xdeadbeef);
847 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 );
848 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED"))
849 return;
850
851 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
852 {
853 UINT v;
854 char buf[10];
855
856 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, vals[i], 0,
857 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
858 if (!test_error_msg(rc,"SPI_SETKEYBOARDSPEED")) return;
859 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
860 test_change_message( SPI_SETKEYBOARDSPEED, 0 );
861 sprintf( buf, "%d", vals[i] );
862 test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY, SPI_SETKEYBOARDSPEED_VALNAME, buf );
863
864 rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &v, 0 );
865 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
866 eq( v, vals[i], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
867 }
868
869 rc=SystemParametersInfoA( SPI_SETKEYBOARDSPEED, old_speed, 0, SPIF_UPDATEINIFILE );
870 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
871 }
872
873 /* test_SPI_ICONHORIZONTALSPACING helper */
874 static BOOL dotest_spi_iconhorizontalspacing( INT curr_val)
875 {
876 BOOL rc;
877 INT spacing, regval;
878 ICONMETRICSA im;
879
880 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, curr_val, 0,
881 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
882 if (!test_error_msg(rc,"SPI_ICONHORIZONTALSPACING")) return FALSE;
883 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
884 test_change_message( SPI_ICONHORIZONTALSPACING, 0 );
885 if( curr_val < 32) curr_val = 32;
886 /* The registry keys depend on the Windows version and the values too
887 * let's test (works on win95,ME,NT4,2k,XP)
888 */
889 regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY2, SPI_ICONHORIZONTALSPACING_VALNAME, dpi);
890 if( regval != curr_val)
891 regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi);
892 ok( curr_val == regval,
893 "wrong value in registry %d, expected %d\n", regval, curr_val);
894 /* compare with what SPI_ICONHORIZONTALSPACING returns */
895 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
896 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
897 eq( spacing, curr_val, "ICONHORIZONTALSPACING", "%d");
898 /* and with a system metrics */
899 eq( GetSystemMetrics( SM_CXICONSPACING ), curr_val, "SM_CXICONSPACING", "%d" );
900 /* and with what SPI_GETICONMETRICS returns */
901 im.cbSize = sizeof(ICONMETRICSA);
902 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE );
903 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
904 eq( im.iHorzSpacing, curr_val, "SPI_GETICONMETRICS", "%d" );
905 return TRUE;
906 }
907
908 static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */
909 {
910 BOOL rc;
911 INT old_spacing;
912
913 trace("testing SPI_ICONHORIZONTALSPACING\n");
914 SetLastError(0xdeadbeef);
915 /* default value: 75 */
916 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &old_spacing, 0 );
917 if (!test_error_msg(rc,"SPI_ICONHORIZONTALSPACING"))
918 return;
919 /* do not increase the value as it would upset the user's icon layout */
920 if (!dotest_spi_iconhorizontalspacing( old_spacing - 1)) return;
921 dotest_spi_iconhorizontalspacing( 10); /* minimum is 32 */
922 /* restore */
923 rc=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, old_spacing, 0, SPIF_UPDATEINIFILE );
924 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
925 }
926
927 static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
928 {
929 BOOL rc;
930 UINT old_timeout;
931 const UINT vals[]={0,32767};
932 unsigned int i;
933
934 trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
935 SetLastError(0xdeadbeef);
936 rc=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &old_timeout, 0 );
937 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVETIMEOUT"))
938 return;
939
940 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
941 {
942 UINT v;
943 char buf[10];
944
945 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, vals[i], 0,
946 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
947 if (!test_error_msg(rc,"SPI_SETSCREENSAVETIMEOUT")) return;
948 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
949 test_change_message( SPI_SETSCREENSAVETIMEOUT, 0 );
950 sprintf( buf, "%d", vals[i] );
951 test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY,
952 SPI_SETSCREENSAVETIMEOUT_VALNAME, buf );
953
954 SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT, 0, &v, 0 );
955 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
956 eq( v, vals[i], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
957 }
958
959 rc=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT, old_timeout, 0,
960 SPIF_UPDATEINIFILE );
961 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
962 }
963
964 static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
965 {
966 BOOL rc;
967 BOOL old_b;
968 const UINT vals[]={TRUE,FALSE};
969 unsigned int i;
970
971 trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
972 SetLastError(0xdeadbeef);
973 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &old_b, 0 );
974 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENSAVEACTIVE"))
975 return;
976
977 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
978 {
979 UINT v;
980
981 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, vals[i], 0,
982 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
983 if (!test_error_msg(rc,"SPI_SETSCREENSAVEACTIVE")) return;
984 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
985 test_change_message( SPI_SETSCREENSAVEACTIVE, 0 );
986 test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY,
987 SPI_SETSCREENSAVEACTIVE_VALNAME,
988 vals[i] ? "1" : "0" );
989
990 rc=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE, 0, &v, 0 );
991 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
992 ok(v == vals[i] || broken(! v) /* Win 7 */,
993 "SPI_{GET,SET}SCREENSAVEACTIVE: got %d instead of %d\n", v, vals[i]);
994 }
995
996 rc=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
997 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
998 }
999
1000 static void test_SPI_SETGRIDGRANULARITY( void ) /* 19 */
1001 {
1002 /* ??? */;
1003 }
1004
1005 static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
1006 {
1007 BOOL rc;
1008 UINT old_delay;
1009 const UINT vals[]={0,3};
1010 unsigned int i;
1011
1012 trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
1013 SetLastError(0xdeadbeef);
1014 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &old_delay, 0 );
1015 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDDELAY"))
1016 return;
1017
1018 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1019 {
1020 UINT delay;
1021 char buf[10];
1022
1023 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, vals[i], 0,
1024 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1025 if (!test_error_msg(rc,"SPI_SETKEYBOARDDELAY")) return;
1026 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1027 test_change_message( SPI_SETKEYBOARDDELAY, 0 );
1028 sprintf( buf, "%d", vals[i] );
1029 test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY,
1030 SPI_SETKEYBOARDDELAY_VALNAME, buf );
1031
1032 rc=SystemParametersInfoA( SPI_GETKEYBOARDDELAY, 0, &delay, 0 );
1033 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1034 eq( delay, vals[i], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
1035 }
1036
1037 rc=SystemParametersInfoA( SPI_SETKEYBOARDDELAY, old_delay, 0, SPIF_UPDATEINIFILE );
1038 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1039 }
1040
1041
1042 /* test_SPI_ICONVERTICALSPACING helper */
1043 static BOOL dotest_spi_iconverticalspacing( INT curr_val)
1044 {
1045 BOOL rc;
1046 INT spacing, regval;
1047 ICONMETRICSA im;
1048
1049 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, curr_val, 0,
1050 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1051 if (!test_error_msg(rc,"SPI_ICONVERTICALSPACING")) return FALSE;
1052 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1053 test_change_message( SPI_ICONVERTICALSPACING, 0 );
1054 if( curr_val < 32) curr_val = 32;
1055 /* The registry keys depend on the Windows version and the values too
1056 * let's test (works on win95,ME,NT4,2k,XP)
1057 */
1058 regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY2, SPI_ICONVERTICALSPACING_VALNAME, dpi);
1059 if( regval != curr_val)
1060 regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi);
1061 ok( curr_val == regval,
1062 "wrong value in registry %d, expected %d\n", regval, curr_val);
1063 /* compare with what SPI_ICONVERTICALSPACING returns */
1064 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
1065 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1066 eq( spacing, curr_val, "ICONVERTICALSPACING", "%d" );
1067 /* and with a system metrics */
1068 eq( GetSystemMetrics( SM_CYICONSPACING ), curr_val, "SM_CYICONSPACING", "%d" );
1069 /* and with what SPI_GETICONMETRICS returns */
1070 im.cbSize = sizeof(ICONMETRICSA);
1071 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE );
1072 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1073 eq( im.iVertSpacing, curr_val, "SPI_GETICONMETRICS", "%d" );
1074 return TRUE;
1075 }
1076
1077 static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */
1078 {
1079 BOOL rc;
1080 INT old_spacing;
1081
1082 trace("testing SPI_ICONVERTICALSPACING\n");
1083 SetLastError(0xdeadbeef);
1084 /* default value: 75 */
1085 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &old_spacing, 0 );
1086 if (!test_error_msg(rc,"SPI_ICONVERTICALSPACING"))
1087 return;
1088 /* do not increase the value as it would upset the user's icon layout */
1089 if (!dotest_spi_iconverticalspacing( old_spacing - 1)) return;
1090 /* same tests with a value less than the minimum 32 */
1091 dotest_spi_iconverticalspacing( 10);
1092 /* restore */
1093 rc=SystemParametersInfoA( SPI_ICONVERTICALSPACING, old_spacing, 0,
1094 SPIF_UPDATEINIFILE );
1095 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",
1096 rc,GetLastError());
1097 }
1098
1099 static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
1100 {
1101 BOOL rc;
1102 BOOL old_b;
1103 const UINT vals[]={TRUE,FALSE};
1104 unsigned int i;
1105 ICONMETRICSA im;
1106
1107 /* These tests hang when XFree86 4.0 for Windows is running (tested on
1108 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
1109 * running.
1110 */
1111 if (FindWindowA( NULL, "Cygwin/XFree86" ))
1112 return;
1113
1114 trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
1115 SetLastError(0xdeadbeef);
1116 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &old_b, 0 );
1117 if (!test_error_msg(rc,"SPI_{GET,SET}ICONTITLEWRAP"))
1118 return;
1119
1120 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1121 {
1122 UINT v;
1123 UINT regval;
1124
1125 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, vals[i], 0,
1126 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1127 if (!test_error_msg(rc,"SPI_SETICONTITLEWRAP")) return;
1128 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1129 test_change_message( SPI_SETICONTITLEWRAP, 1 );
1130 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2,
1131 SPI_SETICONTITLEWRAP_VALNAME, dpi);
1132 if( regval != vals[i])
1133 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1,
1134 SPI_SETICONTITLEWRAP_VALNAME, dpi);
1135 ok( regval == vals[i] || broken(regval == -1), /* win9x */
1136 "wrong value in registry %d, expected %d\n", regval, vals[i] );
1137
1138 rc=SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &v, 0 );
1139 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1140 eq( v, vals[i], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
1141 /* and test with what SPI_GETICONMETRICS returns */
1142 im.cbSize = sizeof(ICONMETRICSA);
1143 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im, FALSE );
1144 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1145 eq( im.iTitleWrap, (BOOL)vals[i], "SPI_GETICONMETRICS", "%d" );
1146 }
1147
1148 rc=SystemParametersInfoA( SPI_SETICONTITLEWRAP, old_b, 0, SPIF_UPDATEINIFILE );
1149 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1150 }
1151
1152 static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
1153 {
1154 BOOL rc;
1155 BOOL old_b;
1156 const UINT vals[]={TRUE,FALSE};
1157 unsigned int i;
1158
1159 trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
1160 SetLastError(0xdeadbeef);
1161 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &old_b, 0 );
1162 if (!test_error_msg(rc,"SPI_{GET,SET}MENUDROPALIGNMENT"))
1163 return;
1164
1165 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1166 {
1167 UINT v;
1168
1169 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, vals[i], 0,
1170 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1171 if (!test_error_msg(rc,"SPI_SETMENUDROPALIGNMENT")) return;
1172 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1173 test_change_message( SPI_SETMENUDROPALIGNMENT, 0 );
1174 test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1,
1175 SPI_SETMENUDROPALIGNMENT_REGKEY2,
1176 SPI_SETMENUDROPALIGNMENT_VALNAME,
1177 vals[i] ? "1" : "0" );
1178
1179 rc=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0, &v, 0 );
1180 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1181 eq( v, vals[i], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
1182 eq( GetSystemMetrics( SM_MENUDROPALIGNMENT ), (int)vals[i],
1183 "SM_MENUDROPALIGNMENT", "%d" );
1184 }
1185
1186 rc=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT, old_b, 0,
1187 SPIF_UPDATEINIFILE );
1188 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1189 }
1190
1191 static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
1192 {
1193 BOOL rc;
1194 INT old_width;
1195 const UINT vals[]={0,10000};
1196 unsigned int i;
1197
1198 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
1199 old_width = GetSystemMetrics( SM_CXDOUBLECLK );
1200
1201 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1202 {
1203 char buf[10];
1204
1205 SetLastError(0xdeadbeef);
1206 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, vals[i], 0,
1207 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1208 if (!test_error_msg(rc,"SPI_{GET,SET}DOUBLECLKWIDTH"))
1209 return;
1210
1211 test_change_message( SPI_SETDOUBLECLKWIDTH, 0 );
1212 sprintf( buf, "%d", vals[i] );
1213 test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1,
1214 SPI_SETDOUBLECLKWIDTH_REGKEY2,
1215 SPI_SETDOUBLECLKWIDTH_VALNAME, buf );
1216 eq( GetSystemMetrics( SM_CXDOUBLECLK ), (int)vals[i],
1217 "SM_CXDOUBLECLK", "%d" );
1218 }
1219
1220 rc=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH, old_width, 0,
1221 SPIF_UPDATEINIFILE );
1222 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1223 }
1224
1225 static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
1226 {
1227 BOOL rc;
1228 INT old_height;
1229 const UINT vals[]={0,10000};
1230 unsigned int i;
1231
1232 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
1233 old_height = GetSystemMetrics( SM_CYDOUBLECLK );
1234
1235 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1236 {
1237 char buf[10];
1238
1239 SetLastError(0xdeadbeef);
1240 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, vals[i], 0,
1241 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1242 if (!test_error_msg(rc,"SPI_{GET,SET}DOUBLECLKHEIGHT"))
1243 return;
1244
1245 test_change_message( SPI_SETDOUBLECLKHEIGHT, 0 );
1246 sprintf( buf, "%d", vals[i] );
1247 test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1,
1248 SPI_SETDOUBLECLKHEIGHT_REGKEY2,
1249 SPI_SETDOUBLECLKHEIGHT_VALNAME, buf );
1250 eq( GetSystemMetrics( SM_CYDOUBLECLK ), (int)vals[i],
1251 "SM_CYDOUBLECLK", "%d" );
1252 }
1253
1254 rc=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT, old_height, 0,
1255 SPIF_UPDATEINIFILE );
1256 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1257 }
1258
1259 static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
1260 {
1261 BOOL rc;
1262 UINT curr_val;
1263 UINT saved_val;
1264 UINT old_time;
1265 char buf[10];
1266
1267 trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
1268 old_time = GetDoubleClickTime();
1269
1270 curr_val = 0;
1271 SetLastError(0xdeadbeef);
1272 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
1273 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1274 if (!test_error_msg(rc,"SPI_{GET,SET}DOUBLECLICKTIME"))
1275 return;
1276
1277 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
1278 sprintf( buf, "%d", curr_val );
1279 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
1280 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
1281 curr_val = 500; /* used value for 0 */
1282 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
1283
1284 curr_val = 1000;
1285 rc=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME, curr_val, 0,
1286 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1287 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1288 test_change_message( SPI_SETDOUBLECLICKTIME, 0 );
1289 sprintf( buf, "%d", curr_val );
1290 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
1291 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
1292 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
1293
1294 saved_val = curr_val;
1295
1296 curr_val = 0;
1297 SetDoubleClickTime( curr_val );
1298 sprintf( buf, "%d", saved_val );
1299 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
1300 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
1301 curr_val = 500; /* used value for 0 */
1302 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
1303
1304 curr_val = 1000;
1305 SetDoubleClickTime( curr_val );
1306 sprintf( buf, "%d", saved_val );
1307 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY,
1308 SPI_SETDOUBLECLICKTIME_VALNAME, buf );
1309 eq( GetDoubleClickTime(), curr_val, "GetDoubleClickTime", "%d" );
1310
1311 rc=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME, old_time, 0, SPIF_UPDATEINIFILE);
1312 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1313 }
1314
1315 static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
1316 {
1317 BOOL rc;
1318 BOOL old_b;
1319 const UINT vals[]={TRUE,FALSE};
1320 unsigned int i;
1321
1322 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
1323 old_b = GetSystemMetrics( SM_SWAPBUTTON );
1324
1325 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1326 {
1327 SetLastError(0xdeadbeef);
1328 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, vals[i], 0,
1329 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1330 if (!test_error_msg(rc,"SPI_SETMOUSEBUTTONSWAP")) return;
1331
1332 test_change_message( SPI_SETMOUSEBUTTONSWAP, 0 );
1333 test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY,
1334 SPI_SETMOUSEBUTTONSWAP_VALNAME,
1335 vals[i] ? "1" : "0" );
1336 eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i],
1337 "SM_SWAPBUTTON", "%d" );
1338 rc=SwapMouseButton((BOOL)vals[i^1]);
1339 eq( GetSystemMetrics( SM_SWAPBUTTON ), (int)vals[i^1],
1340 "SwapMouseButton", "%d" );
1341 ok( rc==(BOOL)vals[i], "SwapMouseButton does not return previous state (really %d)\n", rc );
1342 }
1343
1344 rc=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP, old_b, 0,
1345 SPIF_UPDATEINIFILE );
1346 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1347 }
1348
1349 static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
1350 {
1351 BOOL rc;
1352 BOOL v;
1353
1354 trace("testing SPI_GETFASTTASKSWITCH\n");
1355 SetLastError(0xdeadbeef);
1356 rc=SystemParametersInfoA( SPI_GETFASTTASKSWITCH, 0, &v, 0 );
1357 if (!test_error_msg(rc,"SPI_{GET,SET}FASTTASKSWITCH"))
1358 return;
1359
1360 /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
1361 * works. That sure simplifies testing!
1362 */
1363 }
1364
1365 static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
1366 {
1367 BOOL rc;
1368 BOOL old_b;
1369 const UINT vals[]={TRUE,FALSE};
1370 unsigned int i;
1371
1372 trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
1373 SetLastError(0xdeadbeef);
1374 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &old_b, 0 );
1375
1376 /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
1377 if (!test_error_msg(rc,"SPI_{GET,SET}DRAGFULLWINDOWS"))
1378 return;
1379
1380 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1381 {
1382 UINT v;
1383
1384 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, vals[i], 0,
1385 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1386 if (!test_error_msg(rc,"SPI_SETDRAGFULLWINDOWS")) return;
1387 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1388 test_change_message( SPI_SETDRAGFULLWINDOWS, 0 );
1389 test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY,
1390 SPI_SETDRAGFULLWINDOWS_VALNAME,
1391 vals[i] ? "1" : "0" );
1392
1393 rc=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS, 0, &v, 0 );
1394 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1395 eq( v, vals[i], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
1396 }
1397
1398 rc=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS, old_b, 0, SPIF_UPDATEINIFILE );
1399 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1400 }
1401
1402 #define test_reg_metric( KEY, VAL, val) \
1403 { INT regval;\
1404 regval = metricfromreg( KEY, VAL, dpi);\
1405 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\
1406 }
1407
1408 #define test_reg_metric2( KEY1, KEY2, VAL, val) \
1409 { INT regval;\
1410 regval = metricfromreg( KEY1, VAL, dpi);\
1411 if( regval != val) regval = metricfromreg( KEY2, VAL, dpi);\
1412 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\
1413 }
1414
1415 #define test_reg_font( KEY, VAL, LF) \
1416 { LOGFONTA lfreg;\
1417 lffromreg( KEY, VAL, &lfreg);\
1418 ok( (lfreg.lfHeight < 0 ? (LF).lfHeight == lfreg.lfHeight :\
1419 MulDiv( -(LF).lfHeight , 72, dpi) == lfreg.lfHeight )&&\
1420 (LF).lfWidth == lfreg.lfWidth &&\
1421 (LF).lfWeight == lfreg.lfWeight &&\
1422 !strcmp( (LF).lfFaceName, lfreg.lfFaceName)\
1423 , "wrong value \"%s\" in registry %d, %d\n", VAL, (LF).lfHeight, lfreg.lfHeight);\
1424 }
1425
1426 #define TEST_NONCLIENTMETRICS_REG( ncm) \
1427 /*FIXME: test_reg_metric2( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, (ncm).iBorderWidth);*/\
1428 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLWIDTH_VALNAME, (ncm).iScrollWidth);\
1429 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLHEIGHT_VALNAME, (ncm).iScrollHeight);\
1430 /*FIXME: test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONWIDTH_VALNAME, (ncm).iCaptionWidth);*/\
1431 test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONHEIGHT_VALNAME, (ncm).iCaptionHeight);\
1432 test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONWIDTH_VALNAME, (ncm).iSmCaptionWidth);\
1433 test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, (ncm).iSmCaptionHeight);\
1434 test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUWIDTH_VALNAME, (ncm).iMenuWidth);\
1435 test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, (ncm).iMenuHeight);\
1436 test_reg_font( SPI_METRIC_REGKEY, SPI_MENUFONT_VALNAME, (ncm).lfMenuFont);\
1437 test_reg_font( SPI_METRIC_REGKEY, SPI_CAPTIONFONT_VALNAME, (ncm).lfCaptionFont);\
1438 test_reg_font( SPI_METRIC_REGKEY, SPI_SMCAPTIONFONT_VALNAME, (ncm).lfSmCaptionFont);\
1439 test_reg_font( SPI_METRIC_REGKEY, SPI_STATUSFONT_VALNAME, (ncm).lfStatusFont);\
1440 test_reg_font( SPI_METRIC_REGKEY, SPI_MESSAGEFONT_VALNAME, (ncm).lfMessageFont);
1441
1442 /* get text metric height value for the specified logfont */
1443 static int get_tmheight( LOGFONTA *plf, int flag)
1444 {
1445 TEXTMETRICA tm;
1446 HFONT hfont = CreateFontIndirectA( plf);
1447 hfont = SelectObject( hdc, hfont);
1448 GetTextMetricsA( hdc, &tm);
1449 hfont = SelectObject( hdc, hfont);
1450 return tm.tmHeight + (flag ? tm.tmExternalLeading : 0);
1451 }
1452
1453 static void test_GetSystemMetrics( void);
1454 static UINT smcxsmsize = 999999999;
1455
1456 static void test_SPI_SETNONCLIENTMETRICS( void ) /* 44 */
1457 {
1458 BOOL rc;
1459 INT expect;
1460 NONCLIENTMETRICSA Ncmorig;
1461 NONCLIENTMETRICSA Ncmnew;
1462 NONCLIENTMETRICSA Ncmcur;
1463 NONCLIENTMETRICSA Ncmstart;
1464
1465 Ncmorig.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth);
1466 Ncmnew.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth);
1467 Ncmcur.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth);
1468 Ncmstart.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth);
1469
1470 trace("testing SPI_{GET,SET}NONCLIENTMETRICS\n");
1471 change_counter = 0;
1472 SetLastError(0xdeadbeef);
1473 rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmorig, FALSE );
1474 if (!test_error_msg(rc,"SPI_{GET,SET}NONCLIENTMETRICS"))
1475 return;
1476 Ncmstart = Ncmorig;
1477 smcxsmsize = Ncmstart.iSmCaptionWidth;
1478 /* SPI_GETNONCLIENTMETRICS returns some "cooked" values. For instance if
1479 the caption font height is higher than the CaptionHeight field,
1480 the latter is adjusted accordingly. To be able to restore these setting
1481 accurately be restore the raw values. */
1482 Ncmorig.iCaptionWidth = metricfromreg( SPI_METRIC_REGKEY, SPI_CAPTIONWIDTH_VALNAME, dpi);
1483 Ncmorig.iCaptionHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_CAPTIONHEIGHT_VALNAME, dpi);
1484 Ncmorig.iSmCaptionHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, dpi);
1485 Ncmorig.iMenuHeight = metricfromreg( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, dpi);
1486 /* test registry entries */
1487 TEST_NONCLIENTMETRICS_REG( Ncmorig)
1488 /* make small changes */
1489 Ncmnew = Ncmstart;
1490 Ncmnew.iBorderWidth += 1;
1491 Ncmnew.iScrollWidth += 1;
1492 Ncmnew.iScrollHeight -= 1;
1493 Ncmnew.iCaptionWidth -= 2;
1494 Ncmnew.iCaptionHeight += 2;
1495 Ncmnew.lfCaptionFont.lfHeight +=1;
1496 Ncmnew.lfCaptionFont.lfWidth +=2;
1497 Ncmnew.lfCaptionFont.lfWeight +=1;
1498 Ncmnew.iSmCaptionWidth += 1;
1499 Ncmnew.iSmCaptionHeight += 2;
1500 Ncmnew.lfSmCaptionFont.lfHeight +=3;
1501 Ncmnew.lfSmCaptionFont.lfWidth -=1;
1502 Ncmnew.lfSmCaptionFont.lfWeight +=3;
1503 Ncmnew.iMenuWidth += 1;
1504 Ncmnew.iMenuHeight += 2;
1505 Ncmnew.lfMenuFont.lfHeight +=1;
1506 Ncmnew.lfMenuFont.lfWidth +=1;
1507 Ncmnew.lfMenuFont.lfWeight +=2;
1508 Ncmnew.lfStatusFont.lfHeight -=1;
1509 Ncmnew.lfStatusFont.lfWidth -=1;
1510 Ncmnew.lfStatusFont.lfWeight +=3;
1511 Ncmnew.lfMessageFont.lfHeight -=2;
1512 Ncmnew.lfMessageFont.lfWidth -=1;
1513 Ncmnew.lfMessageFont.lfWeight +=4;
1514
1515 rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &Ncmnew, SPIF_UPDATEINIFILE|
1516 SPIF_SENDCHANGE);
1517 if (!test_error_msg(rc,"SPI_SETNONCLIENTMETRICS")) return;
1518 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1519 test_change_message( SPI_SETNONCLIENTMETRICS, 1 );
1520 /* get them back */
1521 rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmcur, FALSE );
1522 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1523 /* test registry entries */
1524 TEST_NONCLIENTMETRICS_REG( Ncmcur)
1525 /* test the system metrics with these settings */
1526 test_GetSystemMetrics();
1527 /* now for something invalid: increase the {menu|caption|smcaption} fonts
1528 by a large amount will increase the {menu|caption|smcaption} height*/
1529 Ncmnew = Ncmstart;
1530 Ncmnew.lfMenuFont.lfHeight -= 8;
1531 Ncmnew.lfCaptionFont.lfHeight =-4;
1532 Ncmnew.lfSmCaptionFont.lfHeight -=10;
1533 /* also show that a few values are lo limited */
1534 Ncmnew.iCaptionWidth = 0;
1535 Ncmnew.iCaptionHeight = 0;
1536 Ncmnew.iScrollHeight = 0;
1537 Ncmnew.iScrollWidth = 0;
1538
1539 rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &Ncmnew, SPIF_UPDATEINIFILE|
1540 SPIF_SENDCHANGE);
1541 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1542 test_change_message( SPI_SETNONCLIENTMETRICS, 1 );
1543 /* raw values are in registry */
1544 TEST_NONCLIENTMETRICS_REG( Ncmnew)
1545 /* get them back */
1546 rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &Ncmcur, FALSE );
1547 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1548 /* cooked values are returned */
1549 expect = max( Ncmnew.iMenuHeight, 2 + get_tmheight( &Ncmnew.lfMenuFont, 1));
1550 ok( Ncmcur.iMenuHeight == expect,
1551 "MenuHeight: %d expected %d\n", Ncmcur.iMenuHeight, expect);
1552 expect = max( Ncmnew.iCaptionHeight, 2 + get_tmheight(&Ncmnew.lfCaptionFont, 0));
1553 ok( Ncmcur.iCaptionHeight == expect,
1554 "CaptionHeight: %d expected %d\n", Ncmcur.iCaptionHeight, expect);
1555 expect = max( Ncmnew.iSmCaptionHeight, 2 + get_tmheight( &Ncmnew.lfSmCaptionFont, 0));
1556 ok( Ncmcur.iSmCaptionHeight == expect,
1557 "SmCaptionHeight: %d expected %d\n", Ncmcur.iSmCaptionHeight, expect);
1558
1559 ok( Ncmcur.iCaptionWidth == 8 ||
1560 Ncmcur.iCaptionWidth == 12 || /* Vista, W7b */
1561 Ncmcur.iCaptionWidth == Ncmstart.iCaptionWidth, /* with windows XP theme, the value never changes */
1562 "CaptionWidth: %d expected 8, 12 or %d\n", Ncmcur.iCaptionWidth, Ncmstart.iCaptionWidth);
1563 ok( Ncmcur.iScrollWidth == 8,
1564 "ScrollWidth: %d expected 8\n", Ncmcur.iScrollWidth);
1565 ok( Ncmcur.iScrollHeight == 8,
1566 "ScrollHeight: %d expected 8\n", Ncmcur.iScrollHeight);
1567 /* test the system metrics with these settings */
1568 test_GetSystemMetrics();
1569 /* restore */
1570 rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS),
1571 &Ncmorig, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
1572 test_change_message( SPI_SETNONCLIENTMETRICS, 0 );
1573 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1574 /* test the system metrics with these settings */
1575 test_GetSystemMetrics();
1576 }
1577
1578 static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */
1579 {
1580 BOOL rc;
1581 INT regval;
1582 MINIMIZEDMETRICS lpMm_orig;
1583 MINIMIZEDMETRICS lpMm_new;
1584 MINIMIZEDMETRICS lpMm_cur;
1585
1586 lpMm_orig.cbSize = sizeof(MINIMIZEDMETRICS);
1587 lpMm_new.cbSize = sizeof(MINIMIZEDMETRICS);
1588 lpMm_cur.cbSize = sizeof(MINIMIZEDMETRICS);
1589
1590 trace("testing SPI_{GET,SET}MINIMIZEDMETRICS\n");
1591 SetLastError(0xdeadbeef);
1592 rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_orig, FALSE );
1593 if (!test_error_msg(rc,"SPI_{GET,SET}MINIMIZEDMETRICS"))
1594 return;
1595 /* Test registry. Note that it is perfectly valid for some fields to
1596 * not be set.
1597 */
1598 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi);
1599 ok( regval == -1 || regval == lpMm_orig.iWidth, "wrong value in registry %d, expected %d\n",
1600 regval, lpMm_orig.iWidth);
1601 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi);
1602 ok( regval == -1 || regval == lpMm_orig.iHorzGap, "wrong value in registry %d, expected %d\n",
1603 regval, lpMm_orig.iHorzGap);
1604 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi);
1605 ok( regval == -1 || regval == lpMm_orig.iVertGap, "wrong value in registry %d, expected %d\n",
1606 regval, lpMm_orig.iVertGap);
1607 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi);
1608 ok( regval == -1 || regval == lpMm_orig.iArrange, "wrong value in registry %d, expected %d\n",
1609 regval, lpMm_orig.iArrange);
1610 /* set some new values */
1611 lpMm_cur.iWidth = 180;
1612 lpMm_cur.iHorzGap = 1;
1613 lpMm_cur.iVertGap = 1;
1614 lpMm_cur.iArrange = 5;
1615 rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS),
1616 &lpMm_cur, SPIF_UPDATEINIFILE );
1617 if (!test_error_msg(rc,"SPI_SETMINIMIZEDMETRICS")) return;
1618 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1619 /* read them back */
1620 rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE );
1621 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1622 /* and compare */
1623 eq( lpMm_new.iWidth, lpMm_cur.iWidth, "iWidth", "%d" );
1624 eq( lpMm_new.iHorzGap, lpMm_cur.iHorzGap, "iHorzGap", "%d" );
1625 eq( lpMm_new.iVertGap, lpMm_cur.iVertGap, "iVertGap", "%d" );
1626 eq( lpMm_new.iArrange, lpMm_cur.iArrange, "iArrange", "%d" );
1627 /* test registry */
1628 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi);
1629 ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n",
1630 regval, lpMm_new.iWidth);
1631 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi);
1632 ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n",
1633 regval, lpMm_new.iHorzGap);
1634 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi);
1635 ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n",
1636 regval, lpMm_new.iVertGap);
1637 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi);
1638 ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n",
1639 regval, lpMm_new.iArrange);
1640 /* test some system metrics */
1641 eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6,
1642 lpMm_new.iWidth, "iWidth", "%d" );
1643 eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ),
1644 lpMm_new.iHorzGap, "iHorzGap", "%d" );
1645 eq( GetSystemMetrics( SM_CYMINSPACING ) - GetSystemMetrics( SM_CYMINIMIZED ),
1646 lpMm_new.iVertGap, "iVertGap", "%d" );
1647 eq( GetSystemMetrics( SM_ARRANGE ),
1648 lpMm_new.iArrange, "iArrange", "%d" );
1649 /* now some really invalid settings */
1650 lpMm_cur.iWidth = -1;
1651 lpMm_cur.iHorzGap = -1;
1652 lpMm_cur.iVertGap = -1;
1653 lpMm_cur.iArrange = - 1;
1654 rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS),
1655 &lpMm_cur, SPIF_UPDATEINIFILE );
1656 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1657 /* read back */
1658 rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE );
1659 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1660 /* the width and H/V gaps have minimum 0, arrange is and'd with 0xf */
1661 eq( lpMm_new.iWidth, 0, "iWidth", "%d" );
1662 eq( lpMm_new.iHorzGap, 0, "iHorzGap", "%d" );
1663 eq( lpMm_new.iVertGap, 0, "iVertGap", "%d" );
1664 eq( lpMm_new.iArrange, 0xf & lpMm_cur.iArrange, "iArrange", "%d" );
1665 /* test registry */
1666 if (0)
1667 {
1668 /* FIXME: cannot understand the results of this (11, 11, 11, 0) */
1669 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi);
1670 ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n",
1671 regval, lpMm_new.iWidth);
1672 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi);
1673 ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n",
1674 regval, lpMm_new.iHorzGap);
1675 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi);
1676 ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n",
1677 regval, lpMm_new.iVertGap);
1678 regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi);
1679 ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n",
1680 regval, lpMm_new.iArrange);
1681 }
1682 /* test some system metrics */
1683 eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6,
1684 lpMm_new.iWidth, "iWidth", "%d" );
1685 eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ),
1686 lpMm_new.iHorzGap, "iHorzGap", "%d" );
1687 eq( GetSystemMetrics( SM_CYMINSPACING ) - GetSystemMetrics( SM_CYMINIMIZED ),
1688 lpMm_new.iVertGap, "iVertGap", "%d" );
1689 eq( GetSystemMetrics( SM_ARRANGE ),
1690 lpMm_new.iArrange, "iArrange", "%d" );
1691 /* restore */
1692 rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS),
1693 &lpMm_orig, SPIF_UPDATEINIFILE );
1694 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1695 /* check that */
1696 rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE );
1697 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1698 eq( lpMm_new.iWidth, lpMm_orig.iWidth, "iWidth", "%d" );
1699 eq( lpMm_new.iHorzGap, lpMm_orig.iHorzGap, "iHorzGap", "%d" );
1700 eq( lpMm_new.iVertGap, lpMm_orig.iVertGap, "iVertGap", "%d" );
1701 eq( lpMm_new.iArrange, lpMm_orig.iArrange, "iArrange", "%d" );
1702 }
1703
1704 static void test_SPI_SETICONMETRICS( void ) /* 46 */
1705 {
1706 BOOL rc, wrap;
1707 INT spacing;
1708 ICONMETRICSA im_orig;
1709 ICONMETRICSA im_new;
1710 ICONMETRICSA im_cur;
1711 INT regval;
1712
1713 im_orig.cbSize = sizeof(ICONMETRICSA);
1714 im_new.cbSize = sizeof(ICONMETRICSA);
1715 im_cur.cbSize = sizeof(ICONMETRICSA);
1716
1717 trace("testing SPI_{GET,SET}ICONMETRICS\n");
1718 SetLastError(0xdeadbeef);
1719 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE );
1720 if (!test_error_msg(rc,"SPI_{GET,SET}ICONMETRICS"))
1721 return;
1722 /* check some registry values */
1723 regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi);
1724 ok( regval==im_orig.iHorzSpacing || broken(regval == -1), /* nt4 */
1725 "wrong value in registry %d, expected %d\n", regval, im_orig.iHorzSpacing);
1726 regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi);
1727 ok( regval==im_orig.iVertSpacing || broken(regval == -1), /* nt4 */
1728 "wrong value in registry %d, expected %d\n", regval, im_orig.iVertSpacing);
1729 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi);
1730 if( regval != im_orig.iTitleWrap)
1731 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi);
1732 ok( regval==im_orig.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_orig.iTitleWrap);
1733
1734 /* change everything without creating something invalid ( Win9x would ignore
1735 * an invalid font for instance) */
1736 im_cur = im_orig;
1737 im_cur.iHorzSpacing += 10;
1738 im_cur.iVertSpacing += 6;
1739 im_cur.iTitleWrap = !im_cur.iTitleWrap;
1740 im_cur.lfFont.lfHeight += 1;
1741 im_cur.lfFont.lfWidth += 2;
1742 im_cur.lfFont.lfEscapement = 1;
1743 im_cur.lfFont.lfWeight = im_cur.lfFont.lfWeight > 100 ? 1 : 314;
1744 im_cur.lfFont.lfItalic = !im_cur.lfFont.lfItalic;
1745 im_cur.lfFont.lfStrikeOut = !im_cur.lfFont.lfStrikeOut;
1746 im_cur.lfFont.lfUnderline = !im_cur.lfFont.lfUnderline;
1747 im_cur.lfFont.lfCharSet = im_cur.lfFont.lfCharSet ? 0 : 1;
1748 im_cur.lfFont.lfOutPrecision = im_cur.lfFont.lfOutPrecision == OUT_DEFAULT_PRECIS ?
1749 OUT_TT_PRECIS : OUT_DEFAULT_PRECIS;
1750 im_cur.lfFont.lfClipPrecision ^= CLIP_LH_ANGLES;
1751 im_cur.lfFont.lfPitchAndFamily = im_cur.lfFont.lfPitchAndFamily ? 0 : 1;
1752 im_cur.lfFont.lfQuality = im_cur.lfFont.lfQuality == DEFAULT_QUALITY ?
1753 DRAFT_QUALITY : DEFAULT_QUALITY;
1754 if( strcmp( im_cur.lfFont.lfFaceName, "MS Serif"))
1755 strcpy( im_cur.lfFont.lfFaceName, "MS Serif");
1756 else
1757 strcpy( im_cur.lfFont.lfFaceName, "MS Sans Serif");
1758
1759 rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_cur, SPIF_UPDATEINIFILE );
1760 if (!test_error_msg(rc,"SPI_SETICONMETRICS")) return;
1761 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1762
1763 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE );
1764 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1765 /* test GET <-> SETICONMETRICS */
1766 eq( im_new.iHorzSpacing, im_cur.iHorzSpacing, "iHorzSpacing", "%d" );
1767 eq( im_new.iVertSpacing, im_cur.iVertSpacing, "iVertSpacing", "%d" );
1768 eq( im_new.iTitleWrap, im_cur.iTitleWrap, "iTitleWrap", "%d" );
1769 eq( im_new.lfFont.lfHeight, im_cur.lfFont.lfHeight, "lfHeight", "%d" );
1770 eq( im_new.lfFont.lfWidth, im_cur.lfFont.lfWidth, "lfWidth", "%d" );
1771 eq( im_new.lfFont.lfEscapement, im_cur.lfFont.lfEscapement, "lfEscapement", "%d" );
1772 eq( im_new.lfFont.lfWeight, im_cur.lfFont.lfWeight, "lfWeight", "%d" );
1773 eq( im_new.lfFont.lfItalic, im_cur.lfFont.lfItalic, "lfItalic", "%d" );
1774 eq( im_new.lfFont.lfStrikeOut, im_cur.lfFont.lfStrikeOut, "lfStrikeOut", "%d" );
1775 eq( im_new.lfFont.lfUnderline, im_cur.lfFont.lfUnderline, "lfUnderline", "%d" );
1776 eq( im_new.lfFont.lfCharSet, im_cur.lfFont.lfCharSet, "lfCharSet", "%d" );
1777 eq( im_new.lfFont.lfOutPrecision, im_cur.lfFont.lfOutPrecision, "lfOutPrecision", "%d" );
1778 eq( im_new.lfFont.lfClipPrecision, im_cur.lfFont.lfClipPrecision, "lfClipPrecision", "%d" );
1779 eq( im_new.lfFont.lfPitchAndFamily, im_cur.lfFont.lfPitchAndFamily, "lfPitchAndFamily", "%d" );
1780 eq( im_new.lfFont.lfQuality, im_cur.lfFont.lfQuality, "lfQuality", "%d" );
1781 ok( !strcmp( im_new.lfFont.lfFaceName, im_cur.lfFont.lfFaceName),
1782 "wrong facename \"%s\", should be \"%s\"\n", im_new.lfFont.lfFaceName,
1783 im_cur.lfFont.lfFaceName);
1784 /* test some system metrics */
1785 eq( GetSystemMetrics( SM_CXICONSPACING ),
1786 im_new.iHorzSpacing, "iHorzSpacing", "%d" );
1787 eq( GetSystemMetrics( SM_CYICONSPACING ),
1788 im_new.iVertSpacing, "iVertSpacing", "%d" );
1789 /* check some registry values */
1790 regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi);
1791 ok( regval==im_cur.iHorzSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iHorzSpacing);
1792 regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi);
1793 ok( regval==im_cur.iVertSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iVertSpacing);
1794 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi);
1795 if( regval != im_cur.iTitleWrap)
1796 regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi);
1797 ok( regval==im_cur.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_cur.iTitleWrap);
1798 /* test some values from other SPI_GETxxx calls */
1799 rc = SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 );
1800 ok( rc && spacing == im_cur.iHorzSpacing,
1801 "SystemParametersInfoA( SPI_ICONHORIZONTALSPACING...) failed or returns wrong value %d instead of %d\n",
1802 spacing, im_cur.iHorzSpacing);
1803 rc = SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 );
1804 ok( rc && spacing == im_cur.iVertSpacing,
1805 "SystemParametersInfoA( SPI_ICONVERTICALSPACING...) failed or returns wrong value %d instead of %d\n",
1806 spacing, im_cur.iVertSpacing);
1807 rc = SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &wrap, 0 );
1808 ok( rc && wrap == im_cur.iTitleWrap,
1809 "SystemParametersInfoA( SPI_GETICONTITLEWRAP...) failed or returns wrong value %d instead of %d\n",
1810 wrap, im_cur.iTitleWrap);
1811 /* restore old values */
1812 rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig,SPIF_UPDATEINIFILE );
1813 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1814
1815 rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE );
1816 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1817
1818 eq( im_new.iHorzSpacing, im_orig.iHorzSpacing, "iHorzSpacing", "%d" );
1819 eq( im_new.iVertSpacing, im_orig.iVertSpacing, "iVertSpacing", "%d" );
1820 eq( im_new.iTitleWrap, im_orig.iTitleWrap, "iTitleWrap", "%d" );
1821 }
1822
1823 static void test_SPI_SETWORKAREA( void ) /* 47 */
1824 {
1825 BOOL rc;
1826 RECT old_area;
1827 RECT area;
1828 RECT curr_val;
1829
1830 trace("testing SPI_{GET,SET}WORKAREA\n");
1831 SetLastError(0xdeadbeef);
1832 rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0);
1833 if (!test_error_msg(rc,"SPI_{GET,SET}WORKAREA"))
1834 return;
1835
1836 /* Modify the work area only minimally as this causes the icons that
1837 * fall outside it to be moved around thus requiring the user to
1838 * reposition them manually one by one.
1839 * Changing the work area by just one pixel should make this occurrence
1840 * reasonably unlikely.
1841 */
1842 curr_val.left = old_area.left;
1843 curr_val.top = old_area.top;
1844 curr_val.right = old_area.right-1;
1845 curr_val.bottom = old_area.bottom-1;
1846 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val,
1847 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1848 if (!test_error_msg(rc,"SPI_SETWORKAREA")) return;
1849 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1850 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
1851 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1852 if( !EqualRect( &area, &curr_val)) /* no message if rect has not changed */
1853 test_change_message( SPI_SETWORKAREA, 0);
1854 eq( area.left, curr_val.left, "left", "%d" );
1855 eq( area.top, curr_val.top, "top", "%d" );
1856 /* size may be rounded */
1857 ok( area.right >= curr_val.right - 16 && area.right < curr_val.right + 16,
1858 "right: got %d instead of %d\n", area.right, curr_val.right );
1859 ok( area.bottom >= curr_val.bottom - 16 && area.bottom < curr_val.bottom + 16,
1860 "bottom: got %d instead of %d\n", area.bottom, curr_val.bottom );
1861 curr_val = area;
1862 rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area,
1863 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1864 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1865 rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 );
1866 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
1867 if( !EqualRect( &area, &curr_val)) /* no message if rect has not changed */
1868 test_change_message( SPI_SETWORKAREA, 0 );
1869 eq( area.left, old_area.left, "left", "%d" );
1870 eq( area.top, old_area.top, "top", "%d" );
1871 /* size may be rounded */
1872 ok( area.right >= old_area.right - 16 && area.right < old_area.right + 16,
1873 "right: got %d instead of %d\n", area.right, old_area.right );
1874 ok( area.bottom >= old_area.bottom - 16 && area.bottom < old_area.bottom + 16,
1875 "bottom: got %d instead of %d\n", area.bottom, old_area.bottom );
1876 }
1877
1878 static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
1879 {
1880 BOOL rc;
1881 BOOL old_b;
1882 const UINT vals[]={TRUE,FALSE};
1883 unsigned int i;
1884
1885 trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
1886 SetLastError(0xdeadbeef);
1887 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 );
1888 /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1889 if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS"))
1890 return;
1891
1892 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1893 {
1894 UINT v;
1895
1896 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, vals[i], 0,
1897 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1898 if (!test_error_msg(rc,"SPI_SETSHOWSOUNDS")) return;
1899 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1900 test_change_message( SPI_SETSHOWSOUNDS, 1 );
1901 test_reg_key( SPI_SETSHOWSOUNDS_REGKEY,
1902 SPI_SETSHOWSOUNDS_VALNAME,
1903 vals[i] ? "1" : "0" );
1904
1905 rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &v, 0 );
1906 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1907 eq( v, vals[i], "SPI_GETSHOWSOUNDS", "%d" );
1908 eq( GetSystemMetrics( SM_SHOWSOUNDS ), (int)vals[i],
1909 "SM_SHOWSOUNDS", "%d" );
1910 }
1911
1912 rc=SystemParametersInfoA( SPI_SETSHOWSOUNDS, old_b, 0, SPIF_UPDATEINIFILE );
1913 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1914 }
1915
1916 static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
1917 {
1918 BOOL rc;
1919 BOOL old_b;
1920 const UINT vals[]={TRUE,FALSE};
1921 unsigned int i;
1922
1923 trace("testing SPI_{GET,SET}KEYBOARDPREF\n");
1924 SetLastError(0xdeadbeef);
1925 rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &old_b, 0 );
1926 if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDPREF"))
1927 return;
1928
1929 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1930 {
1931 BOOL v;
1932
1933 rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, vals[i], 0,
1934 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1935 if (!test_error_msg(rc,"SPI_SETKEYBOARDPREF")) return;
1936 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1937 test_change_message( SPI_SETKEYBOARDPREF, 1 );
1938 test_reg_key_ex2( SPI_SETKEYBOARDPREF_REGKEY, SPI_SETKEYBOARDPREF_REGKEY_LEGACY,
1939 SPI_SETKEYBOARDPREF_VALNAME, SPI_SETKEYBOARDPREF_VALNAME_LEGACY,
1940 vals[i] ? "1" : "0" );
1941
1942 rc=SystemParametersInfoA( SPI_GETKEYBOARDPREF, 0, &v, 0 );
1943 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1944 eq( v, (BOOL)vals[i], "SPI_GETKEYBOARDPREF", "%d" );
1945 }
1946
1947 rc=SystemParametersInfoA( SPI_SETKEYBOARDPREF, old_b, 0, SPIF_UPDATEINIFILE );
1948 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1949 }
1950
1951 static void test_SPI_SETSCREENREADER( void ) /* 71 */
1952 {
1953 BOOL rc;
1954 BOOL old_b;
1955 const UINT vals[]={TRUE,FALSE};
1956 unsigned int i;
1957
1958 trace("testing SPI_{GET,SET}SCREENREADER\n");
1959 SetLastError(0xdeadbeef);
1960 rc=SystemParametersInfoA( SPI_GETSCREENREADER, 0, &old_b, 0 );
1961 if (!test_error_msg(rc,"SPI_{GET,SET}SCREENREADER"))
1962 return;
1963
1964 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
1965 {
1966 BOOL v;
1967
1968 rc=SystemParametersInfoA( SPI_SETSCREENREADER, vals[i], 0,
1969 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
1970 if (!test_error_msg(rc,"SPI_SETSCREENREADER")) return;
1971 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1972 test_change_message( SPI_SETSCREENREADER, 1 );
1973 test_reg_key_ex2_optional( SPI_SETSCREENREADER_REGKEY, SPI_SETSCREENREADER_REGKEY_LEGACY,
1974 SPI_SETSCREENREADER_VALNAME, SPI_SETSCREENREADER_VALNAME_LEGACY,
1975 vals[i] ? "1" : "0" );
1976
1977 rc=SystemParametersInfoA( SPI_GETSCREENREADER, 0, &v, 0 );
1978 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
1979 eq( v, (BOOL)vals[i], "SPI_GETSCREENREADER", "%d" );
1980 }
1981
1982 rc=SystemParametersInfoA( SPI_SETSCREENREADER, old_b, 0, SPIF_UPDATEINIFILE );
1983 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
1984 }
1985
1986 static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
1987 {
1988 BOOL rc;
1989 BOOL old_b;
1990 DWORD old_type, old_contrast, old_orient;
1991 const UINT vals[]={0xffffffff,0,1,2};
1992 unsigned int i;
1993
1994 trace("testing SPI_{GET,SET}FONTSMOOTHING\n");
1995 if( iswin9x) return; /* 95/98/ME don't seem to implement this fully */
1996 SetLastError(0xdeadbeef);
1997 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &old_b, 0 );
1998 if (!test_error_msg(rc,"SPI_{GET,SET}FONTSMOOTHING"))
1999 return;
2000 SystemParametersInfoA( SPI_GETFONTSMOOTHINGTYPE, 0, &old_type, 0 );
2001 SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &old_contrast, 0 );
2002 SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &old_orient, 0 );
2003
2004 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2005 {
2006 UINT v;
2007
2008 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHING, vals[i], 0,
2009 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2010 if (!test_error_msg(rc,"SPI_SETFONTSMOOTHING")) return;
2011 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2012 test_change_message( SPI_SETFONTSMOOTHING, 0 );
2013 test_reg_key( SPI_SETFONTSMOOTHING_REGKEY,
2014 SPI_SETFONTSMOOTHING_VALNAME,
2015 vals[i] ? "2" : "0" );
2016
2017 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGTYPE, 0, UlongToPtr(vals[i]),
2018 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2019 if (!test_error_msg(rc,"SPI_SETFONTSMOOTHINGTYPE")) return;
2020 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2021 test_change_message( SPI_SETFONTSMOOTHINGTYPE, 0 );
2022 test_reg_key_dword( SPI_SETFONTSMOOTHING_REGKEY,
2023 SPI_SETFONTSMOOTHINGTYPE_VALNAME, &vals[i] );
2024
2025 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGCONTRAST, 0, UlongToPtr(vals[i]),
2026 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2027 if (!test_error_msg(rc,"SPI_SETFONTSMOOTHINGCONTRAST")) return;
2028 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2029 test_change_message( SPI_SETFONTSMOOTHINGCONTRAST, 0 );
2030 test_reg_key_dword( SPI_SETFONTSMOOTHING_REGKEY,
2031 SPI_SETFONTSMOOTHINGCONTRAST_VALNAME, &vals[i] );
2032
2033 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGORIENTATION, 0, UlongToPtr(vals[i]),
2034 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2035 if (!test_error_msg(rc,"SPI_SETFONTSMOOTHINGORIENTATION")) return;
2036 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2037 test_change_message( SPI_SETFONTSMOOTHINGORIENTATION, 0 );
2038 test_reg_key_dword( SPI_SETFONTSMOOTHING_REGKEY,
2039 SPI_SETFONTSMOOTHINGORIENTATION_VALNAME, &vals[i] );
2040
2041 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHING, 0, &v, 0 );
2042 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2043 eq( v, vals[i] ? 1 : 0, "SPI_GETFONTSMOOTHING", "%d" );
2044
2045 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHINGTYPE, 0, &v, 0 );
2046 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2047 ok( v == vals[i], "wrong value %x/%x\n", v, vals[i] );
2048
2049 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHINGCONTRAST, 0, &v, 0 );
2050 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2051 ok( v == vals[i], "wrong value %x/%x\n", v, vals[i] );
2052
2053 rc=SystemParametersInfoA( SPI_GETFONTSMOOTHINGORIENTATION, 0, &v, 0 );
2054 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2055 ok( v == vals[i], "wrong value %x/%x\n", v, vals[i] );
2056 }
2057
2058 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHING, old_b, 0, SPIF_UPDATEINIFILE );
2059 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2060 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGTYPE, old_type, 0, SPIF_UPDATEINIFILE );
2061 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2062 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGCONTRAST, old_contrast, 0, SPIF_UPDATEINIFILE );
2063 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2064 rc=SystemParametersInfoA( SPI_SETFONTSMOOTHINGORIENTATION, old_orient, 0, SPIF_UPDATEINIFILE );
2065 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2066 }
2067
2068 static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
2069 {
2070 BOOL rc;
2071 BOOL old_b;
2072 const UINT vals[]={TRUE,FALSE};
2073 unsigned int i;
2074
2075 trace("testing SPI_{GET,SET}LOWPOWERACTIVE\n");
2076 SetLastError(0xdeadbeef);
2077 rc=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE, 0, &old_b, 0 );
2078 if (!test_error_msg(rc,"SPI_{GET,SET}LOWPOWERACTIVE"))
2079 return;
2080
2081 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2082 {
2083 UINT v;
2084
2085 rc=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE, vals[i], 0,
2086 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2087 if (!test_error_msg(rc,"SPI_SETLOWPOWERACTIVE")) return;
2088 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2089 test_change_message( SPI_SETLOWPOWERACTIVE, 1 );
2090 test_reg_key_optional( SPI_SETLOWPOWERACTIVE_REGKEY,
2091 SPI_SETLOWPOWERACTIVE_VALNAME,
2092 vals[i] ? "1" : "0" );
2093
2094 /* SPI_SETLOWPOWERACTIVE is not persistent in win2k3 and above */
2095 v = 0xdeadbeef;
2096 rc=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE, 0, &v, 0 );
2097 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2098 ok(v == vals[i] ||
2099 broken(v == (0xdead0000 | vals[i])) || /* win98 only sets the low word */
2100 v == 0, /* win2k3 */
2101 "SPI_GETLOWPOWERACTIVE: got %d instead of 0 or %d\n", v, vals[i]);
2102 }
2103
2104 rc=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
2105 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2106 }
2107
2108 static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
2109 {
2110 BOOL rc;
2111 BOOL old_b;
2112 const UINT vals[]={TRUE,FALSE};
2113 unsigned int i;
2114
2115 trace("testing SPI_{GET,SET}POWEROFFACTIVE\n");
2116 SetLastError(0xdeadbeef);
2117 rc=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE, 0, &old_b, 0 );
2118 if (!test_error_msg(rc,"SPI_{GET,SET}POWEROFFACTIVE"))
2119 return;
2120
2121 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2122 {
2123 UINT v;
2124
2125 rc=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE, vals[i], 0,
2126 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2127 if (!test_error_msg(rc,"SPI_SETPOWEROFFACTIVE")) return;
2128 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2129 test_change_message( SPI_SETPOWEROFFACTIVE, 1 );
2130 test_reg_key_optional( SPI_SETPOWEROFFACTIVE_REGKEY,
2131 SPI_SETPOWEROFFACTIVE_VALNAME,
2132 vals[i] ? "1" : "0" );
2133
2134 /* SPI_SETPOWEROFFACTIVE is not persistent in win2k3 and above */
2135 v = 0xdeadbeef;
2136 rc=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE, 0, &v, 0 );
2137 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2138 ok(v == vals[i] ||
2139 broken(v == (0xdead0000 | vals[i])) || /* win98 only sets the low word */
2140 v == 0, /* win2k3 */
2141 "SPI_GETPOWEROFFACTIVE: got %d instead of 0 or %d\n", v, vals[i]);
2142 }
2143
2144 rc=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE, old_b, 0, SPIF_UPDATEINIFILE );
2145 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2146 }
2147
2148 static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
2149 {
2150 BOOL rc;
2151 BOOL old_b;
2152 const UINT vals[]={TRUE,FALSE};
2153 unsigned int i;
2154
2155 trace("testing SPI_{GET,SET}SNAPTODEFBUTTON\n");
2156 SetLastError(0xdeadbeef);
2157 rc=SystemParametersInfoA( SPI_GETSNAPTODEFBUTTON, 0, &old_b, 0 );
2158 if (!test_error_msg(rc,"SPI_GETSNAPTODEFBUTTON"))
2159 return;
2160
2161 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2162 {
2163 UINT v;
2164
2165 rc=SystemParametersInfoA( SPI_SETSNAPTODEFBUTTON, vals[i], 0,
2166 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2167 if (!test_error_msg(rc,"SPI_SETSNAPTODEFBUTTON")) return;
2168 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2169 test_change_message( SPI_SETSNAPTODEFBUTTON, 0 );
2170 test_reg_key_optional( SPI_SETSNAPTODEFBUTTON_REGKEY,
2171 SPI_SETSNAPTODEFBUTTON_VALNAME,
2172 vals[i] ? "1" : "0" );
2173
2174 rc=SystemParametersInfoA( SPI_GETSNAPTODEFBUTTON, 0, &v, 0 );
2175 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2176 eq( v, vals[i], "SPI_GETSNAPTODEFBUTTON", "%d" );
2177 }
2178
2179 rc=SystemParametersInfoA( SPI_SETSNAPTODEFBUTTON, old_b, 0, SPIF_UPDATEINIFILE );
2180 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2181 }
2182
2183 static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
2184 {
2185 BOOL rc;
2186 UINT old_width;
2187 const UINT vals[]={0,32767};
2188 unsigned int i;
2189
2190 trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n");
2191 SetLastError(0xdeadbeef);
2192 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &old_width, 0 );
2193 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2194 * what MSDN states (Verified on Win98SE)
2195 */
2196 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERWIDTH"))
2197 return;
2198
2199 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2200 {
2201 UINT v;
2202 char buf[10];
2203
2204 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, vals[i], 0,
2205 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2206 if (!test_error_msg(rc,"SPI_SETMOUSEHOVERWIDTH")) return;
2207 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2208 test_change_message( SPI_SETMOUSEHOVERWIDTH, 0 );
2209 sprintf( buf, "%d", vals[i] );
2210 test_reg_key( SPI_SETMOUSEHOVERWIDTH_REGKEY,
2211 SPI_SETMOUSEHOVERWIDTH_VALNAME, buf );
2212
2213 SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH, 0, &v, 0 );
2214 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2215 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERWIDTH", "%d" );
2216 }
2217
2218 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH, old_width, 0,
2219 SPIF_UPDATEINIFILE );
2220 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2221 }
2222
2223 static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
2224 {
2225 BOOL rc;
2226 UINT old_height;
2227 const UINT vals[]={0,32767};
2228 unsigned int i;
2229
2230 trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n");
2231 SetLastError(0xdeadbeef);
2232 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &old_height, 0 );
2233 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2234 * what MSDN states (Verified on Win98SE)
2235 */
2236 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERHEIGHT"))
2237 return;
2238
2239 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2240 {
2241 UINT v;
2242 char buf[10];
2243
2244 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, vals[i], 0,
2245 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2246 if (!test_error_msg(rc,"SPI_SETMOUSEHOVERHEIGHT")) return;
2247 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2248 test_change_message( SPI_SETMOUSEHOVERHEIGHT, 0 );
2249 sprintf( buf, "%d", vals[i] );
2250 test_reg_key( SPI_SETMOUSEHOVERHEIGHT_REGKEY,
2251 SPI_SETMOUSEHOVERHEIGHT_VALNAME, buf );
2252
2253 SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT, 0, &v, 0 );
2254 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2255 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERHEIGHT", "%d" );
2256 }
2257
2258 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT, old_height, 0,
2259 SPIF_UPDATEINIFILE );
2260 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2261 }
2262
2263 static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
2264 {
2265 BOOL rc;
2266 UINT old_time;
2267
2268 /* Windows XP accepts 10 as the minimum hover time. Any value below will be
2269 * defaulted to a value of 10 automatically.
2270 */
2271 const UINT vals[]={10,32767};
2272 unsigned int i;
2273
2274 trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n");
2275 SetLastError(0xdeadbeef);
2276 rc=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &old_time, 0 );
2277 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2278 * what MSDN states (Verified on Win98SE)
2279 */
2280 if (!test_error_msg(rc,"SPI_{GET,SET}MOUSEHOVERTIME"))
2281 return;
2282
2283 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2284 {
2285 UINT v;
2286 char buf[10];
2287
2288 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, vals[i], 0,
2289 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2290 if (!test_error_msg(rc,"SPI_SETMOUSEHOVERTIME")) return;
2291 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2292 test_change_message( SPI_SETMOUSEHOVERTIME, 0 );
2293 sprintf( buf, "%d", vals[i] );
2294 test_reg_key( SPI_SETMOUSEHOVERTIME_REGKEY,
2295 SPI_SETMOUSEHOVERTIME_VALNAME, buf );
2296
2297 SystemParametersInfoA( SPI_GETMOUSEHOVERTIME, 0, &v, 0 );
2298 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2299 eq( v, vals[i], "SPI_{GET,SET}MOUSEHOVERTIME", "%d" );
2300 }
2301
2302 rc=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME, old_time, 0,
2303 SPIF_UPDATEINIFILE );
2304 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2305 }
2306
2307 static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
2308 {
2309 BOOL rc;
2310 UINT old_lines;
2311 const UINT vals[]={0,32767};
2312 unsigned int i;
2313
2314 trace("testing SPI_{GET,SET}WHEELSCROLLLINES\n");
2315 SetLastError(0xdeadbeef);
2316 rc=SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &old_lines, 0 );
2317
2318 /* SPI_{GET,SET}WHEELSCROLLLINES not supported on Windows 95 */
2319 if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLLINES"))
2320 return;
2321
2322 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2323 {
2324 UINT v;
2325 char buf[10];
2326
2327 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, vals[i], 0,
2328 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2329 if (!test_error_msg(rc,"SPI_SETWHEELSCROLLLINES")) return;
2330 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2331 test_change_message( SPI_SETWHEELSCROLLLINES, 0 );
2332 sprintf( buf, "%d", vals[i] );
2333 test_reg_key( SPI_SETMOUSESCROLLLINES_REGKEY,
2334 SPI_SETMOUSESCROLLLINES_VALNAME, buf );
2335
2336 SystemParametersInfoA( SPI_GETWHEELSCROLLLINES, 0, &v, 0 );
2337 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2338 eq( v, vals[i], "SPI_{GET,SET}WHEELSCROLLLINES", "%d" );
2339 }
2340
2341 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES, old_lines, 0,
2342 SPIF_UPDATEINIFILE );
2343 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2344 }
2345
2346 static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
2347 {
2348 BOOL rc;
2349 UINT old_delay;
2350 const UINT vals[]={0,32767};
2351 unsigned int i;
2352
2353 trace("testing SPI_{GET,SET}MENUSHOWDELAY\n");
2354 SetLastError(0xdeadbeef);
2355 rc=SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &old_delay, 0 );
2356
2357 /* SPI_{GET,SET}MENUSHOWDELAY not supported on Windows 95 */
2358 if (!test_error_msg(rc,"SPI_{GET,SET}MENUSHOWDELAY"))
2359 return;
2360
2361 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2362 {
2363 UINT v;
2364 char buf[10];
2365
2366 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, vals[i], 0,
2367 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2368 if (!test_error_msg(rc,"SPI_SETMENUSHOWDELAY")) return;
2369 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2370 test_change_message( SPI_SETMENUSHOWDELAY, 0 );
2371 sprintf( buf, "%d", vals[i] );
2372 test_reg_key( SPI_SETMENUSHOWDELAY_REGKEY,
2373 SPI_SETMENUSHOWDELAY_VALNAME, buf );
2374
2375 SystemParametersInfoA( SPI_GETMENUSHOWDELAY, 0, &v, 0 );
2376 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2377 eq( v, vals[i], "SPI_{GET,SET}MENUSHOWDELAY", "%d" );
2378 }
2379
2380 rc=SystemParametersInfoA( SPI_SETMENUSHOWDELAY, old_delay, 0,
2381 SPIF_UPDATEINIFILE );
2382 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2383 }
2384
2385 static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
2386 {
2387 BOOL rc;
2388 UINT old_chars;
2389 const UINT vals[]={32767,0};
2390 unsigned int i;
2391
2392 trace("testing SPI_{GET,SET}WHEELSCROLLCHARS\n");
2393 SetLastError(0xdeadbeef);
2394 rc=SystemParametersInfoA( SPI_GETWHEELSCROLLCHARS, 0, &old_chars, 0 );
2395
2396 /* SPI_{GET,SET}WHEELSCROLLCHARS not supported on Windows 95 */
2397 if (!test_error_msg(rc,"SPI_{GET,SET}WHEELSCROLLCHARS"))
2398 return;
2399
2400 for (i=0;i<sizeof(vals)/sizeof(*vals);i++)
2401 {
2402 UINT v;
2403 char buf[10];
2404
2405 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLCHARS, vals[i], 0,
2406 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE );
2407 if (!test_error_msg(rc,"SPI_SETWHEELSCROLLCHARS")) return;
2408 test_change_message( SPI_SETWHEELSCROLLCHARS, 0 );
2409 sprintf( buf, "%d", vals[i] );
2410 test_reg_key( SPI_SETMOUSESCROLLCHARS_REGKEY,
2411 SPI_SETMOUSESCROLLCHARS_VALNAME, buf );
2412
2413 SystemParametersInfoA( SPI_GETWHEELSCROLLCHARS, 0, &v, 0 );
2414 ok(rc!=0,"%d: rc=%d err=%d\n",i,rc,GetLastError());
2415 eq( v, vals[i], "SPI_{GET,SET}WHEELSCROLLCHARS", "%d" );
2416 }
2417
2418 rc=SystemParametersInfoA( SPI_SETWHEELSCROLLCHARS, old_chars, 0,
2419 SPIF_UPDATEINIFILE );
2420 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2421 }
2422
2423 static void test_SPI_SETWALLPAPER( void ) /* 115 */
2424 {
2425 BOOL rc;
2426 char oldval[260];
2427 char newval[260];
2428
2429 trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
2430 SetLastError(0xdeadbeef);
2431 rc=SystemParametersInfoA(SPI_GETDESKWALLPAPER, 260, oldval, 0);
2432 /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
2433 * unimplemented on NT4
2434 */
2435 if (!test_error_msg(rc,"SPI_{GET,SET}DESKWALLPAPER"))
2436 return;
2437
2438 strcpy(newval, "");
2439 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, newval, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
2440 if (!test_error_msg(rc,"SPI_SETDESKWALLPAPER")) return;
2441 ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,GetLastError());
2442 test_change_message(SPI_SETDESKWALLPAPER, 0);
2443
2444 rc=SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, oldval, SPIF_UPDATEINIFILE);
2445 ok(rc!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc,GetLastError());
2446
2447 test_reg_key(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, oldval);
2448 }
2449
2450 static void test_WM_DISPLAYCHANGE(void)
2451 {
2452 DEVMODE mode, startmode;
2453 int start_bpp, last_set_bpp = 0;
2454 int test_bpps[] = {8, 16, 24, 32}, i;
2455 LONG change_ret;
2456 DWORD wait_ret;
2457
2458 if (!pChangeDisplaySettingsExA)
2459 {
2460 win_skip("ChangeDisplaySettingsExA is not available\n");
2461 return;
2462 }
2463
2464 displaychange_test_active = TRUE;
2465
2466 memset(&startmode, 0, sizeof(startmode));
2467 startmode.dmSize = sizeof(startmode);
2468 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &startmode);
2469 start_bpp = startmode.dmBitsPerPel;
2470
2471 displaychange_sem = CreateSemaphore(NULL, 0, 1, NULL);
2472
2473 for(i = 0; i < sizeof(test_bpps)/sizeof(test_bpps[0]); i++) {
2474 last_bpp = -1;
2475
2476 memset(&mode, 0, sizeof(mode));
2477 mode.dmSize = sizeof(mode);
2478 mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
2479 mode.dmBitsPerPel = test_bpps[i];
2480 mode.dmPelsWidth = GetSystemMetrics(SM_CXSCREEN);
2481 mode.dmPelsHeight = GetSystemMetrics(SM_CYSCREEN);
2482
2483 change_counter = 0; /* This sends a SETTINGSCHANGE message as well in which we aren't interested */
2484 displaychange_ok = TRUE;
2485 change_ret = pChangeDisplaySettingsExA(NULL, &mode, NULL, 0, NULL);
2486 /* Wait quite long for the message, screen setting changes can take some time */
2487 if(change_ret == DISP_CHANGE_SUCCESSFUL) {
2488 wait_ret = WaitForSingleObject(displaychange_sem, 10000);
2489 /* we may not get a notification if nothing changed */
2490 if (wait_ret == WAIT_TIMEOUT && !last_set_bpp && start_bpp == test_bpps[i])
2491 continue;
2492 ok(wait_ret == WAIT_OBJECT_0, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
2493 }
2494 displaychange_ok = FALSE;
2495
2496 if(change_ret != DISP_CHANGE_SUCCESSFUL) {
2497 skip("Setting depth %d failed(ret = %d)\n", test_bpps[i], change_ret);
2498 ok(last_bpp == -1, "WM_DISPLAYCHANGE was sent with wParam %d despite mode change failure\n", last_bpp);
2499 continue;
2500 }
2501
2502 if(start_bpp != test_bpps[i]) {
2503 todo_wine ok(last_bpp == test_bpps[i], "Set bpp %d, but WM_DISPLAYCHANGE reported bpp %d\n", test_bpps[i], last_bpp);
2504 } else {
2505 ok(last_bpp == test_bpps[i], "Set bpp %d, but WM_DISPLAYCHANGE reported bpp %d\n", test_bpps[i], last_bpp);
2506 }
2507 last_set_bpp = test_bpps[i];
2508 }
2509
2510 if(start_bpp != last_set_bpp && last_set_bpp != 0) {
2511 memset(&mode, 0, sizeof(mode));
2512 mode.dmSize = sizeof(mode);
2513 mode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
2514 mode.dmBitsPerPel = start_bpp;
2515 mode.dmPelsWidth = GetSystemMetrics(SM_CXSCREEN);
2516 mode.dmPelsHeight = GetSystemMetrics(SM_CYSCREEN);
2517
2518 displaychange_ok = TRUE;
2519 change_ret = pChangeDisplaySettingsExA(NULL, &mode, NULL, 0, NULL);
2520 WaitForSingleObject(displaychange_sem, 10000);
2521 displaychange_ok = FALSE;
2522 CloseHandle(displaychange_sem);
2523 displaychange_sem = 0;
2524 }
2525
2526 displaychange_test_active = FALSE;
2527 }
2528
2529 /*
2530 * Registry entries for the system parameters.
2531 * Names are created by 'SET' flags names.
2532 * We assume that corresponding 'GET' entries use the same registry keys.
2533 */
2534 static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam )
2535 {
2536 test_SPI_SETBEEP(); /* 1 */
2537 test_SPI_SETMOUSE(); /* 4 */
2538 test_SPI_SETBORDER(); /* 6 */
2539 test_SPI_SETKEYBOARDSPEED(); /* 10 */
2540 test_SPI_ICONHORIZONTALSPACING(); /* 13 */
2541 test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
2542 test_SPI_SETSCREENSAVEACTIVE(); /* 17 */
2543 test_SPI_SETGRIDGRANULARITY(); /* 19 */
2544 test_SPI_SETKEYBOARDDELAY(); /* 23 */
2545 test_SPI_ICONVERTICALSPACING(); /* 24 */
2546 test_SPI_SETICONTITLEWRAP(); /* 26 */
2547 test_SPI_SETMENUDROPALIGNMENT(); /* 28 */
2548 test_SPI_SETDOUBLECLKWIDTH(); /* 29 */
2549 test_SPI_SETDOUBLECLKHEIGHT(); /* 30 */
2550 test_SPI_SETDOUBLECLICKTIME(); /* 32 */
2551 test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */
2552 test_SPI_SETFASTTASKSWITCH(); /* 36 */
2553 test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
2554 /* test_WM_DISPLAYCHANGE seems to be somewhat buggy on
2555 * some versions of Windows (Vista, Win2k8, Win7B) in that
2556 * not all metrics are properly restored. Problems are
2557 * SM_CXMAXTRACK, SM_CYMAXTRACK
2558 * Fortunately setting the Non-Client metrics like in
2559 * test_SPI_SETNONCLIENTMETRICS will correct this. That is why
2560 * we do the DISPLAY change now... */
2561 test_WM_DISPLAYCHANGE();
2562 test_SPI_SETNONCLIENTMETRICS(); /* 42 */
2563 test_SPI_SETMINIMIZEDMETRICS(); /* 44 */
2564 test_SPI_SETICONMETRICS(); /* 46 */
2565 test_SPI_SETWORKAREA(); /* 47 */
2566 test_SPI_SETSHOWSOUNDS(); /* 57 */
2567 test_SPI_SETKEYBOARDPREF(); /* 69 */
2568 test_SPI_SETSCREENREADER(); /* 71 */
2569 test_SPI_SETFONTSMOOTHING(); /* 75 */
2570 test_SPI_SETLOWPOWERACTIVE(); /* 85 */
2571 test_SPI_SETPOWEROFFACTIVE(); /* 86 */
2572 test_SPI_SETSNAPTODEFBUTTON(); /* 95 */
2573 test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */
2574 test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */
2575 test_SPI_SETMOUSEHOVERTIME(); /* 103 */
2576 test_SPI_SETWHEELSCROLLLINES(); /* 105 */
2577 test_SPI_SETMENUSHOWDELAY(); /* 107 */
2578 test_SPI_SETWHEELSCROLLCHARS(); /* 108 */
2579 test_SPI_SETWALLPAPER(); /* 115 */
2580
2581
2582 SendMessageA( ghTestWnd, WM_DESTROY, 0, 0 );
2583 return 0;
2584 }
2585
2586 /* test calculation of GetSystemMetrics values (mostly) from non client metrics,
2587 * icon metrics and minimized metrics.
2588 */
2589
2590 /* copied from wine's GdiGetCharDimensions, which is not available on most
2591 * windows versions */
2592 static LONG _GdiGetCharDimensions(HDC hdc, LPTEXTMETRICA lptm, LONG *height)
2593 {
2594 SIZE sz;
2595 static const CHAR alphabet[] = {
2596 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
2597 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
2598 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
2599
2600 if(lptm && !GetTextMetricsA(hdc, lptm)) return 0;
2601
2602 if(!GetTextExtentPointA(hdc, alphabet, 52, &sz)) return 0;
2603
2604 if (height) *height = sz.cy;
2605 return (sz.cx / 26 + 1) / 2;
2606 }
2607
2608 /* get text metrics and/or "average" char width of the specified logfont
2609 * for the specified dc */
2610 static void get_text_metr_size( HDC hdc, LOGFONTA *plf, TEXTMETRICA * ptm, UINT *psz)
2611 {
2612 HFONT hfont, hfontsav;
2613 TEXTMETRICA tm;
2614 if( !ptm) ptm = &tm;
2615 hfont = CreateFontIndirectA( plf);
2616 if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) {
2617 ptm->tmHeight = -1;
2618 if( psz) *psz = 10;
2619 if( hfont) DeleteObject( hfont);
2620 return;
2621 }
2622 GetTextMetricsA( hdc, ptm);
2623 if( psz)
2624 if( !(*psz = _GdiGetCharDimensions( hdc, ptm, NULL)))
2625 *psz = 10;
2626 SelectObject( hdc, hfontsav);
2627 DeleteObject( hfont);
2628 }
2629
2630 static int gsm_error_ctr;
2631
2632 #define ok_gsm( i, e)\
2633 {\
2634 int exp = (e);\
2635 int act = GetSystemMetrics( (i));\
2636 if( exp != act) gsm_error_ctr++;\
2637 ok( !( exp != act),"GetSystemMetrics(%s): expected %d actual %d\n", #i, exp,act);\
2638 }
2639 #define ok_gsm_2( i, e1, e2)\
2640 {\
2641 int exp1 = (e1);\
2642 int exp2 = (e2);\
2643 int act = GetSystemMetrics( (i));\
2644 if( exp1 != act && exp2 != act) gsm_error_ctr++;\
2645 ok( !( exp1 != act && exp2 != act), "GetSystemMetrics(%s): expected %d or %d actual %d\n", #i, exp1, exp2, act);\
2646 }
2647 #define ok_gsm_3( i, e1, e2, e3)\
2648 {\
2649 int exp1 = (e1);\
2650 int exp2 = (e2);\
2651 int exp3 = (e3);\
2652 int act = GetSystemMetrics( (i));\
2653 if( exp1 != act && exp2 != act && exp3 != act) gsm_error_ctr++;\
2654 ok( !( exp1 != act && exp2 != act && exp3 != act),"GetSystemMetrics(%s): expected %d or %d or %d actual %d\n", #i, exp1, exp2, exp3, act);\
2655 }
2656
2657 static void test_GetSystemMetrics( void)
2658 {
2659 TEXTMETRICA tmMenuFont;
2660 UINT IconSpacing, IconVerticalSpacing;
2661 BOOL rc;
2662
2663 HDC hdc = CreateIC( "Display", 0, 0, 0);
2664 UINT avcwCaption;
2665 INT CaptionWidthfromreg;
2666 MINIMIZEDMETRICS minim;
2667 NONCLIENTMETRICS ncm;
2668 SIZE screen;
2669
2670 assert(sizeof(ncm) == 344);
2671
2672 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth);
2673 rc = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
2674 ok(rc, "SystemParametersInfoA failed\n");
2675
2676 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth) - 1;
2677 rc = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
2678 ok(!rc, "SystemParametersInfoA should fail\n");
2679
2680 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth) + 1;
2681 SetLastError(0xdeadbeef);
2682 rc = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
2683 ok(!rc, "SystemParametersInfoA should fail\n");
2684
2685 ncm.cbSize = sizeof(ncm); /* Vista added padding */
2686 SetLastError(0xdeadbeef);
2687 rc = SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
2688 ok(rc || broken(!rc) /* before Vista */, "SystemParametersInfoA failed\n");
2689
2690 minim.cbSize = sizeof( minim);
2691 ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICS, iPaddedBorderWidth);
2692 SystemParametersInfo( SPI_GETMINIMIZEDMETRICS, 0, &minim, 0);
2693 rc = SystemParametersInfo( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
2694 if( !rc) {
2695 win_skip("SPI_GETNONCLIENTMETRICS is not available\n");
2696 return;
2697 }
2698 /* CaptionWidth from the registry may have different value of iCaptionWidth
2699 * from the non client metrics (observed on WinXP) */
2700 CaptionWidthfromreg = metricfromreg(
2701 "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi);
2702 get_text_metr_size( hdc, &ncm.lfMenuFont, &tmMenuFont, NULL);
2703 get_text_metr_size( hdc, &ncm.lfCaptionFont, NULL, &avcwCaption);
2704 /* FIXME: use icon metric */
2705 if( !SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &IconVerticalSpacing, 0))
2706 IconVerticalSpacing = 0;
2707 if( !SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &IconSpacing, 0 ))
2708 IconSpacing = 0;
2709 /* reset error counters */
2710 gsm_error_ctr = 0;
2711
2712 /* the tests: */
2713
2714 /* SM_CXSCREEN, cannot test these two */
2715 /* SM_CYSCREEN */
2716 ok_gsm( SM_CXVSCROLL, ncm.iScrollWidth);
2717 ok_gsm( SM_CYHSCROLL, ncm.iScrollWidth);
2718 ok_gsm( SM_CYCAPTION, ncm.iCaptionHeight+1);
2719 ok_gsm( SM_CXBORDER, 1);
2720 ok_gsm( SM_CYBORDER, 1);
2721 ok_gsm( SM_CXDLGFRAME, 3);
2722 ok_gsm( SM_CYDLGFRAME, 3);
2723 ok_gsm( SM_CYVTHUMB, ncm.iScrollHeight);
2724 ok_gsm( SM_CXHTHUMB, ncm.iScrollHeight);
2725 /* SM_CXICON */
2726 /* SM_CYICON */
2727 /* SM_CXCURSOR */
2728 /* SM_CYCURSOR */
2729 ok_gsm( SM_CYMENU, ncm.iMenuHeight + 1);
2730 ok_gsm( SM_CXFULLSCREEN,
2731 GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME));
2732 ok_gsm( SM_CYFULLSCREEN,
2733 GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN));
2734 /* SM_CYKANJIWINDOW */
2735 /* SM_MOUSEPRESENT */
2736 ok_gsm( SM_CYVSCROLL, ncm.iScrollHeight);
2737 ok_gsm( SM_CXHSCROLL, ncm.iScrollHeight);
2738 /* SM_DEBUG */
2739 /* SM_SWAPBUTTON */
2740 /* SM_RESERVED1 */
2741 /* SM_RESERVED2 */
2742 /* SM_RESERVED3 */
2743 /* SM_RESERVED4 */
2744 ok_gsm( SM_CXMIN, 3 * max( CaptionWidthfromreg >= 0 ? CaptionWidthfromreg : ncm.iCaptionWidth, 8) +
2745 GetSystemMetrics( SM_CYSIZE) + 4 + 4 * avcwCaption + 2 * GetSystemMetrics( SM_CXFRAME));
2746 ok_gsm( SM_CYMIN, GetSystemMetrics( SM_CYCAPTION) +
2747 2 * GetSystemMetrics( SM_CYFRAME));
2748 ok_gsm_2( SM_CXSIZE,
2749 ncm.iCaptionWidth, /* classic/standard windows style */
2750 GetSystemMetrics( SM_CYCAPTION) - 1 /* WinXP style */
2751 );
2752 ok_gsm( SM_CYSIZE, ncm.iCaptionHeight);
2753 ok_gsm( SM_CXFRAME, ncm.iBorderWidth + 3);
2754 ok_gsm( SM_CYFRAME, ncm.iBorderWidth + 3);
2755 ok_gsm( SM_CXMINTRACK, GetSystemMetrics( SM_CXMIN));
2756 ok_gsm( SM_CYMINTRACK, GetSystemMetrics( SM_CYMIN));
2757 /* SM_CXDOUBLECLK */
2758 /* SM_CYDOUBLECLK */
2759 if( IconSpacing) ok_gsm( SM_CXICONSPACING, IconSpacing);
2760 if( IconVerticalSpacing) ok_gsm( SM_CYICONSPACING, IconVerticalSpacing);
2761 /* SM_MENUDROPALIGNMENT */
2762 /* SM_PENWINDOWS */
2763 /* SM_DBCSENABLED */
2764 /* SM_CMOUSEBUTTONS */
2765 /* SM_SECURE */
2766 ok_gsm( SM_CXEDGE, 2);
2767 ok_gsm( SM_CYEDGE, 2);
2768 /* sign-extension for iHorzGap/iVertGap is broken on Win9x */
2769 ok_gsm( SM_CXMINSPACING, GetSystemMetrics( SM_CXMINIMIZED) + (short)minim.iHorzGap );
2770 ok_gsm( SM_CYMINSPACING, GetSystemMetrics( SM_CYMINIMIZED) + (short)minim.iVertGap );
2771 /* SM_CXSMICON */
2772 /* SM_CYSMICON */
2773 ok_gsm( SM_CYSMCAPTION, ncm.iSmCaptionHeight + 1);
2774 ok_gsm_3( SM_CXSMSIZE,
2775 ncm.iSmCaptionWidth, /* classic/standard windows style */
2776 GetSystemMetrics( SM_CYSMCAPTION) - 1, /* WinXP style */
2777 smcxsmsize /* winXP seems to cache this value: setnonclientmetric
2778 does not change it */
2779 );
2780 ok_gsm( SM_CYSMSIZE, GetSystemMetrics( SM_CYSMCAPTION) - 1);
2781 ok_gsm( SM_CXMENUSIZE, ncm.iMenuWidth);
2782 ok_gsm( SM_CYMENUSIZE, ncm.iMenuHeight);
2783 /* SM_ARRANGE */
2784 ok_gsm( SM_CXMINIMIZED, minim.iWidth + 6);
2785 ok_gsm( SM_CYMINIMIZED, GetSystemMetrics( SM_CYCAPTION) + 5);
2786 screen.cx = GetSystemMetrics( SM_CXVIRTUALSCREEN );
2787 screen.cy = GetSystemMetrics( SM_CYVIRTUALSCREEN );
2788 if (!screen.cx || !screen.cy) /* not supported on NT4 */
2789 {
2790 screen.cx = GetSystemMetrics( SM_CXSCREEN );
2791 screen.cy = GetSystemMetrics( SM_CYSCREEN );
2792 }
2793 ok_gsm_2( SM_CXMAXTRACK, screen.cx + 4 + 2 * GetSystemMetrics(SM_CXFRAME),
2794 screen.cx - 4 + 2 * GetSystemMetrics(SM_CXFRAME)); /* Vista */
2795 ok_gsm_2( SM_CYMAXTRACK, screen.cy + 4 + 2 * GetSystemMetrics(SM_CYFRAME),
2796 screen.cy - 4 + 2 * GetSystemMetrics(SM_CYFRAME)); /* Vista */
2797 /* the next two cannot really be tested as they depend on (application)
2798 * toolbars */
2799 /* SM_CXMAXIMIZED */
2800 /* SM_CYMAXIMIZED */
2801 /* SM_NETWORK */
2802 /* */
2803 /* */
2804 /* */
2805 /* SM_CLEANBOOT */
2806 /* SM_CXDRAG */
2807 /* SM_CYDRAG */
2808 /* SM_SHOWSOUNDS */
2809 ok_gsm( SM_CXMENUCHECK,
2810 ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1);
2811 ok_gsm( SM_CYMENUCHECK,
2812 ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1);
2813 /* SM_SLOWMACHINE */
2814 /* SM_MIDEASTENABLED */
2815 /* SM_MOUSEWHEELPRESENT */
2816 /* SM_XVIRTUALSCREEN */
2817 /* SM_YVIRTUALSCREEN */
2818 /* SM_CXVIRTUALSCREEN */
2819 /* SM_CYVIRTUALSCREEN */
2820 /* SM_CMONITORS */
2821 /* SM_SAMEDISPLAYFORMAT */
2822 /* SM_IMMENABLED */
2823 /* SM_CXFOCUSBORDER */
2824 /* SM_CYFOCUSBORDER */
2825 /* SM_TABLETPC */
2826 /* SM_MEDIACENTER */
2827 /* SM_CMETRICS */
2828 /* end of tests */
2829 if( gsm_error_ctr ) { /* if any errors where found */
2830 trace( "BorderWidth %d CaptionWidth %d CaptionHeight %d IconSpacing %d IconVerticalSpacing %d\n",
2831 ncm.iBorderWidth, ncm.iCaptionWidth, ncm.iCaptionHeight, IconSpacing, IconVerticalSpacing);
2832 trace( "MenuHeight %d MenuWidth %d ScrollHeight %d ScrollWidth %d SmCaptionHeight %d SmCaptionWidth %d\n",
2833 ncm.iMenuHeight, ncm.iMenuWidth, ncm.iScrollHeight, ncm.iScrollWidth, ncm.iSmCaptionHeight, ncm.iSmCaptionWidth);
2834 trace( "Captionfontchar width %d MenuFont %d,%d CaptionWidth from registry: %d screen %d,%d\n",
2835 avcwCaption, tmMenuFont.tmHeight, tmMenuFont.tmExternalLeading, CaptionWidthfromreg, screen.cx, screen.cy);
2836 }
2837 ReleaseDC( 0, hdc);
2838 }
2839
2840 static void test_EnumDisplaySettings(void)
2841 {
2842 DEVMODE devmode;
2843 DWORD val;
2844 HDC hdc;
2845 DWORD num;
2846
2847 memset(&devmode, 0, sizeof(devmode));
2848 /* Win95 doesn't handle ENUM_CURRENT_SETTINGS correctly */
2849 EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode);
2850
2851 hdc = GetDC(0);
2852 val = GetDeviceCaps(hdc, BITSPIXEL);
2853 ok(devmode.dmBitsPerPel == val ||
2854 broken(devmode.dmDeviceName[0] == 0), /* Win95 */
2855 "GetDeviceCaps(BITSPIXEL) returned %d, EnumDisplaySettings returned %d\n",
2856 val, devmode.dmBitsPerPel);
2857
2858 val = GetDeviceCaps(hdc, NUMCOLORS);
2859 if(devmode.dmBitsPerPel <= 8) {
2860 ok(val == 256, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode.dmBitsPerPel, val);
2861 } else {
2862 ok(val == -1, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode.dmBitsPerPel, val);
2863 }
2864
2865 ReleaseDC(0, hdc);
2866
2867 num = 1;
2868 while (1) {
2869 SetLastError (0xdeadbeef);
2870 if (!EnumDisplaySettings(NULL, num++, &devmode)) {
2871 DWORD le = GetLastError();
2872 ok(le == ERROR_NO_MORE_FILES ||
2873 le == 0xdeadbeef, /* XP, 2003 */
2874 "Expected ERROR_NO_MORE_FILES or 0xdeadbeef, got %d\n", le);
2875 break;
2876 }
2877 }
2878 }
2879
2880 static void test_GetSysColorBrush(void)
2881 {
2882 HBRUSH hbr;
2883
2884 SetLastError(0xdeadbeef);
2885 hbr = GetSysColorBrush(-1);
2886 ok(hbr == NULL, "Expected NULL brush\n");
2887 ok(GetLastError() == 0xdeadbeef, "Expected last error not set, got %x\n", GetLastError());
2888 /* greater than max index */
2889 hbr = GetSysColorBrush(COLOR_MENUBAR);
2890 if (hbr)
2891 {
2892 SetLastError(0xdeadbeef);
2893 hbr = GetSysColorBrush(COLOR_MENUBAR + 1);
2894 ok(hbr == NULL, "Expected NULL brush\n");
2895 ok(GetLastError() == 0xdeadbeef, "Expected last error not set, got %x\n", GetLastError());
2896 }
2897 else
2898 win_skip("COLOR_MENUBAR unsupported\n");
2899 }
2900
2901 START_TEST(sysparams)
2902 {
2903 int argc;
2904 char** argv;
2905 WNDCLASSA wc;
2906 MSG msg;
2907 HANDLE hThread;
2908 DWORD dwThreadId;
2909 HANDLE hInstance, hdll;
2910
2911 hdll = GetModuleHandleA("user32.dll");
2912 pChangeDisplaySettingsExA=(void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA");
2913
2914 hInstance = GetModuleHandleA( NULL );
2915 hdc = GetDC(0);
2916 dpi = GetDeviceCaps( hdc, LOGPIXELSY);
2917 iswin9x = GetVersion() & 0x80000000;
2918
2919 /* This test requires interactivity, if we don't have it, give up */
2920 if (!SystemParametersInfoA( SPI_SETBEEP, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ) &&
2921 GetLastError()==ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION) return;
2922
2923 argc = winetest_get_mainargs(&argv);
2924 strict=(argc >= 3 && strcmp(argv[2],"strict")==0);
2925 trace("strict=%d\n",strict);
2926
2927 trace("testing GetSystemMetrics with your current desktop settings\n");
2928 test_GetSystemMetrics( );
2929 trace("testing EnumDisplaySettings vs GetDeviceCaps\n");
2930 test_EnumDisplaySettings( );
2931 test_GetSysColorBrush( );
2932
2933 change_counter = 0;
2934 change_last_param = 0;
2935
2936 wc.lpszClassName = "SysParamsTestClass";
2937 wc.lpfnWndProc = SysParamsTestWndProc;
2938 wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
2939 wc.hInstance = hInstance;
2940 wc.hIcon = LoadIconA( 0, IDI_APPLICATION );
2941 wc.hCursor = LoadCursorA( 0, IDC_ARROW );
2942 wc.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
2943 wc.lpszMenuName = 0;
2944 wc.cbClsExtra = 0;
2945 wc.cbWndExtra = 0;
2946 RegisterClassA( &wc );
2947
2948 ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
2949 WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL );
2950
2951 hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId );
2952 assert( hThread );
2953 CloseHandle( hThread );
2954
2955 while( GetMessageA( &msg, 0, 0, 0 )) {
2956 TranslateMessage( &msg );
2957 DispatchMessageA( &msg );
2958 }
2959 ReleaseDC( 0, hdc);
2960
2961 }