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