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