1 /* Unit test suite for functions SystemParametersInfo and GetSystemMetrics.
3 * Copyright 2002 Andriy Palamarchuk
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.
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.
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
26 #define _WIN32_WINNT 0x0600 /* For SPI_GETMOUSEHOVERWIDTH and more */
27 #define _WIN32_IE 0x0700
29 #include "wine/test.h"
37 #ifndef SPI_GETDESKWALLPAPER
38 # define SPI_GETDESKWALLPAPER 0x0073
41 static LONG (WINAPI
*pChangeDisplaySettingsExA
)(LPCSTR
, LPDEVMODEA
, HWND
, DWORD
, LPVOID
);
48 #define eq(received, expected, label, type) \
49 ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected))
52 #define SPI_SETBEEP_REGKEY "Control Panel\\Sound"
53 #define SPI_SETBEEP_VALNAME "Beep"
54 #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse"
55 #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1"
56 #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2"
57 #define SPI_SETMOUSE_VALNAME3 "MouseSpeed"
58 #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics"
59 #define SPI_SETBORDER_REGKEY2 "Control Panel\\Desktop"
60 #define SPI_SETBORDER_VALNAME "BorderWidth"
61 #define SPI_METRIC_REGKEY "Control Panel\\Desktop\\WindowMetrics"
62 #define SPI_SCROLLWIDTH_VALNAME "ScrollWidth"
63 #define SPI_SCROLLHEIGHT_VALNAME "ScrollHeight"
64 #define SPI_CAPTIONWIDTH_VALNAME "CaptionWidth"
65 #define SPI_CAPTIONHEIGHT_VALNAME "CaptionHeight"
66 #define SPI_CAPTIONFONT_VALNAME "CaptionFont"
67 #define SPI_SMCAPTIONWIDTH_VALNAME "SmCaptionWidth"
68 #define SPI_SMCAPTIONHEIGHT_VALNAME "SmCaptionHeight"
69 #define SPI_SMCAPTIONFONT_VALNAME "SmCaptionFont"
70 #define SPI_MENUWIDTH_VALNAME "MenuWidth"
71 #define SPI_MENUHEIGHT_VALNAME "MenuHeight"
72 #define SPI_MENUFONT_VALNAME "MenuFont"
73 #define SPI_STATUSFONT_VALNAME "StatusFont"
74 #define SPI_MESSAGEFONT_VALNAME "MessageFont"
76 #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard"
77 #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed"
78 #define SPI_ICONHORIZONTALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics"
79 #define SPI_ICONHORIZONTALSPACING_REGKEY2 "Control Panel\\Desktop"
80 #define SPI_ICONHORIZONTALSPACING_VALNAME "IconSpacing"
81 #define SPI_ICONVERTICALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics"
82 #define SPI_ICONVERTICALSPACING_REGKEY2 "Control Panel\\Desktop"
83 #define SPI_ICONVERTICALSPACING_VALNAME "IconVerticalSpacing"
84 #define SPI_MINIMIZEDMETRICS_REGKEY "Control Panel\\Desktop\\WindowMetrics"
85 #define SPI_MINWIDTH_VALNAME "MinWidth"
86 #define SPI_MINHORZGAP_VALNAME "MinHorzGap"
87 #define SPI_MINVERTGAP_VALNAME "MinVertGap"
88 #define SPI_MINARRANGE_VALNAME "MinArrange"
89 #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop"
90 #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut"
91 #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop"
92 #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive"
93 #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop"
94 #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity"
95 #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard"
96 #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay"
97 #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics"
98 #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop"
99 #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap"
100 #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows"
101 #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop"
102 #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment"
103 #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse"
104 #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop"
105 #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth"
106 #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse"
107 #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop"
108 #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight"
109 #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse"
110 #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed"
111 #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse"
112 #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons"
113 #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop"
114 #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea"
115 #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds"
116 #define SPI_SETSHOWSOUNDS_VALNAME "On"
117 #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Accessibility\\Keyboard Preference"
118 #define SPI_SETKEYBOARDPREF_VALNAME "On"
119 #define SPI_SETKEYBOARDPREF_REGKEY_LEGACY "Control Panel\\Accessibility"
120 #define SPI_SETKEYBOARDPREF_VALNAME_LEGACY "Keyboard Preference"
121 #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Accessibility\\Blind Access"
122 #define SPI_SETSCREENREADER_VALNAME "On"
123 #define SPI_SETSCREENREADER_REGKEY_LEGACY "Control Panel\\Accessibility"
124 #define SPI_SETSCREENREADER_VALNAME_LEGACY "Blind Access"
125 #define SPI_SETFONTSMOOTHING_REGKEY "Control Panel\\Desktop"
126 #define SPI_SETFONTSMOOTHING_VALNAME "FontSmoothing"
127 #define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop"
128 #define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive"
129 #define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop"
130 #define SPI_SETPOWEROFFACTIVE_VALNAME "PowerOffActive"
131 #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop"
132 #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows"
133 #define SPI_SETSNAPTODEFBUTTON_REGKEY "Control Panel\\Mouse"
134 #define SPI_SETSNAPTODEFBUTTON_VALNAME "SnapToDefaultButton"
135 #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse"
136 #define SPI_SETMOUSEHOVERWIDTH_VALNAME "MouseHoverWidth"
137 #define SPI_SETMOUSEHOVERHEIGHT_REGKEY "Control Panel\\Mouse"
138 #define SPI_SETMOUSEHOVERHEIGHT_VALNAME "MouseHoverHeight"
139 #define SPI_SETMOUSEHOVERTIME_REGKEY "Control Panel\\Mouse"
140 #define SPI_SETMOUSEHOVERTIME_VALNAME "MouseHoverTime"
141 #define SPI_SETMOUSESCROLLCHARS_REGKEY "Control Panel\\Desktop"
142 #define SPI_SETMOUSESCROLLCHARS_VALNAME "WheelScrollChars"
143 #define SPI_SETMOUSESCROLLLINES_REGKEY "Control Panel\\Desktop"
144 #define SPI_SETMOUSESCROLLLINES_VALNAME "WheelScrollLines"
145 #define SPI_SETMENUSHOWDELAY_REGKEY "Control Panel\\Desktop"
146 #define SPI_SETMENUSHOWDELAY_VALNAME "MenuShowDelay"
147 #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop"
148 #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper"
150 /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */
151 #define WINE_CURRENT_USER_REGKEY "Wine"
153 static HWND ghTestWnd
;
155 static DWORD WINAPI
SysParamsThreadFunc( LPVOID lpParam
);
156 static LRESULT CALLBACK
SysParamsTestWndProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
158 static int change_counter
;
159 static int change_setworkarea_param
, change_iconverticalspacing_param
;
160 static int change_last_param
;
162 static BOOL displaychange_ok
= FALSE
, displaychange_test_active
= FALSE
;
163 static HANDLE displaychange_sem
= 0;
165 static LRESULT CALLBACK
SysParamsTestWndProc( HWND hWnd
, UINT msg
, WPARAM wParam
,
170 case WM_DISPLAYCHANGE
:
171 ok(displaychange_ok
, "Unexpected WM_DISPLAYCHANGE message\n");
173 displaychange_ok
= FALSE
;
174 ReleaseSemaphore(displaychange_sem
, 1, 0);
177 case WM_SETTINGCHANGE
:
178 if (change_counter
>0) {
179 /* ignore these messages caused by resizing of toolbars */
180 if( wParam
== SPI_SETWORKAREA
){
181 change_setworkarea_param
= 1;
183 } else if( wParam
== SPI_ICONVERTICALSPACING
) {
184 change_iconverticalspacing_param
= 1;
186 } else if( displaychange_test_active
)
188 if( !change_last_param
){
189 change_last_param
= wParam
;
192 ok(0,"too many changes counter=%d last change=%d\n",
193 change_counter
,change_last_param
);
195 change_last_param
= wParam
;
199 change_last_param
= change_setworkarea_param
= change_iconverticalspacing_param
=0;
200 if( wParam
== SPI_SETWORKAREA
)
201 change_setworkarea_param
= 1;
202 else if( wParam
== SPI_ICONVERTICALSPACING
)
203 change_iconverticalspacing_param
= 1;
205 change_last_param
= wParam
;
209 PostQuitMessage( 0 );
214 return( DefWindowProcA( hWnd
, msg
, wParam
, lParam
) );
221 Performs testing for system parameters messages
223 - system parameter id
224 - supposed value of the registry key
226 static void test_change_message( int action
, int optional
)
228 if (change_counter
==0 && optional
==1)
230 ok( 1 == change_counter
,
231 "Missed a message: change_counter=%d\n", change_counter
);
233 ok( action
== change_last_param
||
234 ( change_setworkarea_param
&& action
== SPI_SETWORKAREA
) ||
235 ( change_iconverticalspacing_param
&& action
== SPI_ICONVERTICALSPACING
),
236 "Wrong action got %d expected %d\n", change_last_param
, action
);
237 change_last_param
= 0;
240 static BOOL
test_error_msg ( int rc
, const char *name
)
242 DWORD last_error
= GetLastError();
246 if (last_error
==0xdeadbeef || last_error
==ERROR_INVALID_SPI_VALUE
|| last_error
==ERROR_INVALID_PARAMETER
)
248 trace("%s not supported on this platform. Skipping test\n", name
);
250 else if (last_error
==ERROR_ACCESS_DENIED
)
252 trace("%s does not have privileges to run. Skipping test\n", name
);
256 trace("%s failed for reason: %d. Indicating test failure and skipping remainder of test\n",name
,last_error
);
257 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,last_error
);
263 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,last_error
);
269 * Tests the HKEY_CURRENT_USER subkey value.
270 * The value should contain string value.
273 * lpsSubKey - subkey name
274 * lpsRegName - registry entry name
275 * lpsTestValue - value to test
277 static void _test_reg_key( LPCSTR subKey1
, LPCSTR subKey2
, LPCSTR valName1
, LPCSTR valName2
, LPCSTR testValue
)
279 CHAR value
[MAX_PATH
];
287 valueLen
=sizeof(value
);
288 RegOpenKeyA( HKEY_CURRENT_USER
, subKey1
, &hKey
);
289 rc
=RegQueryValueExA( hKey
, valName1
, NULL
, &type
, (LPBYTE
)value
, &valueLen
);
291 if (rc
==ERROR_SUCCESS
)
293 ok( !strcmp( testValue
, value
),
294 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
295 subKey1
, valName1
, testValue
, value
);
300 ok(0,"Missing registry entry: subKey=%s, valName=%s\n",
306 valueLen
=sizeof(value
);
307 RegOpenKeyA( HKEY_CURRENT_USER
, subKey1
, &hKey
);
308 rc
=RegQueryValueExA( hKey
, valName2
, NULL
, &type
, (LPBYTE
)value
, &valueLen
);
310 if (rc
==ERROR_SUCCESS
)
312 ok( !strcmp( testValue
, value
),
313 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
314 subKey1
, valName2
, testValue
, value
);
319 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
323 if (subKey2
&& !strict
)
326 valueLen
=sizeof(value
);
327 RegOpenKeyA( HKEY_CURRENT_USER
, subKey2
, &hKey
);
328 rc
=RegQueryValueExA( hKey
, valName1
, NULL
, &type
, (LPBYTE
)value
, &valueLen
);
330 if (rc
==ERROR_SUCCESS
)
332 ok( !strcmp( testValue
, value
),
333 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
334 subKey2
, valName1
, testValue
, value
);
339 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
345 valueLen
=sizeof(value
);
346 RegOpenKeyA( HKEY_CURRENT_USER
, subKey2
, &hKey
);
347 rc
=RegQueryValueExA( hKey
, valName2
, NULL
, &type
, (LPBYTE
)value
, &valueLen
);
349 if (rc
==ERROR_SUCCESS
)
351 ok( !strcmp( testValue
, value
),
352 "Wrong value in registry: subKey=%s, valName=%s, testValue=%s, value=%s\n",
353 subKey2
, valName2
, testValue
, value
);
358 ok( 0,"Missing registry entry: subKey=%s, valName=%s\n",
363 ok(found
,"Missing registry values: %s or %s in keys: %s or %s\n",
364 valName1
, (valName2
?valName2
:"<n/a>"), subKey1
, (subKey2
?subKey2
:"<n/a>") );
367 #define test_reg_key( subKey, valName, testValue ) \
368 _test_reg_key( subKey, NULL, valName, NULL, testValue )
369 #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \
370 _test_reg_key( subKey1, subKey2, valName, NULL, testValue )
371 #define test_reg_key_ex2( subKey1, subKey2, valName1, valName2, testValue ) \
372 _test_reg_key( subKey1, subKey2, valName1, valName2, testValue )
374 /* get a metric from the registry. If the value is negative
375 * it is assumed to be in twips and converted to pixels */
376 static UINT
metricfromreg( const char *keyname
, const char *valname
, int dpi
)
384 RegOpenKeyA( HKEY_CURRENT_USER
, keyname
, &hkey
);
386 ret
=RegQueryValueExA( hkey
, valname
, NULL
, &type
, (LPBYTE
)buf
, &size
);
388 if( ret
!= ERROR_SUCCESS
) return -1;
391 value
= ( -value
* dpi
+ 720) / 1440;
407 BYTE lfClipPrecision
;
409 BYTE lfPitchAndFamily
;
410 CHAR lfFaceName
[LF_FACESIZE
];
411 } LOGFONT16
, *LPLOGFONT16
;
413 /* get logfont from the registry */
414 static int lffromreg( const char *keyname
, const char *valname
, LOGFONTA
*plf
)
418 DWORD ret
, size
, type
;
420 RegOpenKeyA( HKEY_CURRENT_USER
, keyname
, &hkey
);
422 ret
=RegQueryValueExA( hkey
, valname
, NULL
, &type
, (LPBYTE
)&lfw
, &size
);
424 ok( ret
== ERROR_SUCCESS
, "Key \"%s\" value \"%s\" not found\n", keyname
, valname
);
425 if( ret
!= ERROR_SUCCESS
)
427 if( size
<= sizeof( LOGFONT16
)) {
428 LOGFONT16
*plf16
= (LOGFONT16
*) &lfw
;
429 plf
->lfHeight
= plf16
->lfHeight
;
430 plf
->lfWidth
= plf16
->lfWidth
;
431 plf
->lfEscapement
= plf16
->lfEscapement
;
432 plf
->lfOrientation
= plf16
->lfOrientation
;
433 plf
->lfWeight
= plf16
->lfWeight
;
434 plf
->lfItalic
= plf16
->lfItalic
;
435 plf
->lfUnderline
= plf16
->lfUnderline
;
436 plf
->lfStrikeOut
= plf16
->lfStrikeOut
;
437 plf
->lfCharSet
= plf16
->lfCharSet
;
438 plf
->lfOutPrecision
= plf16
->lfOutPrecision
;
439 plf
->lfClipPrecision
= plf16
->lfClipPrecision
;
440 plf
->lfQuality
= plf16
->lfQuality
;
441 plf
->lfPitchAndFamily
= plf16
->lfPitchAndFamily
;
442 memcpy( plf
->lfFaceName
, plf16
->lfFaceName
, LF_FACESIZE
);
443 } else if( size
<= sizeof( LOGFONTA
)) {
444 plf
= (LOGFONTA
*) &lfw
;
446 plf
->lfHeight
= lfw
.lfHeight
;
447 plf
->lfWidth
= lfw
.lfWidth
;
448 plf
->lfEscapement
= lfw
.lfEscapement
;
449 plf
->lfOrientation
= lfw
.lfOrientation
;
450 plf
->lfWeight
= lfw
.lfWeight
;
451 plf
->lfItalic
= lfw
.lfItalic
;
452 plf
->lfUnderline
= lfw
.lfUnderline
;
453 plf
->lfStrikeOut
= lfw
.lfStrikeOut
;
454 plf
->lfCharSet
= lfw
.lfCharSet
;
455 plf
->lfOutPrecision
= lfw
.lfOutPrecision
;
456 plf
->lfClipPrecision
= lfw
.lfClipPrecision
;
457 plf
->lfQuality
= lfw
.lfQuality
;
458 plf
->lfPitchAndFamily
= lfw
.lfPitchAndFamily
;
459 WideCharToMultiByte( CP_ACP
, 0, lfw
.lfFaceName
, -1, plf
->lfFaceName
,
460 LF_FACESIZE
, NULL
, NULL
);
466 static void test_SPI_SETBEEP( void ) /* 2 */
473 trace("testing SPI_{GET,SET}BEEP\n");
474 SetLastError(0xdeadbeef);
475 rc
=SystemParametersInfoA( SPI_GETBEEP
, 0, &old_b
, 0 );
476 if (!test_error_msg(rc
,"SPI_{GET,SET}BEEP"))
480 rc
=SystemParametersInfoA( SPI_SETBEEP
, curr_val
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
481 if (!test_error_msg(rc
,"SPI_SETBEEP")) return;
482 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
483 test_change_message( SPI_SETBEEP
, 0 );
484 test_reg_key( SPI_SETBEEP_REGKEY
,
486 curr_val
? "Yes" : "No" );
487 rc
=SystemParametersInfoA( SPI_GETBEEP
, 0, &b
, 0 );
488 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
489 eq( b
, curr_val
, "SPI_{GET,SET}BEEP", "%d" );
490 rc
=SystemParametersInfoW( SPI_GETBEEP
, 0, &b
, 0 );
491 if (rc
!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED
)
493 ok(rc
!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc
,GetLastError());
494 eq( b
, curr_val
, "SystemParametersInfoW", "%d" );
497 /* is a message sent for the second change? */
498 rc
=SystemParametersInfoA( SPI_SETBEEP
, curr_val
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
499 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
500 test_change_message( SPI_SETBEEP
, 0 );
503 rc
=SystemParametersInfoW( SPI_SETBEEP
, curr_val
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
504 if (rc
==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
505 rc
=SystemParametersInfoA( SPI_SETBEEP
, curr_val
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
506 ok(rc
!=0,"SystemParametersInfo: rc=%d err=%d\n",rc
,GetLastError());
507 test_change_message( SPI_SETBEEP
, 0 );
508 test_reg_key( SPI_SETBEEP_REGKEY
,
510 curr_val
? "Yes" : "No" );
511 rc
=SystemParametersInfoA( SPI_GETBEEP
, 0, &b
, 0 );
512 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
513 eq( b
, curr_val
, "SPI_{GET,SET}BEEP", "%d" );
514 rc
=SystemParametersInfoW( SPI_GETBEEP
, 0, &b
, 0 );
515 if (rc
!=0 || GetLastError()!=ERROR_CALL_NOT_IMPLEMENTED
)
517 ok(rc
!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc
,GetLastError());
518 eq( b
, curr_val
, "SystemParametersInfoW", "%d" );
520 ok( MessageBeep( MB_OK
), "Return value of MessageBeep when sound is disabled\n" );
522 rc
=SystemParametersInfoA( SPI_SETBEEP
, old_b
, 0, SPIF_UPDATEINIFILE
);
523 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
526 static const char *setmouse_valuenames
[3] = {
527 SPI_SETMOUSE_VALNAME1
,
528 SPI_SETMOUSE_VALNAME2
,
529 SPI_SETMOUSE_VALNAME3
533 * Runs check for one setting of spi_setmouse.
535 static BOOL
run_spi_setmouse_test( int curr_val
[], POINT
*req_change
, POINT
*proj_change
, int nchange
)
539 static int aw_turn
= 0;
540 static BOOL w_implemented
= 1;
547 if ((aw_turn
% 2!=0) && (w_implemented
))
549 /* call unicode on odd (non even) calls */
550 SetLastError(0xdeadbeef);
551 rc
=SystemParametersInfoW( SPI_SETMOUSE
, 0, curr_val
, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
552 if (rc
==0 && GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
555 trace("SystemParametersInfoW not supported on this platform\n");
559 if ((aw_turn
% 2==0) || (!w_implemented
))
561 /* call ascii version on even calls or if unicode is not available */
562 rc
=SystemParametersInfoA( SPI_SETMOUSE
, 0, curr_val
, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
564 if (!test_error_msg(rc
,"SPI_SETMOUSE")) return FALSE
;
566 ok(rc
!=0,"SystemParametersInfo: rc=%d err=%d\n",rc
,GetLastError());
567 test_change_message( SPI_SETMOUSE
, 0 );
568 for (i
= 0; i
< 3; i
++)
570 sprintf( buf
, "%d", curr_val
[i
] );
571 test_reg_key( SPI_SETMOUSE_REGKEY
, setmouse_valuenames
[i
], buf
);
574 rc
=SystemParametersInfoA( SPI_GETMOUSE
, 0, mi
, 0 );
575 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
576 for (i
= 0; i
< 3; i
++)
578 ok(mi
[i
] == curr_val
[i
],
579 "incorrect value for %d: %d != %d\n", i
, mi
[i
], curr_val
[i
]);
584 rc
=SystemParametersInfoW( SPI_GETMOUSE
, 0, mi
, 0 );
585 ok(rc
!=0,"SystemParametersInfoW: rc=%d err=%d\n",rc
,GetLastError());
586 for (i
= 0; i
< 3; i
++)
588 ok(mi
[i
] == curr_val
[i
],
589 "incorrect value for %d: %d != %d\n", i
, mi
[i
], curr_val
[i
]);
595 /* FIXME: this always fails for me - AJ */
596 for (i
= 0; i
< nchange
; i
++)
599 mouse_event( MOUSEEVENTF_ABSOLUTE
| MOUSEEVENTF_MOVE
, 0, 0, 0, 0 );
600 mouse_event( MOUSEEVENTF_MOVE
, req_change
[i
].x
, req_change
[i
].y
, 0, 0 );
602 ok( proj_change
[i
].x
== mv
.x
, "Projected dx and real dx comparison. May fail under high load.\n" );
603 ok( proj_change
[i
].y
== mv
.y
, "Projected dy equals real dy. May fail under high load.\n" );
609 static void test_SPI_SETMOUSE( void ) /* 4 */
614 /* win nt default values - 6, 10, 1 */
615 INT curr_val
[3] = {6, 10, 1};
617 /* requested and projected mouse movements */
618 POINT req_change
[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
619 POINT proj_change1
[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
620 POINT proj_change2
[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} };
621 POINT proj_change3
[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
622 POINT proj_change4
[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} };
623 POINT proj_change5
[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} };
624 POINT proj_change6
[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
625 POINT proj_change7
[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
626 POINT proj_change8
[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} };
628 int nchange
= sizeof( req_change
) / sizeof( POINT
);
630 trace("testing SPI_{GET,SET}MOUSE\n");
631 SetLastError(0xdeadbeef);
632 rc
=SystemParametersInfoA( SPI_GETMOUSE
, 0, old_mi
, 0 );
633 if (!test_error_msg(rc
,"SPI_{GET,SET}MOUSE"))
636 if (!run_spi_setmouse_test( curr_val
, req_change
, proj_change1
, nchange
)) return;
638 /* acceleration change */
640 run_spi_setmouse_test( curr_val
, req_change
, proj_change2
, nchange
);
642 /* acceleration change */
644 run_spi_setmouse_test( curr_val
, req_change
, proj_change3
, nchange
);
646 /* acceleration change */
648 run_spi_setmouse_test( curr_val
, req_change
, proj_change4
, nchange
);
650 /* threshold change */
653 run_spi_setmouse_test( curr_val
, req_change
, proj_change5
, nchange
);
655 /* threshold change */
659 run_spi_setmouse_test( curr_val
, req_change
, proj_change6
, nchange
);
661 /* threshold change */
663 run_spi_setmouse_test( curr_val
, req_change
, proj_change7
, nchange
);
665 /* threshold change */
667 run_spi_setmouse_test( curr_val
, req_change
, proj_change8
, nchange
);
669 rc
=SystemParametersInfoA( SPI_SETMOUSE
, 0, old_mi
, SPIF_UPDATEINIFILE
);
670 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
673 static BOOL
test_setborder(UINT curr_val
, int usesetborder
, int dpi
)
678 NONCLIENTMETRICSA ncm
;
680 ncm
.cbSize
= sizeof( ncm
);
681 rc
=SystemParametersInfo( SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
682 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
684 rc
=SystemParametersInfoA( SPI_SETBORDER
, curr_val
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
685 if (!test_error_msg(rc
,"SPI_SETBORDER")) return FALSE
;
686 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
687 test_change_message( SPI_SETBORDER
, 1 );
688 } else { /* set non client metrics */
689 ncm
.iBorderWidth
= curr_val
;
690 rc
=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS
, 0, &ncm
, SPIF_UPDATEINIFILE
|
692 if (!test_error_msg(rc
,"SPI_SETNONCLIENTMETRICS")) return FALSE
;
693 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
694 test_change_message( SPI_SETNONCLIENTMETRICS
, 1 );
696 if( curr_val
) { /* skip if 0, some windows versions return 0 others 1 */
697 regval
= metricfromreg( SPI_SETBORDER_REGKEY2
, SPI_SETBORDER_VALNAME
, dpi
);
698 if( regval
!= curr_val
)
699 regval
= metricfromreg( SPI_SETBORDER_REGKEY
, SPI_SETBORDER_VALNAME
, dpi
);
700 ok( regval
==curr_val
, "wrong value in registry %d, expected %d\n", regval
, curr_val
);
702 /* minimum border width is 1 */
703 if (curr_val
== 0) curr_val
= 1;
704 /* should be the same as the non client metrics */
705 rc
=SystemParametersInfo( SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
706 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
707 eq( (UINT
)ncm
.iBorderWidth
, curr_val
, "NonClientMetric.iBorderWidth", "%d");
708 /* and from SPI_GETBORDER */
709 rc
=SystemParametersInfoA( SPI_GETBORDER
, 0, &border
, 0 );
710 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
711 eq( border
, curr_val
, "SPI_{GET,SET}BORDER", "%d");
712 /* test some SystemMetrics */
713 frame
= curr_val
+ GetSystemMetrics( SM_CXDLGFRAME
);
714 eq( frame
, GetSystemMetrics( SM_CXFRAME
), "SM_CXFRAME", "%d" );
715 eq( frame
, GetSystemMetrics( SM_CYFRAME
), "SM_CYFRAME", "%d" );
716 eq( frame
, GetSystemMetrics( SM_CXSIZEFRAME
), "SM_CXSIZEFRAME", "%d" );
717 eq( frame
, GetSystemMetrics( SM_CYSIZEFRAME
), "SM_CYSIZEFRAME", "%d" );
721 static void test_SPI_SETBORDER( void ) /* 6 */
725 NONCLIENTMETRICSA ncmsave
;
729 ncmsave
.cbSize
= sizeof( ncmsave
);
730 rc
=SystemParametersInfo( SPI_GETNONCLIENTMETRICS
, 0, &ncmsave
, 0);
732 win_skip("SPI_GETNONCLIENTMETRICS is not available\n");
735 /* CaptionWidth from the registry may have different value of iCaptionWidth
736 * from the non client metrics (observed on WinXP).
737 * Fix this so we can safely restore settings with the nonclientmetrics */
738 CaptionWidth
= metricfromreg(
739 "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi
);
740 ncmsave
.iCaptionWidth
= CaptionWidth
;
742 /* These tests hang when XFree86 4.0 for Windows is running (tested on
743 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
746 if (FindWindowA( NULL
, "Cygwin/XFree86" ))
749 trace("testing SPI_{GET,SET}BORDER\n");
751 SetLastError(0xdeadbeef);
752 rc
=SystemParametersInfoA( SPI_GETBORDER
, 0, &old_border
, 0 );
753 if (!test_error_msg(rc
,"SPI_{GET,SET}BORDER"))
755 /* FIXME: include new PaddedBorderWidth parameter */
756 PaddedBorderWidth
= ncmsave
.iBorderWidth
- old_border
;
757 if( PaddedBorderWidth
){
758 win_skip( "Can not reliable restore border width yet (PaddedBorderWidth = %d)\n",
762 /* This will restore sane values if the test hang previous run. */
763 if ( old_border
== 7 || old_border
== 20 )
766 /* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to
767 * do it twice to make the intended change). So skip parts of the tests on
770 /* win2k3 fails if you set the same border twice, or if size is 0 */
771 if (!test_setborder(2, 1, dpi
)) return;
772 test_setborder(1, 1, dpi
);
773 test_setborder(3, 1, dpi
);
775 if (!test_setborder(1, 0, dpi
)) return;
776 test_setborder(0, 0, dpi
);
777 test_setborder(3, 0, dpi
);
779 rc
=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS
, 0, &ncmsave
,
780 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
781 test_change_message( SPI_SETNONCLIENTMETRICS
, 1 );
782 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",
786 static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */
790 const UINT vals
[]={0,20,31};
793 trace("testing SPI_{GET,SET}KEYBOARDSPEED\n");
794 SetLastError(0xdeadbeef);
795 rc
=SystemParametersInfoA( SPI_GETKEYBOARDSPEED
, 0, &old_speed
, 0 );
796 if (!test_error_msg(rc
,"SPI_{GET,SET}KEYBOARDSPEED"))
799 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
804 rc
=SystemParametersInfoA( SPI_SETKEYBOARDSPEED
, vals
[i
], 0,
805 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
806 if (!test_error_msg(rc
,"SPI_SETKEYBOARDSPEED")) return;
807 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
808 test_change_message( SPI_SETKEYBOARDSPEED
, 0 );
809 sprintf( buf
, "%d", vals
[i
] );
810 test_reg_key( SPI_SETKEYBOARDSPEED_REGKEY
, SPI_SETKEYBOARDSPEED_VALNAME
, buf
);
812 rc
=SystemParametersInfoA( SPI_GETKEYBOARDSPEED
, 0, &v
, 0 );
813 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
814 eq( v
, vals
[i
], "SPI_{GET,SET}KEYBOARDSPEED", "%d" );
817 rc
=SystemParametersInfoA( SPI_SETKEYBOARDSPEED
, old_speed
, 0, SPIF_UPDATEINIFILE
);
818 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
821 /* test_SPI_ICONHORIZONTALSPACING helper */
822 static BOOL
dotest_spi_iconhorizontalspacing( INT curr_val
)
828 rc
=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, curr_val
, 0,
829 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
830 if (!test_error_msg(rc
,"SPI_ICONHORIZONTALSPACING")) return FALSE
;
831 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
832 test_change_message( SPI_ICONHORIZONTALSPACING
, 0 );
833 if( curr_val
< 32) curr_val
= 32;
834 /* The registry keys depend on the Windows version and the values too
835 * let's test (works on win95,ME,NT4,2k,XP)
837 regval
= metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY2
, SPI_ICONHORIZONTALSPACING_VALNAME
, dpi
);
838 if( regval
!= curr_val
)
839 regval
= metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY
, SPI_ICONHORIZONTALSPACING_VALNAME
, dpi
);
840 ok( curr_val
== regval
,
841 "wrong value in registry %d, expected %d\n", regval
, curr_val
);
842 /* compare with what SPI_ICONHORIZONTALSPACING returns */
843 rc
=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0, &spacing
, 0 );
844 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
845 eq( spacing
, curr_val
, "ICONHORIZONTALSPACING", "%d");
846 /* and with a system metrics */
847 eq( GetSystemMetrics( SM_CXICONSPACING
), curr_val
, "SM_CXICONSPACING", "%d" );
848 /* and with what SPI_GETICONMETRICS returns */
849 im
.cbSize
= sizeof(ICONMETRICSA
);
850 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im
, FALSE
);
851 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
852 eq( im
.iHorzSpacing
, curr_val
, "SPI_GETICONMETRICS", "%d" );
856 static void test_SPI_ICONHORIZONTALSPACING( void ) /* 13 */
861 trace("testing SPI_ICONHORIZONTALSPACING\n");
862 SetLastError(0xdeadbeef);
863 /* default value: 75 */
864 rc
=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0, &old_spacing
, 0 );
865 if (!test_error_msg(rc
,"SPI_ICONHORIZONTALSPACING"))
867 /* do not increase the value as it would upset the user's icon layout */
868 if (!dotest_spi_iconhorizontalspacing( old_spacing
- 1)) return;
869 dotest_spi_iconhorizontalspacing( 10); /* minimum is 32 */
871 rc
=SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, old_spacing
, 0, SPIF_UPDATEINIFILE
);
872 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
875 static void test_SPI_SETSCREENSAVETIMEOUT( void ) /* 14 */
879 const UINT vals
[]={0,32767};
882 trace("testing SPI_{GET,SET}SCREENSAVETIMEOUT\n");
883 SetLastError(0xdeadbeef);
884 rc
=SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT
, 0, &old_timeout
, 0 );
885 if (!test_error_msg(rc
,"SPI_{GET,SET}SCREENSAVETIMEOUT"))
888 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
893 rc
=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT
, vals
[i
], 0,
894 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
895 if (!test_error_msg(rc
,"SPI_SETSCREENSAVETIMEOUT")) return;
896 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
897 test_change_message( SPI_SETSCREENSAVETIMEOUT
, 0 );
898 sprintf( buf
, "%d", vals
[i
] );
899 test_reg_key( SPI_SETSCREENSAVETIMEOUT_REGKEY
,
900 SPI_SETSCREENSAVETIMEOUT_VALNAME
, buf
);
902 SystemParametersInfoA( SPI_GETSCREENSAVETIMEOUT
, 0, &v
, 0 );
903 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
904 eq( v
, vals
[i
], "SPI_{GET,SET}SCREENSAVETIMEOUT", "%d" );
907 rc
=SystemParametersInfoA( SPI_SETSCREENSAVETIMEOUT
, old_timeout
, 0,
908 SPIF_UPDATEINIFILE
);
909 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
912 static void test_SPI_SETSCREENSAVEACTIVE( void ) /* 17 */
916 const UINT vals
[]={TRUE
,FALSE
};
919 trace("testing SPI_{GET,SET}SCREENSAVEACTIVE\n");
920 SetLastError(0xdeadbeef);
921 rc
=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE
, 0, &old_b
, 0 );
922 if (!test_error_msg(rc
,"SPI_{GET,SET}SCREENSAVEACTIVE"))
925 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
929 rc
=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE
, vals
[i
], 0,
930 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
931 if (!test_error_msg(rc
,"SPI_SETSCREENSAVEACTIVE")) return;
932 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
933 test_change_message( SPI_SETSCREENSAVEACTIVE
, 0 );
934 test_reg_key( SPI_SETSCREENSAVEACTIVE_REGKEY
,
935 SPI_SETSCREENSAVEACTIVE_VALNAME
,
936 vals
[i
] ? "1" : "0" );
938 rc
=SystemParametersInfoA( SPI_GETSCREENSAVEACTIVE
, 0, &v
, 0 );
939 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
940 eq( v
, vals
[i
], "SPI_{GET,SET}SCREENSAVEACTIVE", "%d" );
943 rc
=SystemParametersInfoA( SPI_SETSCREENSAVEACTIVE
, old_b
, 0, SPIF_UPDATEINIFILE
);
944 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
947 static void test_SPI_SETGRIDGRANULARITY( void ) /* 19 */
952 static void test_SPI_SETKEYBOARDDELAY( void ) /* 23 */
956 const UINT vals
[]={0,3};
959 trace("testing SPI_{GET,SET}KEYBOARDDELAY\n");
960 SetLastError(0xdeadbeef);
961 rc
=SystemParametersInfoA( SPI_GETKEYBOARDDELAY
, 0, &old_delay
, 0 );
962 if (!test_error_msg(rc
,"SPI_{GET,SET}KEYBOARDDELAY"))
965 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
970 rc
=SystemParametersInfoA( SPI_SETKEYBOARDDELAY
, vals
[i
], 0,
971 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
972 if (!test_error_msg(rc
,"SPI_SETKEYBOARDDELAY")) return;
973 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
974 test_change_message( SPI_SETKEYBOARDDELAY
, 0 );
975 sprintf( buf
, "%d", vals
[i
] );
976 test_reg_key( SPI_SETKEYBOARDDELAY_REGKEY
,
977 SPI_SETKEYBOARDDELAY_VALNAME
, buf
);
979 rc
=SystemParametersInfoA( SPI_GETKEYBOARDDELAY
, 0, &delay
, 0 );
980 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
981 eq( delay
, vals
[i
], "SPI_{GET,SET}KEYBOARDDELAY", "%d" );
984 rc
=SystemParametersInfoA( SPI_SETKEYBOARDDELAY
, old_delay
, 0, SPIF_UPDATEINIFILE
);
985 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
989 /* test_SPI_ICONVERTICALSPACING helper */
990 static BOOL
dotest_spi_iconverticalspacing( INT curr_val
)
996 rc
=SystemParametersInfoA( SPI_ICONVERTICALSPACING
, curr_val
, 0,
997 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
998 if (!test_error_msg(rc
,"SPI_ICONVERTICALSPACING")) return FALSE
;
999 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1000 test_change_message( SPI_ICONVERTICALSPACING
, 0 );
1001 if( curr_val
< 32) curr_val
= 32;
1002 /* The registry keys depend on the Windows version and the values too
1003 * let's test (works on win95,ME,NT4,2k,XP)
1005 regval
= metricfromreg( SPI_ICONVERTICALSPACING_REGKEY2
, SPI_ICONVERTICALSPACING_VALNAME
, dpi
);
1006 if( regval
!= curr_val
)
1007 regval
= metricfromreg( SPI_ICONVERTICALSPACING_REGKEY
, SPI_ICONVERTICALSPACING_VALNAME
, dpi
);
1008 ok( curr_val
== regval
,
1009 "wrong value in registry %d, expected %d\n", regval
, curr_val
);
1010 /* compare with what SPI_ICONVERTICALSPACING returns */
1011 rc
=SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0, &spacing
, 0 );
1012 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1013 eq( spacing
, curr_val
, "ICONVERTICALSPACING", "%d" );
1014 /* and with a system metrics */
1015 eq( GetSystemMetrics( SM_CYICONSPACING
), curr_val
, "SM_CYICONSPACING", "%d" );
1016 /* and with what SPI_GETICONMETRICS returns */
1017 im
.cbSize
= sizeof(ICONMETRICSA
);
1018 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im
, FALSE
);
1019 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1020 eq( im
.iVertSpacing
, curr_val
, "SPI_GETICONMETRICS", "%d" );
1024 static void test_SPI_ICONVERTICALSPACING( void ) /* 24 */
1029 trace("testing SPI_ICONVERTICALSPACING\n");
1030 SetLastError(0xdeadbeef);
1031 /* default value: 75 */
1032 rc
=SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0, &old_spacing
, 0 );
1033 if (!test_error_msg(rc
,"SPI_ICONVERTICALSPACING"))
1035 /* do not increase the value as it would upset the user's icon layout */
1036 if (!dotest_spi_iconverticalspacing( old_spacing
- 1)) return;
1037 /* same tests with a value less than the minimum 32 */
1038 dotest_spi_iconverticalspacing( 10);
1040 rc
=SystemParametersInfoA( SPI_ICONVERTICALSPACING
, old_spacing
, 0,
1041 SPIF_UPDATEINIFILE
);
1042 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",
1046 static void test_SPI_SETICONTITLEWRAP( void ) /* 26 */
1050 const UINT vals
[]={TRUE
,FALSE
};
1054 /* These tests hang when XFree86 4.0 for Windows is running (tested on
1055 * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is
1058 if (FindWindowA( NULL
, "Cygwin/XFree86" ))
1061 trace("testing SPI_{GET,SET}ICONTITLEWRAP\n");
1062 SetLastError(0xdeadbeef);
1063 rc
=SystemParametersInfoA( SPI_GETICONTITLEWRAP
, 0, &old_b
, 0 );
1064 if (!test_error_msg(rc
,"SPI_{GET,SET}ICONTITLEWRAP"))
1067 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1072 rc
=SystemParametersInfoA( SPI_SETICONTITLEWRAP
, vals
[i
], 0,
1073 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1074 if (!test_error_msg(rc
,"SPI_SETICONTITLEWRAP")) return;
1075 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1076 test_change_message( SPI_SETICONTITLEWRAP
, 1 );
1077 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2
,
1078 SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1079 if( regval
!= vals
[i
])
1080 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1
,
1081 SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1082 ok( regval
== vals
[i
],
1083 "wrong value in registry %d, expected %d\n", regval
, vals
[i
] );
1085 rc
=SystemParametersInfoA( SPI_GETICONTITLEWRAP
, 0, &v
, 0 );
1086 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1087 eq( v
, vals
[i
], "SPI_{GET,SET}ICONTITLEWRAP", "%d" );
1088 /* and test with what SPI_GETICONMETRICS returns */
1089 im
.cbSize
= sizeof(ICONMETRICSA
);
1090 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im
, FALSE
);
1091 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1092 eq( im
.iTitleWrap
, (BOOL
)vals
[i
], "SPI_GETICONMETRICS", "%d" );
1095 rc
=SystemParametersInfoA( SPI_SETICONTITLEWRAP
, old_b
, 0, SPIF_UPDATEINIFILE
);
1096 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1099 static void test_SPI_SETMENUDROPALIGNMENT( void ) /* 28 */
1103 const UINT vals
[]={TRUE
,FALSE
};
1106 trace("testing SPI_{GET,SET}MENUDROPALIGNMENT\n");
1107 SetLastError(0xdeadbeef);
1108 rc
=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT
, 0, &old_b
, 0 );
1109 if (!test_error_msg(rc
,"SPI_{GET,SET}MENUDROPALIGNMENT"))
1112 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1116 rc
=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT
, vals
[i
], 0,
1117 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1118 if (!test_error_msg(rc
,"SPI_SETMENUDROPALIGNMENT")) return;
1119 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1120 test_change_message( SPI_SETMENUDROPALIGNMENT
, 0 );
1121 test_reg_key_ex( SPI_SETMENUDROPALIGNMENT_REGKEY1
,
1122 SPI_SETMENUDROPALIGNMENT_REGKEY2
,
1123 SPI_SETMENUDROPALIGNMENT_VALNAME
,
1124 vals
[i
] ? "1" : "0" );
1126 rc
=SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT
, 0, &v
, 0 );
1127 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1128 eq( v
, vals
[i
], "SPI_{GET,SET}MENUDROPALIGNMENT", "%d" );
1129 eq( GetSystemMetrics( SM_MENUDROPALIGNMENT
), (int)vals
[i
],
1130 "SM_MENUDROPALIGNMENT", "%d" );
1133 rc
=SystemParametersInfoA( SPI_SETMENUDROPALIGNMENT
, old_b
, 0,
1134 SPIF_UPDATEINIFILE
);
1135 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1138 static void test_SPI_SETDOUBLECLKWIDTH( void ) /* 29 */
1142 const UINT vals
[]={0,10000};
1145 trace("testing SPI_{GET,SET}DOUBLECLKWIDTH\n");
1146 old_width
= GetSystemMetrics( SM_CXDOUBLECLK
);
1148 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1152 SetLastError(0xdeadbeef);
1153 rc
=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH
, vals
[i
], 0,
1154 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1155 if (!test_error_msg(rc
,"SPI_{GET,SET}DOUBLECLKWIDTH"))
1158 test_change_message( SPI_SETDOUBLECLKWIDTH
, 0 );
1159 sprintf( buf
, "%d", vals
[i
] );
1160 test_reg_key_ex( SPI_SETDOUBLECLKWIDTH_REGKEY1
,
1161 SPI_SETDOUBLECLKWIDTH_REGKEY2
,
1162 SPI_SETDOUBLECLKWIDTH_VALNAME
, buf
);
1163 eq( GetSystemMetrics( SM_CXDOUBLECLK
), (int)vals
[i
],
1164 "SM_CXDOUBLECLK", "%d" );
1167 rc
=SystemParametersInfoA( SPI_SETDOUBLECLKWIDTH
, old_width
, 0,
1168 SPIF_UPDATEINIFILE
);
1169 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1172 static void test_SPI_SETDOUBLECLKHEIGHT( void ) /* 30 */
1176 const UINT vals
[]={0,10000};
1179 trace("testing SPI_{GET,SET}DOUBLECLKHEIGHT\n");
1180 old_height
= GetSystemMetrics( SM_CYDOUBLECLK
);
1182 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1186 SetLastError(0xdeadbeef);
1187 rc
=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT
, vals
[i
], 0,
1188 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1189 if (!test_error_msg(rc
,"SPI_{GET,SET}DOUBLECLKHEIGHT"))
1192 test_change_message( SPI_SETDOUBLECLKHEIGHT
, 0 );
1193 sprintf( buf
, "%d", vals
[i
] );
1194 test_reg_key_ex( SPI_SETDOUBLECLKHEIGHT_REGKEY1
,
1195 SPI_SETDOUBLECLKHEIGHT_REGKEY2
,
1196 SPI_SETDOUBLECLKHEIGHT_VALNAME
, buf
);
1197 eq( GetSystemMetrics( SM_CYDOUBLECLK
), (int)vals
[i
],
1198 "SM_CYDOUBLECLK", "%d" );
1201 rc
=SystemParametersInfoA( SPI_SETDOUBLECLKHEIGHT
, old_height
, 0,
1202 SPIF_UPDATEINIFILE
);
1203 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1206 static void test_SPI_SETDOUBLECLICKTIME( void ) /* 32 */
1214 trace("testing SPI_{GET,SET}DOUBLECLICKTIME\n");
1215 old_time
= GetDoubleClickTime();
1218 SetLastError(0xdeadbeef);
1219 rc
=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME
, curr_val
, 0,
1220 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1221 if (!test_error_msg(rc
,"SPI_{GET,SET}DOUBLECLICKTIME"))
1224 test_change_message( SPI_SETDOUBLECLICKTIME
, 0 );
1225 sprintf( buf
, "%d", curr_val
);
1226 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY
,
1227 SPI_SETDOUBLECLICKTIME_VALNAME
, buf
);
1228 curr_val
= 500; /* used value for 0 */
1229 eq( GetDoubleClickTime(), curr_val
, "GetDoubleClickTime", "%d" );
1232 rc
=SystemParametersInfoA( SPI_SETDOUBLECLICKTIME
, curr_val
, 0,
1233 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1234 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1235 test_change_message( SPI_SETDOUBLECLICKTIME
, 0 );
1236 sprintf( buf
, "%d", curr_val
);
1237 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY
,
1238 SPI_SETDOUBLECLICKTIME_VALNAME
, buf
);
1239 eq( GetDoubleClickTime(), curr_val
, "GetDoubleClickTime", "%d" );
1241 saved_val
= curr_val
;
1244 SetDoubleClickTime( curr_val
);
1245 sprintf( buf
, "%d", saved_val
);
1246 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY
,
1247 SPI_SETDOUBLECLICKTIME_VALNAME
, buf
);
1248 curr_val
= 500; /* used value for 0 */
1249 eq( GetDoubleClickTime(), curr_val
, "GetDoubleClickTime", "%d" );
1252 SetDoubleClickTime( curr_val
);
1253 sprintf( buf
, "%d", saved_val
);
1254 test_reg_key( SPI_SETDOUBLECLICKTIME_REGKEY
,
1255 SPI_SETDOUBLECLICKTIME_VALNAME
, buf
);
1256 eq( GetDoubleClickTime(), curr_val
, "GetDoubleClickTime", "%d" );
1258 rc
=SystemParametersInfoA(SPI_SETDOUBLECLICKTIME
, old_time
, 0, SPIF_UPDATEINIFILE
);
1259 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1262 static void test_SPI_SETMOUSEBUTTONSWAP( void ) /* 33 */
1266 const UINT vals
[]={TRUE
,FALSE
};
1269 trace("testing SPI_{GET,SET}MOUSEBUTTONSWAP\n");
1270 old_b
= GetSystemMetrics( SM_SWAPBUTTON
);
1272 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1274 SetLastError(0xdeadbeef);
1275 rc
=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP
, vals
[i
], 0,
1276 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1277 if (!test_error_msg(rc
,"SPI_SETMOUSEBUTTONSWAP")) return;
1279 test_change_message( SPI_SETMOUSEBUTTONSWAP
, 0 );
1280 test_reg_key( SPI_SETMOUSEBUTTONSWAP_REGKEY
,
1281 SPI_SETMOUSEBUTTONSWAP_VALNAME
,
1282 vals
[i
] ? "1" : "0" );
1283 eq( GetSystemMetrics( SM_SWAPBUTTON
), (int)vals
[i
],
1284 "SM_SWAPBUTTON", "%d" );
1285 rc
=SwapMouseButton((BOOL
)vals
[i
^1]);
1286 eq( GetSystemMetrics( SM_SWAPBUTTON
), (int)vals
[i
^1],
1287 "SwapMouseButton", "%d" );
1288 ok( rc
==(BOOL
)vals
[i
], "SwapMouseButton does not return previous state (really %d)\n", rc
);
1291 rc
=SystemParametersInfoA( SPI_SETMOUSEBUTTONSWAP
, old_b
, 0,
1292 SPIF_UPDATEINIFILE
);
1293 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1296 static void test_SPI_SETFASTTASKSWITCH( void ) /* 36 */
1301 trace("testing SPI_GETFASTTASKSWITCH\n");
1302 SetLastError(0xdeadbeef);
1303 rc
=SystemParametersInfoA( SPI_GETFASTTASKSWITCH
, 0, &v
, 0 );
1304 if (!test_error_msg(rc
,"SPI_{GET,SET}FASTTASKSWITCH"))
1307 /* there is not a single Windows platform on which SPI_GETFASTTASKSWITCH
1308 * works. That sure simplifies testing!
1312 static void test_SPI_SETDRAGFULLWINDOWS( void ) /* 37 */
1316 const UINT vals
[]={TRUE
,FALSE
};
1319 trace("testing SPI_{GET,SET}DRAGFULLWINDOWS\n");
1320 SetLastError(0xdeadbeef);
1321 rc
=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS
, 0, &old_b
, 0 );
1323 /* SPI_{GET,SET}DRAGFULLWINDOWS is not implemented on Win95 */
1324 if (!test_error_msg(rc
,"SPI_{GET,SET}DRAGFULLWINDOWS"))
1327 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1331 rc
=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS
, vals
[i
], 0,
1332 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1333 if (!test_error_msg(rc
,"SPI_SETDRAGFULLWINDOWS")) return;
1334 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1335 test_change_message( SPI_SETDRAGFULLWINDOWS
, 0 );
1336 test_reg_key( SPI_SETDRAGFULLWINDOWS_REGKEY
,
1337 SPI_SETDRAGFULLWINDOWS_VALNAME
,
1338 vals
[i
] ? "1" : "0" );
1340 rc
=SystemParametersInfoA( SPI_GETDRAGFULLWINDOWS
, 0, &v
, 0 );
1341 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1342 eq( v
, vals
[i
], "SPI_{GET,SET}DRAGFULLWINDOWS", "%d" );
1345 rc
=SystemParametersInfoA( SPI_SETDRAGFULLWINDOWS
, old_b
, 0, SPIF_UPDATEINIFILE
);
1346 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1349 #define test_reg_metric( KEY, VAL, val) \
1351 regval = metricfromreg( KEY, VAL, dpi);\
1352 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\
1355 #define test_reg_metric2( KEY1, KEY2, VAL, val) \
1357 regval = metricfromreg( KEY1, VAL, dpi);\
1358 if( regval != val) regval = metricfromreg( KEY2, VAL, dpi);\
1359 ok( regval==val, "wrong value \"%s\" in registry %d, expected %d\n", VAL, regval, val);\
1362 #define test_reg_font( KEY, VAL, LF) \
1364 lffromreg( KEY, VAL, &lfreg);\
1365 ok( (lfreg.lfHeight < 0 ? (LF).lfHeight == lfreg.lfHeight :\
1366 MulDiv( -(LF).lfHeight , 72, dpi) == lfreg.lfHeight )&&\
1367 (LF).lfWidth == lfreg.lfWidth &&\
1368 (LF).lfWeight == lfreg.lfWeight &&\
1369 !strcmp( (LF).lfFaceName, lfreg.lfFaceName)\
1370 , "wrong value \"%s\" in registry %d, %d\n", VAL, (LF).lfHeight, lfreg.lfHeight);\
1373 #define TEST_NONCLIENTMETRICS_REG( ncm) \
1374 /*FIXME: test_reg_metric2( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, (ncm).iBorderWidth);*/\
1375 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLWIDTH_VALNAME, (ncm).iScrollWidth);\
1376 test_reg_metric( SPI_METRIC_REGKEY, SPI_SCROLLHEIGHT_VALNAME, (ncm).iScrollHeight);\
1377 /*FIXME: test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONWIDTH_VALNAME, (ncm).iCaptionWidth);*/\
1378 test_reg_metric( SPI_METRIC_REGKEY, SPI_CAPTIONHEIGHT_VALNAME, (ncm).iCaptionHeight);\
1379 test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONWIDTH_VALNAME, (ncm).iSmCaptionWidth);\
1380 test_reg_metric( SPI_METRIC_REGKEY, SPI_SMCAPTIONHEIGHT_VALNAME, (ncm).iSmCaptionHeight);\
1381 test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUWIDTH_VALNAME, (ncm).iMenuWidth);\
1382 test_reg_metric( SPI_METRIC_REGKEY, SPI_MENUHEIGHT_VALNAME, (ncm).iMenuHeight);\
1383 test_reg_font( SPI_METRIC_REGKEY, SPI_MENUFONT_VALNAME, (ncm).lfMenuFont);\
1384 test_reg_font( SPI_METRIC_REGKEY, SPI_CAPTIONFONT_VALNAME, (ncm).lfCaptionFont);\
1385 test_reg_font( SPI_METRIC_REGKEY, SPI_SMCAPTIONFONT_VALNAME, (ncm).lfSmCaptionFont);\
1386 test_reg_font( SPI_METRIC_REGKEY, SPI_STATUSFONT_VALNAME, (ncm).lfStatusFont);\
1387 test_reg_font( SPI_METRIC_REGKEY, SPI_MESSAGEFONT_VALNAME, (ncm).lfMessageFont);
1389 /* get text metric height value for the specified logfont */
1390 static int get_tmheight( LOGFONTA
*plf
, int flag
)
1393 HFONT hfont
= CreateFontIndirectA( plf
);
1394 hfont
= SelectObject( hdc
, hfont
);
1395 GetTextMetricsA( hdc
, &tm
);
1396 hfont
= SelectObject( hdc
, hfont
);
1397 return tm
.tmHeight
+ (flag
? tm
.tmExternalLeading
: 0);
1400 static void test_GetSystemMetrics( void);
1401 static UINT smcxsmsize
= 999999999;
1403 static void test_SPI_SETNONCLIENTMETRICS( void ) /* 44 */
1407 NONCLIENTMETRICSA Ncmorig
;
1408 NONCLIENTMETRICSA Ncmnew
;
1409 NONCLIENTMETRICSA Ncmcur
;
1410 NONCLIENTMETRICSA Ncmstart
;
1412 Ncmorig
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1413 Ncmnew
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1414 Ncmcur
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1415 Ncmstart
.cbSize
= sizeof(NONCLIENTMETRICSA
);
1417 trace("testing SPI_{GET,SET}NONCLIENTMETRICS\n");
1419 SetLastError(0xdeadbeef);
1420 rc
=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICS
), &Ncmorig
, FALSE
);
1421 if (!test_error_msg(rc
,"SPI_{GET,SET}NONCLIENTMETRICS"))
1424 smcxsmsize
= Ncmstart
.iSmCaptionWidth
;
1425 /* SPI_GETNONCLIENTMETRICS returns some "cooked" values. For instance if
1426 the caption font height is higher than the CaptionHeight field,
1427 the latter is adjusted accordingly. To be able to restore these setting
1428 accurately be restore the raw values. */
1429 Ncmorig
.iCaptionWidth
= metricfromreg( SPI_METRIC_REGKEY
, SPI_CAPTIONWIDTH_VALNAME
, dpi
);
1430 Ncmorig
.iCaptionHeight
= metricfromreg( SPI_METRIC_REGKEY
, SPI_CAPTIONHEIGHT_VALNAME
, dpi
);
1431 Ncmorig
.iSmCaptionHeight
= metricfromreg( SPI_METRIC_REGKEY
, SPI_SMCAPTIONHEIGHT_VALNAME
, dpi
);
1432 Ncmorig
.iMenuHeight
= metricfromreg( SPI_METRIC_REGKEY
, SPI_MENUHEIGHT_VALNAME
, dpi
);
1433 /* test registry entries */
1434 TEST_NONCLIENTMETRICS_REG( Ncmorig
)
1435 /* make small changes */
1437 Ncmnew
.iBorderWidth
+= 1;
1438 Ncmnew
.iScrollWidth
+= 1;
1439 Ncmnew
.iScrollHeight
-= 1;
1440 Ncmnew
.iCaptionWidth
-= 2;
1441 Ncmnew
.iCaptionHeight
+= 2;
1442 Ncmnew
.lfCaptionFont
.lfHeight
+=1;
1443 Ncmnew
.lfCaptionFont
.lfWidth
+=2;
1444 Ncmnew
.lfCaptionFont
.lfWeight
+=1;
1445 Ncmnew
.iSmCaptionWidth
+= 1;
1446 Ncmnew
.iSmCaptionHeight
+= 2;
1447 Ncmnew
.lfSmCaptionFont
.lfHeight
+=3;
1448 Ncmnew
.lfSmCaptionFont
.lfWidth
-=1;
1449 Ncmnew
.lfSmCaptionFont
.lfWeight
+=3;
1450 Ncmnew
.iMenuWidth
+= 1;
1451 Ncmnew
.iMenuHeight
+= 2;
1452 Ncmnew
.lfMenuFont
.lfHeight
+=1;
1453 Ncmnew
.lfMenuFont
.lfWidth
+=1;
1454 Ncmnew
.lfMenuFont
.lfWeight
+=2;
1455 Ncmnew
.lfStatusFont
.lfHeight
-=1;
1456 Ncmnew
.lfStatusFont
.lfWidth
-=1;
1457 Ncmnew
.lfStatusFont
.lfWeight
+=3;
1458 Ncmnew
.lfMessageFont
.lfHeight
-=2;
1459 Ncmnew
.lfMessageFont
.lfWidth
-=1;
1460 Ncmnew
.lfMessageFont
.lfWeight
+=4;
1462 rc
=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS
, 0, &Ncmnew
, SPIF_UPDATEINIFILE
|
1464 if (!test_error_msg(rc
,"SPI_SETNONCLIENTMETRICS")) return;
1465 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1466 test_change_message( SPI_SETNONCLIENTMETRICS
, 1 );
1468 rc
=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICS
), &Ncmcur
, FALSE
);
1469 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1470 /* test registry entries */
1471 TEST_NONCLIENTMETRICS_REG( Ncmcur
)
1472 /* test the system metrics with these settings */
1473 test_GetSystemMetrics();
1474 /* now for something invalid: increase the {menu|caption|smcaption} fonts
1475 by a large amount will increase the {menu|caption|smcaption} height*/
1477 Ncmnew
.lfMenuFont
.lfHeight
-= 8;
1478 Ncmnew
.lfCaptionFont
.lfHeight
=-4;
1479 Ncmnew
.lfSmCaptionFont
.lfHeight
-=10;
1480 /* also show that a few values are lo limited */
1481 Ncmnew
.iCaptionWidth
= 0;
1482 Ncmnew
.iCaptionHeight
= 0;
1483 Ncmnew
.iScrollHeight
= 0;
1484 Ncmnew
.iScrollWidth
= 0;
1486 rc
=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS
, 0, &Ncmnew
, SPIF_UPDATEINIFILE
|
1488 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1489 test_change_message( SPI_SETNONCLIENTMETRICS
, 1 );
1490 /* raw values are in registry */
1491 TEST_NONCLIENTMETRICS_REG( Ncmnew
)
1493 rc
=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICS
), &Ncmcur
, FALSE
);
1494 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1495 /* cooked values are returned */
1496 expect
= max( Ncmnew
.iMenuHeight
, 2 + get_tmheight( &Ncmnew
.lfMenuFont
, 1));
1497 ok( Ncmcur
.iMenuHeight
== expect
,
1498 "MenuHeight: %d expected %d\n", Ncmcur
.iMenuHeight
, expect
);
1499 expect
= max( Ncmnew
.iCaptionHeight
, 2 + get_tmheight(&Ncmnew
.lfCaptionFont
, 0));
1500 ok( Ncmcur
.iCaptionHeight
== expect
,
1501 "CaptionHeight: %d expected %d\n", Ncmcur
.iCaptionHeight
, expect
);
1502 expect
= max( Ncmnew
.iSmCaptionHeight
, 2 + get_tmheight( &Ncmnew
.lfSmCaptionFont
, 0));
1503 ok( Ncmcur
.iSmCaptionHeight
== expect
,
1504 "SmCaptionHeight: %d expected %d\n", Ncmcur
.iSmCaptionHeight
, expect
);
1506 ok( Ncmcur
.iCaptionWidth
== 8 ||
1507 Ncmcur
.iCaptionWidth
== 12 || /* Vista, W7b */
1508 Ncmcur
.iCaptionWidth
== Ncmstart
.iCaptionWidth
, /* with windows XP theme, the value never changes */
1509 "CaptionWidth: %d expected 8, 12 or %d\n", Ncmcur
.iCaptionWidth
, Ncmstart
.iCaptionWidth
);
1510 ok( Ncmcur
.iScrollWidth
== 8,
1511 "ScrollWidth: %d expected 8\n", Ncmcur
.iScrollWidth
);
1512 ok( Ncmcur
.iScrollHeight
== 8,
1513 "ScrollHeight: %d expected 8\n", Ncmcur
.iScrollHeight
);
1514 /* test the system metrics with these settings */
1515 test_GetSystemMetrics();
1517 rc
=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS
, sizeof(NONCLIENTMETRICS
),
1518 &Ncmorig
, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1519 test_change_message( SPI_SETNONCLIENTMETRICS
, 0 );
1520 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1521 /* test the system metrics with these settings */
1522 test_GetSystemMetrics();
1525 static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */
1529 MINIMIZEDMETRICS lpMm_orig
;
1530 MINIMIZEDMETRICS lpMm_new
;
1531 MINIMIZEDMETRICS lpMm_cur
;
1533 lpMm_orig
.cbSize
= sizeof(MINIMIZEDMETRICS
);
1534 lpMm_new
.cbSize
= sizeof(MINIMIZEDMETRICS
);
1535 lpMm_cur
.cbSize
= sizeof(MINIMIZEDMETRICS
);
1537 trace("testing SPI_{GET,SET}MINIMIZEDMETRICS\n");
1538 SetLastError(0xdeadbeef);
1539 rc
=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
), &lpMm_orig
, FALSE
);
1540 if (!test_error_msg(rc
,"SPI_{GET,SET}MINIMIZEDMETRICS"))
1542 /* Test registry. Note that it is perfectly valid for some fields to
1545 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINWIDTH_VALNAME
, dpi
);
1546 ok( regval
== -1 || regval
== lpMm_orig
.iWidth
, "wrong value in registry %d, expected %d\n",
1547 regval
, lpMm_orig
.iWidth
);
1548 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINHORZGAP_VALNAME
, dpi
);
1549 ok( regval
== -1 || regval
== lpMm_orig
.iHorzGap
, "wrong value in registry %d, expected %d\n",
1550 regval
, lpMm_orig
.iHorzGap
);
1551 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINVERTGAP_VALNAME
, dpi
);
1552 ok( regval
== -1 || regval
== lpMm_orig
.iVertGap
, "wrong value in registry %d, expected %d\n",
1553 regval
, lpMm_orig
.iVertGap
);
1554 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINARRANGE_VALNAME
, dpi
);
1555 ok( regval
== -1 || regval
== lpMm_orig
.iArrange
, "wrong value in registry %d, expected %d\n",
1556 regval
, lpMm_orig
.iArrange
);
1557 /* set some new values */
1558 lpMm_cur
.iWidth
= 180;
1559 lpMm_cur
.iHorzGap
= 1;
1560 lpMm_cur
.iVertGap
= 1;
1561 lpMm_cur
.iArrange
= 5;
1562 rc
=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
),
1563 &lpMm_cur
, SPIF_UPDATEINIFILE
);
1564 if (!test_error_msg(rc
,"SPI_SETMINIMIZEDMETRICS")) return;
1565 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1566 /* read them back */
1567 rc
=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
), &lpMm_new
, FALSE
);
1568 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1570 eq( lpMm_new
.iWidth
, lpMm_cur
.iWidth
, "iWidth", "%d" );
1571 eq( lpMm_new
.iHorzGap
, lpMm_cur
.iHorzGap
, "iHorzGap", "%d" );
1572 eq( lpMm_new
.iVertGap
, lpMm_cur
.iVertGap
, "iVertGap", "%d" );
1573 eq( lpMm_new
.iArrange
, lpMm_cur
.iArrange
, "iArrange", "%d" );
1575 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINWIDTH_VALNAME
, dpi
);
1576 ok( regval
== lpMm_new
.iWidth
, "wrong value in registry %d, expected %d\n",
1577 regval
, lpMm_new
.iWidth
);
1578 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINHORZGAP_VALNAME
, dpi
);
1579 ok( regval
== lpMm_new
.iHorzGap
, "wrong value in registry %d, expected %d\n",
1580 regval
, lpMm_new
.iHorzGap
);
1581 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINVERTGAP_VALNAME
, dpi
);
1582 ok( regval
== lpMm_new
.iVertGap
, "wrong value in registry %d, expected %d\n",
1583 regval
, lpMm_new
.iVertGap
);
1584 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINARRANGE_VALNAME
, dpi
);
1585 ok( regval
== lpMm_new
.iArrange
, "wrong value in registry %d, expected %d\n",
1586 regval
, lpMm_new
.iArrange
);
1587 /* test some system metrics */
1588 eq( GetSystemMetrics( SM_CXMINIMIZED
) - 6,
1589 lpMm_new
.iWidth
, "iWidth", "%d" );
1590 eq( GetSystemMetrics( SM_CXMINSPACING
) - GetSystemMetrics( SM_CXMINIMIZED
),
1591 lpMm_new
.iHorzGap
, "iHorzGap", "%d" );
1592 eq( GetSystemMetrics( SM_CYMINSPACING
) - GetSystemMetrics( SM_CYMINIMIZED
),
1593 lpMm_new
.iVertGap
, "iVertGap", "%d" );
1594 eq( GetSystemMetrics( SM_ARRANGE
),
1595 lpMm_new
.iArrange
, "iArrange", "%d" );
1596 /* now some really invalid settings */
1597 lpMm_cur
.iWidth
= -1;
1598 lpMm_cur
.iHorzGap
= -1;
1599 lpMm_cur
.iVertGap
= -1;
1600 lpMm_cur
.iArrange
= - 1;
1601 rc
=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
),
1602 &lpMm_cur
, SPIF_UPDATEINIFILE
);
1603 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1605 rc
=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
), &lpMm_new
, FALSE
);
1606 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1607 /* the width and H/V gaps have minimum 0, arrange is and'd with 0xf */
1608 eq( lpMm_new
.iWidth
, 0, "iWidth", "%d" );
1609 eq( lpMm_new
.iHorzGap
, 0, "iHorzGap", "%d" );
1610 eq( lpMm_new
.iVertGap
, 0, "iVertGap", "%d" );
1611 eq( lpMm_new
.iArrange
, 0xf & lpMm_cur
.iArrange
, "iArrange", "%d" );
1615 /* FIXME: cannot understand the results of this (11, 11, 11, 0) */
1616 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINWIDTH_VALNAME
, dpi
);
1617 ok( regval
== lpMm_new
.iWidth
, "wrong value in registry %d, expected %d\n",
1618 regval
, lpMm_new
.iWidth
);
1619 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINHORZGAP_VALNAME
, dpi
);
1620 ok( regval
== lpMm_new
.iHorzGap
, "wrong value in registry %d, expected %d\n",
1621 regval
, lpMm_new
.iHorzGap
);
1622 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINVERTGAP_VALNAME
, dpi
);
1623 ok( regval
== lpMm_new
.iVertGap
, "wrong value in registry %d, expected %d\n",
1624 regval
, lpMm_new
.iVertGap
);
1625 regval
= metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY
, SPI_MINARRANGE_VALNAME
, dpi
);
1626 ok( regval
== lpMm_new
.iArrange
, "wrong value in registry %d, expected %d\n",
1627 regval
, lpMm_new
.iArrange
);
1629 /* test some system metrics */
1630 eq( GetSystemMetrics( SM_CXMINIMIZED
) - 6,
1631 lpMm_new
.iWidth
, "iWidth", "%d" );
1632 eq( GetSystemMetrics( SM_CXMINSPACING
) - GetSystemMetrics( SM_CXMINIMIZED
),
1633 lpMm_new
.iHorzGap
, "iHorzGap", "%d" );
1634 eq( GetSystemMetrics( SM_CYMINSPACING
) - GetSystemMetrics( SM_CYMINIMIZED
),
1635 lpMm_new
.iVertGap
, "iVertGap", "%d" );
1636 eq( GetSystemMetrics( SM_ARRANGE
),
1637 lpMm_new
.iArrange
, "iArrange", "%d" );
1639 rc
=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
),
1640 &lpMm_orig
, SPIF_UPDATEINIFILE
);
1641 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1643 rc
=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS
, sizeof(MINIMIZEDMETRICS
), &lpMm_new
, FALSE
);
1644 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1645 eq( lpMm_new
.iWidth
, lpMm_orig
.iWidth
, "iWidth", "%d" );
1646 eq( lpMm_new
.iHorzGap
, lpMm_orig
.iHorzGap
, "iHorzGap", "%d" );
1647 eq( lpMm_new
.iVertGap
, lpMm_orig
.iVertGap
, "iVertGap", "%d" );
1648 eq( lpMm_new
.iArrange
, lpMm_orig
.iArrange
, "iArrange", "%d" );
1651 static void test_SPI_SETICONMETRICS( void ) /* 46 */
1655 ICONMETRICSA im_orig
;
1656 ICONMETRICSA im_new
;
1657 ICONMETRICSA im_cur
;
1660 im_orig
.cbSize
= sizeof(ICONMETRICSA
);
1661 im_new
.cbSize
= sizeof(ICONMETRICSA
);
1662 im_cur
.cbSize
= sizeof(ICONMETRICSA
);
1664 trace("testing SPI_{GET,SET}ICONMETRICS\n");
1665 SetLastError(0xdeadbeef);
1666 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im_orig
, FALSE
);
1667 if (!test_error_msg(rc
,"SPI_{GET,SET}ICONMETRICS"))
1669 /* check some registry values */
1670 regval
= metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY
, SPI_ICONHORIZONTALSPACING_VALNAME
, dpi
);
1671 ok( regval
==im_orig
.iHorzSpacing
, "wrong value in registry %d, expected %d\n", regval
, im_orig
.iHorzSpacing
);
1672 regval
= metricfromreg( SPI_ICONVERTICALSPACING_REGKEY
, SPI_ICONVERTICALSPACING_VALNAME
, dpi
);
1673 ok( regval
==im_orig
.iVertSpacing
, "wrong value in registry %d, expected %d\n", regval
, im_orig
.iVertSpacing
);
1674 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2
, SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1675 if( regval
!= im_orig
.iTitleWrap
)
1676 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1
, SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1677 ok( regval
==im_orig
.iTitleWrap
, "wrong value in registry %d, expected %d\n", regval
, im_orig
.iTitleWrap
);
1679 /* change everything without creating something invalid ( Win9x would ignore
1680 * an invalid font for instance) */
1682 im_cur
.iHorzSpacing
+= 10;
1683 im_cur
.iVertSpacing
+= 6;
1684 im_cur
.iTitleWrap
= !im_cur
.iTitleWrap
;
1685 im_cur
.lfFont
.lfHeight
+= 1;
1686 im_cur
.lfFont
.lfWidth
+= 2;
1687 im_cur
.lfFont
.lfEscapement
= 1;
1688 im_cur
.lfFont
.lfWeight
= im_cur
.lfFont
.lfWeight
> 100 ? 1 : 314;
1689 im_cur
.lfFont
.lfItalic
= !im_cur
.lfFont
.lfItalic
;
1690 im_cur
.lfFont
.lfStrikeOut
= !im_cur
.lfFont
.lfStrikeOut
;
1691 im_cur
.lfFont
.lfUnderline
= !im_cur
.lfFont
.lfUnderline
;
1692 im_cur
.lfFont
.lfCharSet
= im_cur
.lfFont
.lfCharSet
? 0 : 1;
1693 im_cur
.lfFont
.lfOutPrecision
= im_cur
.lfFont
.lfOutPrecision
== OUT_DEFAULT_PRECIS
?
1694 OUT_TT_PRECIS
: OUT_DEFAULT_PRECIS
;
1695 im_cur
.lfFont
.lfClipPrecision
^= CLIP_LH_ANGLES
;
1696 im_cur
.lfFont
.lfPitchAndFamily
= im_cur
.lfFont
.lfPitchAndFamily
? 0 : 1;
1697 im_cur
.lfFont
.lfQuality
= im_cur
.lfFont
.lfQuality
== DEFAULT_QUALITY
?
1698 DRAFT_QUALITY
: DEFAULT_QUALITY
;
1699 if( strcmp( im_cur
.lfFont
.lfFaceName
, "MS Serif"))
1700 strcpy( im_cur
.lfFont
.lfFaceName
, "MS Serif");
1702 strcpy( im_cur
.lfFont
.lfFaceName
, "MS Sans Serif");
1704 rc
=SystemParametersInfoA( SPI_SETICONMETRICS
, sizeof(ICONMETRICSA
), &im_cur
, SPIF_UPDATEINIFILE
);
1705 if (!test_error_msg(rc
,"SPI_SETICONMETRICS")) return;
1706 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1708 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im_new
, FALSE
);
1709 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1710 /* test GET <-> SETICONMETRICS */
1711 eq( im_new
.iHorzSpacing
, im_cur
.iHorzSpacing
, "iHorzSpacing", "%d" );
1712 eq( im_new
.iVertSpacing
, im_cur
.iVertSpacing
, "iVertSpacing", "%d" );
1713 eq( im_new
.iTitleWrap
, im_cur
.iTitleWrap
, "iTitleWrap", "%d" );
1714 eq( im_new
.lfFont
.lfHeight
, im_cur
.lfFont
.lfHeight
, "lfHeight", "%d" );
1715 eq( im_new
.lfFont
.lfWidth
, im_cur
.lfFont
.lfWidth
, "lfWidth", "%d" );
1716 eq( im_new
.lfFont
.lfEscapement
, im_cur
.lfFont
.lfEscapement
, "lfEscapement", "%d" );
1717 eq( im_new
.lfFont
.lfWeight
, im_cur
.lfFont
.lfWeight
, "lfWeight", "%d" );
1718 eq( im_new
.lfFont
.lfItalic
, im_cur
.lfFont
.lfItalic
, "lfItalic", "%d" );
1719 eq( im_new
.lfFont
.lfStrikeOut
, im_cur
.lfFont
.lfStrikeOut
, "lfStrikeOut", "%d" );
1720 eq( im_new
.lfFont
.lfUnderline
, im_cur
.lfFont
.lfUnderline
, "lfUnderline", "%d" );
1721 eq( im_new
.lfFont
.lfCharSet
, im_cur
.lfFont
.lfCharSet
, "lfCharSet", "%d" );
1722 eq( im_new
.lfFont
.lfOutPrecision
, im_cur
.lfFont
.lfOutPrecision
, "lfOutPrecision", "%d" );
1723 eq( im_new
.lfFont
.lfClipPrecision
, im_cur
.lfFont
.lfClipPrecision
, "lfClipPrecision", "%d" );
1724 eq( im_new
.lfFont
.lfPitchAndFamily
, im_cur
.lfFont
.lfPitchAndFamily
, "lfPitchAndFamily", "%d" );
1725 eq( im_new
.lfFont
.lfQuality
, im_cur
.lfFont
.lfQuality
, "lfQuality", "%d" );
1726 ok( !strcmp( im_new
.lfFont
.lfFaceName
, im_cur
.lfFont
.lfFaceName
),
1727 "wrong facename \"%s\", should be \"%s\"\n", im_new
.lfFont
.lfFaceName
,
1728 im_cur
.lfFont
.lfFaceName
);
1729 /* test some system metrics */
1730 eq( GetSystemMetrics( SM_CXICONSPACING
),
1731 im_new
.iHorzSpacing
, "iHorzSpacing", "%d" );
1732 eq( GetSystemMetrics( SM_CYICONSPACING
),
1733 im_new
.iVertSpacing
, "iVertSpacing", "%d" );
1734 /* check some registry values */
1735 regval
= metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY
, SPI_ICONHORIZONTALSPACING_VALNAME
, dpi
);
1736 ok( regval
==im_cur
.iHorzSpacing
, "wrong value in registry %d, expected %d\n", regval
, im_cur
.iHorzSpacing
);
1737 regval
= metricfromreg( SPI_ICONVERTICALSPACING_REGKEY
, SPI_ICONVERTICALSPACING_VALNAME
, dpi
);
1738 ok( regval
==im_cur
.iVertSpacing
, "wrong value in registry %d, expected %d\n", regval
, im_cur
.iVertSpacing
);
1739 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2
, SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1740 if( regval
!= im_cur
.iTitleWrap
)
1741 regval
= metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1
, SPI_SETICONTITLEWRAP_VALNAME
, dpi
);
1742 ok( regval
==im_cur
.iTitleWrap
, "wrong value in registry %d, expected %d\n", regval
, im_cur
.iTitleWrap
);
1743 /* test some values from other SPI_GETxxx calls */
1744 rc
= SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0, &spacing
, 0 );
1745 ok( rc
&& spacing
== im_cur
.iHorzSpacing
,
1746 "SystemParametersInfoA( SPI_ICONHORIZONTALSPACING...) failed or returns wrong value %d instead of %d\n",
1747 spacing
, im_cur
.iHorzSpacing
);
1748 rc
= SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0, &spacing
, 0 );
1749 ok( rc
&& spacing
== im_cur
.iVertSpacing
,
1750 "SystemParametersInfoA( SPI_ICONVERTICALSPACING...) failed or returns wrong value %d instead of %d\n",
1751 spacing
, im_cur
.iVertSpacing
);
1752 rc
= SystemParametersInfoA( SPI_GETICONTITLEWRAP
, 0, &wrap
, 0 );
1753 ok( rc
&& wrap
== im_cur
.iTitleWrap
,
1754 "SystemParametersInfoA( SPI_GETICONTITLEWRAP...) failed or returns wrong value %d instead of %d\n",
1755 wrap
, im_cur
.iTitleWrap
);
1756 /* restore old values */
1757 rc
=SystemParametersInfoA( SPI_SETICONMETRICS
, sizeof(ICONMETRICSA
), &im_orig
,SPIF_UPDATEINIFILE
);
1758 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1760 rc
=SystemParametersInfoA( SPI_GETICONMETRICS
, sizeof(ICONMETRICSA
), &im_new
, FALSE
);
1761 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1763 eq( im_new
.iHorzSpacing
, im_orig
.iHorzSpacing
, "iHorzSpacing", "%d" );
1764 eq( im_new
.iVertSpacing
, im_orig
.iVertSpacing
, "iVertSpacing", "%d" );
1765 eq( im_new
.iTitleWrap
, im_orig
.iTitleWrap
, "iTitleWrap", "%d" );
1768 static void test_SPI_SETWORKAREA( void ) /* 47 */
1775 trace("testing SPI_{GET,SET}WORKAREA\n");
1776 SetLastError(0xdeadbeef);
1777 rc
=SystemParametersInfoA(SPI_GETWORKAREA
, 0, &old_area
, 0);
1778 if (!test_error_msg(rc
,"SPI_{GET,SET}WORKAREA"))
1781 /* Modify the work area only minimally as this causes the icons that
1782 * fall outside it to be moved around thus requiring the user to
1783 * reposition them manually one by one.
1784 * Changing the work area by just one pixel should make this occurrence
1785 * reasonably unlikely.
1787 curr_val
.left
= old_area
.left
;
1788 curr_val
.top
= old_area
.top
;
1789 curr_val
.right
= old_area
.right
-1;
1790 curr_val
.bottom
= old_area
.bottom
-1;
1791 rc
=SystemParametersInfoA( SPI_SETWORKAREA
, 0, &curr_val
,
1792 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1793 if (!test_error_msg(rc
,"SPI_SETWORKAREA")) return;
1794 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1795 rc
=SystemParametersInfoA( SPI_GETWORKAREA
, 0, &area
, 0 );
1796 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1797 if( !EqualRect( &area
, &curr_val
)) /* no message if rect has not changed */
1798 test_change_message( SPI_SETWORKAREA
, 0);
1799 eq( area
.left
, curr_val
.left
, "left", "%d" );
1800 eq( area
.top
, curr_val
.top
, "top", "%d" );
1801 eq( area
.right
, curr_val
.right
, "right", "%d" );
1802 eq( area
.bottom
, curr_val
.bottom
, "bottom", "%d" );
1804 rc
=SystemParametersInfoA( SPI_SETWORKAREA
, 0, &old_area
,
1805 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1806 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1807 rc
=SystemParametersInfoA( SPI_GETWORKAREA
, 0, &area
, 0 );
1808 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
1809 if( !EqualRect( &area
, &curr_val
)) /* no message if rect has not changed */
1810 test_change_message( SPI_SETWORKAREA
, 0 );
1811 eq( area
.left
, old_area
.left
, "left", "%d" );
1812 eq( area
.top
, old_area
.top
, "top", "%d" );
1813 eq( area
.right
, old_area
.right
, "right", "%d" );
1814 eq( area
.bottom
, old_area
.bottom
, "bottom", "%d" );
1817 static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */
1821 const UINT vals
[]={TRUE
,FALSE
};
1824 trace("testing SPI_{GET,SET}SHOWSOUNDS\n");
1825 SetLastError(0xdeadbeef);
1826 rc
=SystemParametersInfoA( SPI_GETSHOWSOUNDS
, 0, &old_b
, 0 );
1827 /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */
1828 if (!test_error_msg(rc
,"SPI_{GET,SET}SHOWSOUNDS"))
1831 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1835 rc
=SystemParametersInfoA( SPI_SETSHOWSOUNDS
, vals
[i
], 0,
1836 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1837 if (!test_error_msg(rc
,"SPI_SETSHOWSOUNDS")) return;
1838 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1839 test_change_message( SPI_SETSHOWSOUNDS
, 1 );
1840 test_reg_key( SPI_SETSHOWSOUNDS_REGKEY
,
1841 SPI_SETSHOWSOUNDS_VALNAME
,
1842 vals
[i
] ? "1" : "0" );
1844 rc
=SystemParametersInfoA( SPI_GETSHOWSOUNDS
, 0, &v
, 0 );
1845 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1846 eq( v
, vals
[i
], "SPI_GETSHOWSOUNDS", "%d" );
1847 eq( GetSystemMetrics( SM_SHOWSOUNDS
), (int)vals
[i
],
1848 "SM_SHOWSOUNDS", "%d" );
1851 rc
=SystemParametersInfoA( SPI_SETSHOWSOUNDS
, old_b
, 0, SPIF_UPDATEINIFILE
);
1852 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1855 static void test_SPI_SETKEYBOARDPREF( void ) /* 69 */
1859 const UINT vals
[]={TRUE
,FALSE
};
1862 trace("testing SPI_{GET,SET}KEYBOARDPREF\n");
1863 SetLastError(0xdeadbeef);
1864 rc
=SystemParametersInfoA( SPI_GETKEYBOARDPREF
, 0, &old_b
, 0 );
1865 if (!test_error_msg(rc
,"SPI_{GET,SET}KEYBOARDPREF"))
1868 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1872 rc
=SystemParametersInfoA( SPI_SETKEYBOARDPREF
, vals
[i
], 0,
1873 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1874 if (!test_error_msg(rc
,"SPI_SETKEYBOARDPREF")) return;
1875 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1876 test_change_message( SPI_SETKEYBOARDPREF
, 1 );
1877 test_reg_key_ex2( SPI_SETKEYBOARDPREF_REGKEY
, SPI_SETKEYBOARDPREF_REGKEY_LEGACY
,
1878 SPI_SETKEYBOARDPREF_VALNAME
, SPI_SETKEYBOARDPREF_VALNAME_LEGACY
,
1879 vals
[i
] ? "1" : "0" );
1881 rc
=SystemParametersInfoA( SPI_GETKEYBOARDPREF
, 0, &v
, 0 );
1882 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1883 eq( v
, (BOOL
)vals
[i
], "SPI_GETKEYBOARDPREF", "%d" );
1886 rc
=SystemParametersInfoA( SPI_SETKEYBOARDPREF
, old_b
, 0, SPIF_UPDATEINIFILE
);
1887 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1890 static void test_SPI_SETSCREENREADER( void ) /* 71 */
1894 const UINT vals
[]={TRUE
,FALSE
};
1897 trace("testing SPI_{GET,SET}SCREENREADER\n");
1898 SetLastError(0xdeadbeef);
1899 rc
=SystemParametersInfoA( SPI_GETSCREENREADER
, 0, &old_b
, 0 );
1900 if (!test_error_msg(rc
,"SPI_{GET,SET}SCREENREADER"))
1903 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1907 rc
=SystemParametersInfoA( SPI_SETSCREENREADER
, vals
[i
], 0,
1908 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1909 if (!test_error_msg(rc
,"SPI_SETSCREENREADER")) return;
1910 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1911 test_change_message( SPI_SETSCREENREADER
, 1 );
1912 test_reg_key_ex2( SPI_SETSCREENREADER_REGKEY
, SPI_SETSCREENREADER_REGKEY_LEGACY
,
1913 SPI_SETSCREENREADER_VALNAME
, SPI_SETSCREENREADER_VALNAME_LEGACY
,
1914 vals
[i
] ? "1" : "0" );
1916 rc
=SystemParametersInfoA( SPI_GETSCREENREADER
, 0, &v
, 0 );
1917 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1918 eq( v
, (BOOL
)vals
[i
], "SPI_GETSCREENREADER", "%d" );
1921 rc
=SystemParametersInfoA( SPI_SETSCREENREADER
, old_b
, 0, SPIF_UPDATEINIFILE
);
1922 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1925 static void test_SPI_SETFONTSMOOTHING( void ) /* 75 */
1929 const UINT vals
[]={0xffffffff,0,1,2};
1932 trace("testing SPI_{GET,SET}FONTSMOOTHING\n");
1933 if( iswin9x
) return; /* 95/98/ME don't seem to implement this fully */
1934 SetLastError(0xdeadbeef);
1935 rc
=SystemParametersInfoA( SPI_GETFONTSMOOTHING
, 0, &old_b
, 0 );
1936 if (!test_error_msg(rc
,"SPI_{GET,SET}FONTSMOOTHING"))
1939 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1943 rc
=SystemParametersInfoA( SPI_SETFONTSMOOTHING
, vals
[i
], 0,
1944 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1945 if (!test_error_msg(rc
,"SPI_SETFONTSMOOTHING")) return;
1946 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1947 test_change_message( SPI_SETFONTSMOOTHING
, 0 );
1948 test_reg_key( SPI_SETFONTSMOOTHING_REGKEY
,
1949 SPI_SETFONTSMOOTHING_VALNAME
,
1950 vals
[i
] ? "2" : "0" );
1952 rc
=SystemParametersInfoA( SPI_GETFONTSMOOTHING
, 0, &v
, 0 );
1953 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1954 eq( v
, vals
[i
] ? 1 : 0, "SPI_GETFONTSMOOTHING", "%d" );
1957 rc
=SystemParametersInfoA( SPI_SETFONTSMOOTHING
, old_b
, 0, SPIF_UPDATEINIFILE
);
1958 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1961 static void test_SPI_SETLOWPOWERACTIVE( void ) /* 85 */
1965 const UINT vals
[]={TRUE
,FALSE
};
1968 trace("testing SPI_{GET,SET}LOWPOWERACTIVE\n");
1969 SetLastError(0xdeadbeef);
1970 rc
=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE
, 0, &old_b
, 0 );
1971 if (!test_error_msg(rc
,"SPI_{GET,SET}LOWPOWERACTIVE"))
1974 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
1978 rc
=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE
, vals
[i
], 0,
1979 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
1980 if (!test_error_msg(rc
,"SPI_SETLOWPOWERACTIVE")) return;
1981 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1982 test_change_message( SPI_SETLOWPOWERACTIVE
, 1 );
1983 test_reg_key( SPI_SETLOWPOWERACTIVE_REGKEY
,
1984 SPI_SETLOWPOWERACTIVE_VALNAME
,
1985 vals
[i
] ? "1" : "0" );
1987 /* SPI_SETLOWPOWERACTIVE is not persistent in win2k3 and above */
1988 rc
=SystemParametersInfoA( SPI_GETLOWPOWERACTIVE
, 0, &v
, 0 );
1989 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
1991 v
== 0, /* win2k3 */
1992 "SPI_GETLOWPOWERACTIVE: got %d instead of 0 or %d\n", v
, vals
[i
]);
1995 rc
=SystemParametersInfoA( SPI_SETLOWPOWERACTIVE
, old_b
, 0, SPIF_UPDATEINIFILE
);
1996 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
1999 static void test_SPI_SETPOWEROFFACTIVE( void ) /* 86 */
2003 const UINT vals
[]={TRUE
,FALSE
};
2006 trace("testing SPI_{GET,SET}POWEROFFACTIVE\n");
2007 SetLastError(0xdeadbeef);
2008 rc
=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE
, 0, &old_b
, 0 );
2009 if (!test_error_msg(rc
,"SPI_{GET,SET}POWEROFFACTIVE"))
2012 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2016 rc
=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE
, vals
[i
], 0,
2017 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2018 if (!test_error_msg(rc
,"SPI_SETPOWEROFFACTIVE")) return;
2019 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2020 test_change_message( SPI_SETPOWEROFFACTIVE
, 1 );
2021 test_reg_key( SPI_SETPOWEROFFACTIVE_REGKEY
,
2022 SPI_SETPOWEROFFACTIVE_VALNAME
,
2023 vals
[i
] ? "1" : "0" );
2025 /* SPI_SETPOWEROFFACTIVE is not persistent in win2k3 and above */
2026 rc
=SystemParametersInfoA( SPI_GETPOWEROFFACTIVE
, 0, &v
, 0 );
2027 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2029 v
== 0, /* win2k3 */
2030 "SPI_GETPOWEROFFACTIVE: got %d instead of 0 or %d\n", v
, vals
[i
]);
2033 rc
=SystemParametersInfoA( SPI_SETPOWEROFFACTIVE
, old_b
, 0, SPIF_UPDATEINIFILE
);
2034 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2037 static void test_SPI_SETSNAPTODEFBUTTON( void ) /* 95 */
2041 const UINT vals
[]={TRUE
,FALSE
};
2044 trace("testing SPI_{GET,SET}SNAPTODEFBUTTON\n");
2045 SetLastError(0xdeadbeef);
2046 rc
=SystemParametersInfoA( SPI_GETSNAPTODEFBUTTON
, 0, &old_b
, 0 );
2047 if (!test_error_msg(rc
,"SPI_GETSNAPTODEFBUTTON"))
2050 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2054 rc
=SystemParametersInfoA( SPI_SETSNAPTODEFBUTTON
, vals
[i
], 0,
2055 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2056 if (!test_error_msg(rc
,"SPI_SETSNAPTODEFBUTTON")) return;
2057 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2058 test_change_message( SPI_SETSNAPTODEFBUTTON
, 0 );
2059 test_reg_key( SPI_SETSNAPTODEFBUTTON_REGKEY
,
2060 SPI_SETSNAPTODEFBUTTON_VALNAME
,
2061 vals
[i
] ? "1" : "0" );
2063 rc
=SystemParametersInfoA( SPI_GETSNAPTODEFBUTTON
, 0, &v
, 0 );
2064 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2065 eq( v
, vals
[i
], "SPI_GETSNAPTODEFBUTTON", "%d" );
2068 rc
=SystemParametersInfoA( SPI_SETSNAPTODEFBUTTON
, old_b
, 0, SPIF_UPDATEINIFILE
);
2069 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2072 static void test_SPI_SETMOUSEHOVERWIDTH( void ) /* 99 */
2076 const UINT vals
[]={0,32767};
2079 trace("testing SPI_{GET,SET}MOUSEHOVERWIDTH\n");
2080 SetLastError(0xdeadbeef);
2081 rc
=SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH
, 0, &old_width
, 0 );
2082 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2083 * what MSDN states (Verified on Win98SE)
2085 if (!test_error_msg(rc
,"SPI_{GET,SET}MOUSEHOVERWIDTH"))
2088 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2093 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH
, vals
[i
], 0,
2094 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2095 if (!test_error_msg(rc
,"SPI_SETMOUSEHOVERWIDTH")) return;
2096 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2097 test_change_message( SPI_SETMOUSEHOVERWIDTH
, 0 );
2098 sprintf( buf
, "%d", vals
[i
] );
2099 test_reg_key( SPI_SETMOUSEHOVERWIDTH_REGKEY
,
2100 SPI_SETMOUSEHOVERWIDTH_VALNAME
, buf
);
2102 SystemParametersInfoA( SPI_GETMOUSEHOVERWIDTH
, 0, &v
, 0 );
2103 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2104 eq( v
, vals
[i
], "SPI_{GET,SET}MOUSEHOVERWIDTH", "%d" );
2107 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERWIDTH
, old_width
, 0,
2108 SPIF_UPDATEINIFILE
);
2109 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2112 static void test_SPI_SETMOUSEHOVERHEIGHT( void ) /* 101 */
2116 const UINT vals
[]={0,32767};
2119 trace("testing SPI_{GET,SET}MOUSEHOVERHEIGHT\n");
2120 SetLastError(0xdeadbeef);
2121 rc
=SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT
, 0, &old_height
, 0 );
2122 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2123 * what MSDN states (Verified on Win98SE)
2125 if (!test_error_msg(rc
,"SPI_{GET,SET}MOUSEHOVERHEIGHT"))
2128 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2133 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT
, vals
[i
], 0,
2134 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2135 if (!test_error_msg(rc
,"SPI_SETMOUSEHOVERHEIGHT")) return;
2136 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2137 test_change_message( SPI_SETMOUSEHOVERHEIGHT
, 0 );
2138 sprintf( buf
, "%d", vals
[i
] );
2139 test_reg_key( SPI_SETMOUSEHOVERHEIGHT_REGKEY
,
2140 SPI_SETMOUSEHOVERHEIGHT_VALNAME
, buf
);
2142 SystemParametersInfoA( SPI_GETMOUSEHOVERHEIGHT
, 0, &v
, 0 );
2143 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2144 eq( v
, vals
[i
], "SPI_{GET,SET}MOUSEHOVERHEIGHT", "%d" );
2147 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERHEIGHT
, old_height
, 0,
2148 SPIF_UPDATEINIFILE
);
2149 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2152 static void test_SPI_SETMOUSEHOVERTIME( void ) /* 103 */
2157 /* Windows XP accepts 10 as the minimum hover time. Any value below will be
2158 * defaulted to a value of 10 automatically.
2160 const UINT vals
[]={10,32767};
2163 trace("testing SPI_{GET,SET}MOUSEHOVERTIME\n");
2164 SetLastError(0xdeadbeef);
2165 rc
=SystemParametersInfoA( SPI_GETMOUSEHOVERTIME
, 0, &old_time
, 0 );
2166 /* SPI_{GET,SET}MOUSEHOVERWIDTH does not seem to be supported on Win9x despite
2167 * what MSDN states (Verified on Win98SE)
2169 if (!test_error_msg(rc
,"SPI_{GET,SET}MOUSEHOVERTIME"))
2172 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2177 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME
, vals
[i
], 0,
2178 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2179 if (!test_error_msg(rc
,"SPI_SETMOUSEHOVERTIME")) return;
2180 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2181 test_change_message( SPI_SETMOUSEHOVERTIME
, 0 );
2182 sprintf( buf
, "%d", vals
[i
] );
2183 test_reg_key( SPI_SETMOUSEHOVERTIME_REGKEY
,
2184 SPI_SETMOUSEHOVERTIME_VALNAME
, buf
);
2186 SystemParametersInfoA( SPI_GETMOUSEHOVERTIME
, 0, &v
, 0 );
2187 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2188 eq( v
, vals
[i
], "SPI_{GET,SET}MOUSEHOVERTIME", "%d" );
2191 rc
=SystemParametersInfoA( SPI_SETMOUSEHOVERTIME
, old_time
, 0,
2192 SPIF_UPDATEINIFILE
);
2193 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2196 static void test_SPI_SETWHEELSCROLLLINES( void ) /* 105 */
2200 const UINT vals
[]={0,32767};
2203 trace("testing SPI_{GET,SET}WHEELSCROLLLINES\n");
2204 SetLastError(0xdeadbeef);
2205 rc
=SystemParametersInfoA( SPI_GETWHEELSCROLLLINES
, 0, &old_lines
, 0 );
2207 /* SPI_{GET,SET}WHEELSCROLLLINES not supported on Windows 95 */
2208 if (!test_error_msg(rc
,"SPI_{GET,SET}WHEELSCROLLLINES"))
2211 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2216 rc
=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES
, vals
[i
], 0,
2217 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2218 if (!test_error_msg(rc
,"SPI_SETWHEELSCROLLLINES")) return;
2219 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2220 test_change_message( SPI_SETWHEELSCROLLLINES
, 0 );
2221 sprintf( buf
, "%d", vals
[i
] );
2222 test_reg_key( SPI_SETMOUSESCROLLLINES_REGKEY
,
2223 SPI_SETMOUSESCROLLLINES_VALNAME
, buf
);
2225 SystemParametersInfoA( SPI_GETWHEELSCROLLLINES
, 0, &v
, 0 );
2226 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2227 eq( v
, vals
[i
], "SPI_{GET,SET}WHEELSCROLLLINES", "%d" );
2230 rc
=SystemParametersInfoA( SPI_SETWHEELSCROLLLINES
, old_lines
, 0,
2231 SPIF_UPDATEINIFILE
);
2232 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2235 static void test_SPI_SETMENUSHOWDELAY( void ) /* 107 */
2239 const UINT vals
[]={0,32767};
2242 trace("testing SPI_{GET,SET}MENUSHOWDELAY\n");
2243 SetLastError(0xdeadbeef);
2244 rc
=SystemParametersInfoA( SPI_GETMENUSHOWDELAY
, 0, &old_delay
, 0 );
2246 /* SPI_{GET,SET}MENUSHOWDELAY not supported on Windows 95 */
2247 if (!test_error_msg(rc
,"SPI_{GET,SET}MENUSHOWDELAY"))
2250 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2255 rc
=SystemParametersInfoA( SPI_SETMENUSHOWDELAY
, vals
[i
], 0,
2256 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2257 if (!test_error_msg(rc
,"SPI_SETMENUSHOWDELAY")) return;
2258 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2259 test_change_message( SPI_SETMENUSHOWDELAY
, 0 );
2260 sprintf( buf
, "%d", vals
[i
] );
2261 test_reg_key( SPI_SETMENUSHOWDELAY_REGKEY
,
2262 SPI_SETMENUSHOWDELAY_VALNAME
, buf
);
2264 SystemParametersInfoA( SPI_GETMENUSHOWDELAY
, 0, &v
, 0 );
2265 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2266 eq( v
, vals
[i
], "SPI_{GET,SET}MENUSHOWDELAY", "%d" );
2269 rc
=SystemParametersInfoA( SPI_SETMENUSHOWDELAY
, old_delay
, 0,
2270 SPIF_UPDATEINIFILE
);
2271 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2274 static void test_SPI_SETWHEELSCROLLCHARS( void ) /* 108 */
2278 const UINT vals
[]={32767,0};
2281 trace("testing SPI_{GET,SET}WHEELSCROLLCHARS\n");
2282 SetLastError(0xdeadbeef);
2283 rc
=SystemParametersInfoA( SPI_GETWHEELSCROLLCHARS
, 0, &old_chars
, 0 );
2285 /* SPI_{GET,SET}WHEELSCROLLCHARS not supported on Windows 95 */
2286 if (!test_error_msg(rc
,"SPI_{GET,SET}WHEELSCROLLCHARS"))
2289 for (i
=0;i
<sizeof(vals
)/sizeof(*vals
);i
++)
2294 rc
=SystemParametersInfoA( SPI_SETWHEELSCROLLCHARS
, vals
[i
], 0,
2295 SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2296 if (!test_error_msg(rc
,"SPI_SETWHEELSCROLLCHARS")) return;
2297 test_change_message( SPI_SETWHEELSCROLLCHARS
, 0 );
2298 sprintf( buf
, "%d", vals
[i
] );
2299 test_reg_key( SPI_SETMOUSESCROLLCHARS_REGKEY
,
2300 SPI_SETMOUSESCROLLCHARS_VALNAME
, buf
);
2302 SystemParametersInfoA( SPI_GETWHEELSCROLLCHARS
, 0, &v
, 0 );
2303 ok(rc
!=0,"%d: rc=%d err=%d\n",i
,rc
,GetLastError());
2304 eq( v
, vals
[i
], "SPI_{GET,SET}WHEELSCROLLCHARS", "%d" );
2307 rc
=SystemParametersInfoA( SPI_SETWHEELSCROLLCHARS
, old_chars
, 0,
2308 SPIF_UPDATEINIFILE
);
2309 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2312 static void test_SPI_SETWALLPAPER( void ) /* 115 */
2318 trace("testing SPI_{GET,SET}DESKWALLPAPER\n");
2319 SetLastError(0xdeadbeef);
2320 rc
=SystemParametersInfoA(SPI_GETDESKWALLPAPER
, 260, oldval
, 0);
2321 /* SPI_{GET,SET}DESKWALLPAPER is completely broken on Win9x and
2322 * unimplemented on NT4
2324 if (!test_error_msg(rc
,"SPI_{GET,SET}DESKWALLPAPER"))
2328 rc
=SystemParametersInfoA(SPI_SETDESKWALLPAPER
, 0, newval
, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
);
2329 if (!test_error_msg(rc
,"SPI_SETDESKWALLPAPER")) return;
2330 ok(rc
!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc
,GetLastError());
2331 test_change_message(SPI_SETDESKWALLPAPER
, 0);
2333 rc
=SystemParametersInfoA(SPI_SETDESKWALLPAPER
, 0, oldval
, SPIF_UPDATEINIFILE
);
2334 ok(rc
!=0,"***warning*** failed to restore the original value: rc=%d err=%d\n",rc
,GetLastError());
2336 test_reg_key(SPI_SETDESKWALLPAPER_REGKEY
, SPI_SETDESKWALLPAPER_VALNAME
, oldval
);
2339 static void test_WM_DISPLAYCHANGE(void)
2341 DEVMODE mode
, startmode
;
2342 int start_bpp
, last_set_bpp
= 0;
2343 int test_bpps
[] = {8, 16, 24, 32}, i
;
2347 if (!pChangeDisplaySettingsExA
)
2349 win_skip("ChangeDisplaySettingsExA is not available\n");
2353 displaychange_test_active
= TRUE
;
2355 memset(&startmode
, 0, sizeof(startmode
));
2356 startmode
.dmSize
= sizeof(startmode
);
2357 EnumDisplaySettings(NULL
, ENUM_CURRENT_SETTINGS
, &startmode
);
2358 start_bpp
= startmode
.dmBitsPerPel
;
2360 displaychange_sem
= CreateSemaphore(NULL
, 0, 1, NULL
);
2362 for(i
= 0; i
< sizeof(test_bpps
)/sizeof(test_bpps
[0]); i
++) {
2365 memset(&mode
, 0, sizeof(mode
));
2366 mode
.dmSize
= sizeof(mode
);
2367 mode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
2368 mode
.dmBitsPerPel
= test_bpps
[i
];
2369 mode
.dmPelsWidth
= GetSystemMetrics(SM_CXSCREEN
);
2370 mode
.dmPelsHeight
= GetSystemMetrics(SM_CYSCREEN
);
2372 change_counter
= 0; /* This sends a SETTINGSCHANGE message as well in which we aren't interested */
2373 displaychange_ok
= TRUE
;
2374 change_ret
= pChangeDisplaySettingsExA(NULL
, &mode
, NULL
, 0, NULL
);
2375 /* Wait quite long for the message, screen setting changes can take some time */
2376 if(change_ret
== DISP_CHANGE_SUCCESSFUL
) {
2377 wait_ret
= WaitForSingleObject(displaychange_sem
, 10000);
2378 /* we may not get a notification if nothing changed */
2379 if (wait_ret
== WAIT_TIMEOUT
&& !last_set_bpp
&& start_bpp
== test_bpps
[i
])
2381 ok(wait_ret
== WAIT_OBJECT_0
, "Waiting for the WM_DISPLAYCHANGE message timed out\n");
2383 displaychange_ok
= FALSE
;
2385 if(change_ret
!= DISP_CHANGE_SUCCESSFUL
) {
2386 skip("Setting depth %d failed(ret = %d)\n", test_bpps
[i
], change_ret
);
2387 ok(last_bpp
== -1, "WM_DISPLAYCHANGE was sent with wParam %d despite mode change failure\n", last_bpp
);
2391 if(start_bpp
!= test_bpps
[i
]) {
2392 todo_wine
ok(last_bpp
== test_bpps
[i
], "Set bpp %d, but WM_DISPLAYCHANGE reported bpp %d\n", test_bpps
[i
], last_bpp
);
2394 ok(last_bpp
== test_bpps
[i
], "Set bpp %d, but WM_DISPLAYCHANGE reported bpp %d\n", test_bpps
[i
], last_bpp
);
2396 last_set_bpp
= test_bpps
[i
];
2399 if(start_bpp
!= last_set_bpp
&& last_set_bpp
!= 0) {
2400 memset(&mode
, 0, sizeof(mode
));
2401 mode
.dmSize
= sizeof(mode
);
2402 mode
.dmFields
= DM_BITSPERPEL
| DM_PELSWIDTH
| DM_PELSHEIGHT
;
2403 mode
.dmBitsPerPel
= start_bpp
;
2404 mode
.dmPelsWidth
= GetSystemMetrics(SM_CXSCREEN
);
2405 mode
.dmPelsHeight
= GetSystemMetrics(SM_CYSCREEN
);
2407 displaychange_ok
= TRUE
;
2408 change_ret
= pChangeDisplaySettingsExA(NULL
, &mode
, NULL
, 0, NULL
);
2409 WaitForSingleObject(displaychange_sem
, 10000);
2410 displaychange_ok
= FALSE
;
2411 CloseHandle(displaychange_sem
);
2412 displaychange_sem
= 0;
2415 displaychange_test_active
= FALSE
;
2419 * Registry entries for the system parameters.
2420 * Names are created by 'SET' flags names.
2421 * We assume that corresponding 'GET' entries use the same registry keys.
2423 static DWORD WINAPI
SysParamsThreadFunc( LPVOID lpParam
)
2425 test_SPI_SETBEEP(); /* 1 */
2426 test_SPI_SETMOUSE(); /* 4 */
2427 test_SPI_SETBORDER(); /* 6 */
2428 test_SPI_SETKEYBOARDSPEED(); /* 10 */
2429 test_SPI_ICONHORIZONTALSPACING(); /* 13 */
2430 test_SPI_SETSCREENSAVETIMEOUT(); /* 14 */
2431 test_SPI_SETSCREENSAVEACTIVE(); /* 17 */
2432 test_SPI_SETGRIDGRANULARITY(); /* 19 */
2433 test_SPI_SETKEYBOARDDELAY(); /* 23 */
2434 test_SPI_ICONVERTICALSPACING(); /* 24 */
2435 test_SPI_SETICONTITLEWRAP(); /* 26 */
2436 test_SPI_SETMENUDROPALIGNMENT(); /* 28 */
2437 test_SPI_SETDOUBLECLKWIDTH(); /* 29 */
2438 test_SPI_SETDOUBLECLKHEIGHT(); /* 30 */
2439 test_SPI_SETDOUBLECLICKTIME(); /* 32 */
2440 test_SPI_SETMOUSEBUTTONSWAP(); /* 33 */
2441 test_SPI_SETFASTTASKSWITCH(); /* 36 */
2442 test_SPI_SETDRAGFULLWINDOWS(); /* 37 */
2443 /* test_WM_DISPLAYCHANGE seems to be somewhat buggy on
2444 * some versions of Windows (Vista, Win2k8, Win7B) in that
2445 * not all metrics are properly restored. Problems are
2446 * SM_CXMAXTRACK, SM_CYMAXTRACK
2447 * Fortunately setting the Non-Client metrics like in
2448 * test_SPI_SETNONCLIENTMETRICS will corect this. That is why
2449 * we do the DISPLAY change now... */
2450 test_WM_DISPLAYCHANGE();
2451 test_SPI_SETNONCLIENTMETRICS(); /* 42 */
2452 test_SPI_SETMINIMIZEDMETRICS(); /* 44 */
2453 test_SPI_SETICONMETRICS(); /* 46 */
2454 test_SPI_SETWORKAREA(); /* 47 */
2455 test_SPI_SETSHOWSOUNDS(); /* 57 */
2456 test_SPI_SETKEYBOARDPREF(); /* 69 */
2457 test_SPI_SETSCREENREADER(); /* 71 */
2458 test_SPI_SETFONTSMOOTHING(); /* 75 */
2459 test_SPI_SETLOWPOWERACTIVE(); /* 85 */
2460 test_SPI_SETPOWEROFFACTIVE(); /* 86 */
2461 test_SPI_SETSNAPTODEFBUTTON(); /* 95 */
2462 test_SPI_SETMOUSEHOVERWIDTH(); /* 99 */
2463 test_SPI_SETMOUSEHOVERHEIGHT(); /* 101 */
2464 test_SPI_SETMOUSEHOVERTIME(); /* 103 */
2465 test_SPI_SETWHEELSCROLLLINES(); /* 105 */
2466 test_SPI_SETMENUSHOWDELAY(); /* 107 */
2467 test_SPI_SETWHEELSCROLLCHARS(); /* 108 */
2468 test_SPI_SETWALLPAPER(); /* 115 */
2471 SendMessageA( ghTestWnd
, WM_DESTROY
, 0, 0 );
2475 /* test calculation of GetSystemMetrics values (mostly) from non client metrics,
2476 * icon metrics and minimized metrics.
2479 /* copied from wine's GdiGetCharDimensions, which is not available on most
2480 * windows versions */
2481 static LONG
_GdiGetCharDimensions(HDC hdc
, LPTEXTMETRICA lptm
, LONG
*height
)
2484 static const CHAR alphabet
[] = {
2485 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
2486 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H',
2487 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',0};
2489 if(lptm
&& !GetTextMetricsA(hdc
, lptm
)) return 0;
2491 if(!GetTextExtentPointA(hdc
, alphabet
, 52, &sz
)) return 0;
2493 if (height
) *height
= sz
.cy
;
2494 return (sz
.cx
/ 26 + 1) / 2;
2497 /* get text metrics and/or "average" char width of the specified logfont
2498 * for the specified dc */
2499 static void get_text_metr_size( HDC hdc
, LOGFONTA
*plf
, TEXTMETRICA
* ptm
, UINT
*psz
)
2501 HFONT hfont
, hfontsav
;
2503 if( !ptm
) ptm
= &tm
;
2504 hfont
= CreateFontIndirectA( plf
);
2505 if( !hfont
|| ( hfontsav
= SelectObject( hdc
, hfont
)) == NULL
) {
2508 if( hfont
) DeleteObject( hfont
);
2511 GetTextMetricsA( hdc
, ptm
);
2513 if( !(*psz
= _GdiGetCharDimensions( hdc
, ptm
, NULL
)))
2515 SelectObject( hdc
, hfontsav
);
2516 DeleteObject( hfont
);
2519 static int gsm_error_ctr
;
2521 #define ok_gsm( i, e)\
2524 int act = GetSystemMetrics( (i));\
2525 if( exp != act) gsm_error_ctr++;\
2526 ok( !( exp != act),"GetSystemMetrics(%s): expected %d actual %d\n", #i, exp,act);\
2528 #define ok_gsm_2( i, e1, e2)\
2532 int act = GetSystemMetrics( (i));\
2533 if( exp1 != act && exp2 != act) gsm_error_ctr++;\
2534 ok( !( exp1 != act && exp2 != act), "GetSystemMetrics(%s): expected %d or %d actual %d\n", #i, exp1, exp2, act);\
2536 #define ok_gsm_3( i, e1, e2, e3)\
2541 int act = GetSystemMetrics( (i));\
2542 if( exp1 != act && exp2 != act && exp3 != act) gsm_error_ctr++;\
2543 ok( !( exp1 != act && exp2 != act && exp3 != act),"GetSystemMetrics(%s): expected %d or %d or %d actual %d\n", #i, exp1, exp2, exp3, act);\
2546 static void test_GetSystemMetrics( void)
2548 TEXTMETRICA tmMenuFont
;
2549 UINT IconSpacing
, IconVerticalSpacing
;
2552 HDC hdc
= CreateIC( "Display", 0, 0, 0);
2554 INT CaptionWidthfromreg
;
2555 MINIMIZEDMETRICS minim
;
2556 NONCLIENTMETRICS ncm
;
2559 minim
.cbSize
= sizeof( minim
);
2560 ncm
.cbSize
= sizeof( ncm
);
2561 SystemParametersInfo( SPI_GETMINIMIZEDMETRICS
, 0, &minim
, 0);
2562 rc
= SystemParametersInfo( SPI_GETNONCLIENTMETRICS
, 0, &ncm
, 0);
2564 win_skip("SPI_GETNONCLIENTMETRICS is not available\n");
2567 /* CaptionWidth from the registry may have different value of iCaptionWidth
2568 * from the non client metrics (observed on WinXP) */
2569 CaptionWidthfromreg
= metricfromreg(
2570 "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi
);
2571 get_text_metr_size( hdc
, &ncm
.lfMenuFont
, &tmMenuFont
, NULL
);
2572 get_text_metr_size( hdc
, &ncm
.lfCaptionFont
, NULL
, &avcwCaption
);
2573 /* FIXME: use icon metric */
2574 if( !SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0, &IconVerticalSpacing
, 0))
2575 IconVerticalSpacing
= 0;
2576 if( !SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0, &IconSpacing
, 0 ))
2578 /* reset error counters */
2583 /* SM_CXSCREEN, cannot test these two */
2585 ok_gsm( SM_CXVSCROLL
, ncm
.iScrollWidth
);
2586 ok_gsm( SM_CYHSCROLL
, ncm
.iScrollWidth
);
2587 ok_gsm( SM_CYCAPTION
, ncm
.iCaptionHeight
+1);
2588 ok_gsm( SM_CXBORDER
, 1);
2589 ok_gsm( SM_CYBORDER
, 1);
2590 ok_gsm( SM_CXDLGFRAME
, 3);
2591 ok_gsm( SM_CYDLGFRAME
, 3);
2592 ok_gsm( SM_CYVTHUMB
, ncm
.iScrollHeight
);
2593 ok_gsm( SM_CXHTHUMB
, ncm
.iScrollHeight
);
2598 ok_gsm( SM_CYMENU
, ncm
.iMenuHeight
+ 1);
2599 ok_gsm( SM_CXFULLSCREEN
,
2600 GetSystemMetrics( SM_CXMAXIMIZED
) - 2 * GetSystemMetrics( SM_CXFRAME
));
2601 ok_gsm( SM_CYFULLSCREEN
,
2602 GetSystemMetrics( SM_CYMAXIMIZED
) - GetSystemMetrics( SM_CYMIN
));
2603 /* SM_CYKANJIWINDOW */
2604 /* SM_MOUSEPRESENT */
2605 ok_gsm( SM_CYVSCROLL
, ncm
.iScrollHeight
);
2606 ok_gsm( SM_CXHSCROLL
, ncm
.iScrollHeight
);
2613 ok_gsm( SM_CXMIN
, 3 * max( CaptionWidthfromreg
>= 0 ? CaptionWidthfromreg
: ncm
.iCaptionWidth
, 8) +
2614 GetSystemMetrics( SM_CYSIZE
) + 4 + 4 * avcwCaption
+ 2 * GetSystemMetrics( SM_CXFRAME
));
2615 ok_gsm( SM_CYMIN
, GetSystemMetrics( SM_CYCAPTION
) +
2616 2 * GetSystemMetrics( SM_CYFRAME
));
2617 ok_gsm_2( SM_CXSIZE
,
2618 ncm
.iCaptionWidth
, /* classic/standard windows style */
2619 GetSystemMetrics( SM_CYCAPTION
) - 1 /* WinXP style */
2621 ok_gsm( SM_CYSIZE
, ncm
.iCaptionHeight
);
2622 ok_gsm( SM_CXFRAME
, ncm
.iBorderWidth
+ 3);
2623 ok_gsm( SM_CYFRAME
, ncm
.iBorderWidth
+ 3);
2624 ok_gsm( SM_CXMINTRACK
, GetSystemMetrics( SM_CXMIN
));
2625 ok_gsm( SM_CYMINTRACK
, GetSystemMetrics( SM_CYMIN
));
2626 /* SM_CXDOUBLECLK */
2627 /* SM_CYDOUBLECLK */
2628 if( IconSpacing
) ok_gsm( SM_CXICONSPACING
, IconSpacing
);
2629 if( IconVerticalSpacing
) ok_gsm( SM_CYICONSPACING
, IconVerticalSpacing
);
2630 /* SM_MENUDROPALIGNMENT */
2632 /* SM_DBCSENABLED */
2633 /* SM_CMOUSEBUTTONS */
2635 ok_gsm( SM_CXEDGE
, 2);
2636 ok_gsm( SM_CYEDGE
, 2);
2637 /* sign-extension for iHorzGap/iVertGap is broken on Win9x */
2638 ok_gsm( SM_CXMINSPACING
, GetSystemMetrics( SM_CXMINIMIZED
) + (short)minim
.iHorzGap
);
2639 ok_gsm( SM_CYMINSPACING
, GetSystemMetrics( SM_CYMINIMIZED
) + (short)minim
.iVertGap
);
2642 ok_gsm( SM_CYSMCAPTION
, ncm
.iSmCaptionHeight
+ 1);
2643 ok_gsm_3( SM_CXSMSIZE
,
2644 ncm
.iSmCaptionWidth
, /* classic/standard windows style */
2645 GetSystemMetrics( SM_CYSMCAPTION
) - 1, /* WinXP style */
2646 smcxsmsize
/* winXP seems to cache this value: setnonclientmetric
2647 does not change it */
2649 ok_gsm( SM_CYSMSIZE
, GetSystemMetrics( SM_CYSMCAPTION
) - 1);
2650 ok_gsm( SM_CXMENUSIZE
, ncm
.iMenuWidth
);
2651 ok_gsm( SM_CYMENUSIZE
, ncm
.iMenuHeight
);
2653 ok_gsm( SM_CXMINIMIZED
, minim
.iWidth
+ 6);
2654 ok_gsm( SM_CYMINIMIZED
, GetSystemMetrics( SM_CYCAPTION
) + 5);
2655 screen
.cx
= GetSystemMetrics( SM_CXVIRTUALSCREEN
);
2656 screen
.cy
= GetSystemMetrics( SM_CYVIRTUALSCREEN
);
2657 if (!screen
.cx
|| !screen
.cy
) /* not supported on NT4 */
2659 screen
.cx
= GetSystemMetrics( SM_CXSCREEN
);
2660 screen
.cy
= GetSystemMetrics( SM_CYSCREEN
);
2662 ok_gsm( SM_CXMAXTRACK
, screen
.cx
+ 4 + 2 * GetSystemMetrics(SM_CXFRAME
));
2663 ok_gsm( SM_CYMAXTRACK
, screen
.cy
+ 4 + 2 * GetSystemMetrics(SM_CYFRAME
));
2664 /* the next two cannot really be tested as they depend on (application)
2666 /* SM_CXMAXIMIZED */
2667 /* SM_CYMAXIMIZED */
2676 ok_gsm( SM_CXMENUCHECK
,
2677 ((tmMenuFont
.tmHeight
+ tmMenuFont
.tmExternalLeading
+1)/2)*2-1);
2678 ok_gsm( SM_CYMENUCHECK
,
2679 ((tmMenuFont
.tmHeight
+ tmMenuFont
.tmExternalLeading
+1)/2)*2-1);
2680 /* SM_SLOWMACHINE */
2681 /* SM_MIDEASTENABLED */
2682 /* SM_MOUSEWHEELPRESENT */
2683 /* SM_XVIRTUALSCREEN */
2684 /* SM_YVIRTUALSCREEN */
2685 /* SM_CXVIRTUALSCREEN */
2686 /* SM_CYVIRTUALSCREEN */
2688 /* SM_SAMEDISPLAYFORMAT */
2690 /* SM_CXFOCUSBORDER */
2691 /* SM_CYFOCUSBORDER */
2693 /* SM_MEDIACENTER */
2696 if( gsm_error_ctr
) { /* if any errors where found */
2697 trace( "BorderWidth %d CaptionWidth %d CaptionHeight %d IconSpacing %d IconVerticalSpacing %d\n",
2698 ncm
.iBorderWidth
, ncm
.iCaptionWidth
, ncm
.iCaptionHeight
, IconSpacing
, IconVerticalSpacing
);
2699 trace( "MenuHeight %d MenuWidth %d ScrollHeight %d ScrollWidth %d SmCaptionHeight %d SmCaptionWidth %d\n",
2700 ncm
.iMenuHeight
, ncm
.iMenuWidth
, ncm
.iScrollHeight
, ncm
.iScrollWidth
, ncm
.iSmCaptionHeight
, ncm
.iSmCaptionWidth
);
2701 trace( "Captionfontchar width %d MenuFont %d,%d CaptionWidth from registry: %d screen %d,%d\n",
2702 avcwCaption
, tmMenuFont
.tmHeight
, tmMenuFont
.tmExternalLeading
, CaptionWidthfromreg
, screen
.cx
, screen
.cy
);
2707 static void test_EnumDisplaySettings(void)
2714 memset(&devmode
, 0, sizeof(devmode
));
2715 devmode
.dmSize
= sizeof(devmode
);
2716 EnumDisplaySettings(NULL
, ENUM_CURRENT_SETTINGS
, &devmode
);
2719 val
= GetDeviceCaps(hdc
, BITSPIXEL
);
2720 ok(devmode
.dmBitsPerPel
== val
, "GetDeviceCaps(BITSPIXEL) returned %d, EnumDisplaySettings returned %d\n",
2721 val
, devmode
.dmBitsPerPel
);
2723 val
= GetDeviceCaps(hdc
, NUMCOLORS
);
2724 if(devmode
.dmBitsPerPel
<= 8) {
2725 ok(val
== 256, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode
.dmBitsPerPel
, val
);
2727 ok(val
== -1, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode
.dmBitsPerPel
, val
);
2734 SetLastError (0xdeadbeef);
2735 if (!EnumDisplaySettings(NULL
, num
++, &devmode
)) {
2736 DWORD le
= GetLastError();
2737 ok(le
== ERROR_NO_MORE_FILES
||
2738 le
== 0xdeadbeef, /* XP, 2003 */
2739 "Expected ERROR_NO_MORE_FILES or 0xdeadbeef, got %d\n", le
);
2745 START_TEST(sysparams
)
2753 HANDLE hInstance
, hdll
;
2755 hdll
= GetModuleHandleA("user32.dll");
2756 pChangeDisplaySettingsExA
=(void*)GetProcAddress(hdll
, "ChangeDisplaySettingsExA");
2758 hInstance
= GetModuleHandleA( NULL
);
2760 dpi
= GetDeviceCaps( hdc
, LOGPIXELSY
);
2761 iswin9x
= GetVersion() & 0x80000000;
2763 /* This test requires interactivity, if we don't have it, give up */
2764 if (!SystemParametersInfoA( SPI_SETBEEP
, TRUE
, 0, SPIF_UPDATEINIFILE
| SPIF_SENDCHANGE
) &&
2765 GetLastError()==ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION
) return;
2767 argc
= winetest_get_mainargs(&argv
);
2768 strict
=(argc
>= 3 && strcmp(argv
[2],"strict")==0);
2769 trace("strict=%d\n",strict
);
2771 trace("testing GetSystemMetrics with your current desktop settings\n");
2772 test_GetSystemMetrics( );
2773 trace("testing EnumDisplaySettings vs GetDeviceCaps\n");
2774 test_EnumDisplaySettings( );
2777 change_last_param
= 0;
2779 wc
.lpszClassName
= "SysParamsTestClass";
2780 wc
.lpfnWndProc
= SysParamsTestWndProc
;
2781 wc
.style
= CS_OWNDC
| CS_VREDRAW
| CS_HREDRAW
;
2782 wc
.hInstance
= hInstance
;
2783 wc
.hIcon
= LoadIconA( 0, IDI_APPLICATION
);
2784 wc
.hCursor
= LoadCursorA( 0, IDC_ARROW
);
2785 wc
.hbrBackground
= (HBRUSH
)( COLOR_WINDOW
+ 1 );
2786 wc
.lpszMenuName
= 0;
2789 RegisterClassA( &wc
);
2791 ghTestWnd
= CreateWindowA( "SysParamsTestClass", "Test System Parameters Application",
2792 WS_OVERLAPPEDWINDOW
, 0, 0, 100, 100, 0, 0, hInstance
, NULL
);
2794 hThread
= CreateThread( NULL
, 0, SysParamsThreadFunc
, 0, 0, &dwThreadId
);
2796 CloseHandle( hThread
);
2798 while( GetMessageA( &msg
, 0, 0, 0 )) {
2799 TranslateMessage( &msg
);
2800 DispatchMessageA( &msg
);