/* Unit test suite for functions SystemParametersInfo and GetSystemMetrics. * * Copyright 2002 Andriy Palamarchuk * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #define _WIN32_WINNT 0x0600 /* For SPI_GETMOUSEHOVERWIDTH and more */ #define _WIN32_IE 0x0700 #define WINVER 0x0600 /* For COLOR_MENUBAR, NONCLIENTMETRICS with padding */ #include #include #include #include #include "wine/test.h" #include "windef.h" #include "winbase.h" #include "wingdi.h" #include "winreg.h" #include "winuser.h" #include "winnls.h" #ifndef SPI_GETDESKWALLPAPER # define SPI_GETDESKWALLPAPER 0x0073 #endif static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, LPVOID); static BOOL (WINAPI *pIsProcessDPIAware)(void); static BOOL (WINAPI *pSetProcessDPIAware)(void); static BOOL strict; static int dpi, real_dpi; static BOOL iswin9x; static HDC hdc; #define eq(received, expected, label, type) \ ok((received) == (expected), "%s: got " type " instead of " type "\n", (label),(received),(expected)) #define SPI_SETBEEP_REGKEY "Control Panel\\Sound" #define SPI_SETBEEP_VALNAME "Beep" #define SPI_SETMOUSE_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSE_VALNAME1 "MouseThreshold1" #define SPI_SETMOUSE_VALNAME2 "MouseThreshold2" #define SPI_SETMOUSE_VALNAME3 "MouseSpeed" #define SPI_SETBORDER_REGKEY "Control Panel\\Desktop\\WindowMetrics" #define SPI_SETBORDER_REGKEY2 "Control Panel\\Desktop" #define SPI_SETBORDER_VALNAME "BorderWidth" #define SPI_METRIC_REGKEY "Control Panel\\Desktop\\WindowMetrics" #define SPI_SCROLLWIDTH_VALNAME "ScrollWidth" #define SPI_SCROLLHEIGHT_VALNAME "ScrollHeight" #define SPI_CAPTIONWIDTH_VALNAME "CaptionWidth" #define SPI_CAPTIONHEIGHT_VALNAME "CaptionHeight" #define SPI_CAPTIONFONT_VALNAME "CaptionFont" #define SPI_SMCAPTIONWIDTH_VALNAME "SmCaptionWidth" #define SPI_SMCAPTIONHEIGHT_VALNAME "SmCaptionHeight" #define SPI_SMCAPTIONFONT_VALNAME "SmCaptionFont" #define SPI_MENUWIDTH_VALNAME "MenuWidth" #define SPI_MENUHEIGHT_VALNAME "MenuHeight" #define SPI_MENUFONT_VALNAME "MenuFont" #define SPI_STATUSFONT_VALNAME "StatusFont" #define SPI_MESSAGEFONT_VALNAME "MessageFont" #define SPI_SETKEYBOARDSPEED_REGKEY "Control Panel\\Keyboard" #define SPI_SETKEYBOARDSPEED_VALNAME "KeyboardSpeed" #define SPI_ICONHORIZONTALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics" #define SPI_ICONHORIZONTALSPACING_REGKEY2 "Control Panel\\Desktop" #define SPI_ICONHORIZONTALSPACING_VALNAME "IconSpacing" #define SPI_ICONVERTICALSPACING_REGKEY "Control Panel\\Desktop\\WindowMetrics" #define SPI_ICONVERTICALSPACING_REGKEY2 "Control Panel\\Desktop" #define SPI_ICONVERTICALSPACING_VALNAME "IconVerticalSpacing" #define SPI_MINIMIZEDMETRICS_REGKEY "Control Panel\\Desktop\\WindowMetrics" #define SPI_MINWIDTH_VALNAME "MinWidth" #define SPI_MINHORZGAP_VALNAME "MinHorzGap" #define SPI_MINVERTGAP_VALNAME "MinVertGap" #define SPI_MINARRANGE_VALNAME "MinArrange" #define SPI_SETSCREENSAVETIMEOUT_REGKEY "Control Panel\\Desktop" #define SPI_SETSCREENSAVETIMEOUT_VALNAME "ScreenSaveTimeOut" #define SPI_SETSCREENSAVEACTIVE_REGKEY "Control Panel\\Desktop" #define SPI_SETSCREENSAVEACTIVE_VALNAME "ScreenSaveActive" #define SPI_SETGRIDGRANULARITY_REGKEY "Control Panel\\Desktop" #define SPI_SETGRIDGRANULARITY_VALNAME "GridGranularity" #define SPI_SETKEYBOARDDELAY_REGKEY "Control Panel\\Keyboard" #define SPI_SETKEYBOARDDELAY_VALNAME "KeyboardDelay" #define SPI_SETICONTITLEWRAP_REGKEY1 "Control Panel\\Desktop\\WindowMetrics" #define SPI_SETICONTITLEWRAP_REGKEY2 "Control Panel\\Desktop" #define SPI_SETICONTITLEWRAP_VALNAME "IconTitleWrap" #define SPI_SETMENUDROPALIGNMENT_REGKEY1 "Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows" #define SPI_SETMENUDROPALIGNMENT_REGKEY2 "Control Panel\\Desktop" #define SPI_SETMENUDROPALIGNMENT_VALNAME "MenuDropAlignment" #define SPI_SETDOUBLECLKWIDTH_REGKEY1 "Control Panel\\Mouse" #define SPI_SETDOUBLECLKWIDTH_REGKEY2 "Control Panel\\Desktop" #define SPI_SETDOUBLECLKWIDTH_VALNAME "DoubleClickWidth" #define SPI_SETDOUBLECLKHEIGHT_REGKEY1 "Control Panel\\Mouse" #define SPI_SETDOUBLECLKHEIGHT_REGKEY2 "Control Panel\\Desktop" #define SPI_SETDOUBLECLKHEIGHT_VALNAME "DoubleClickHeight" #define SPI_SETDOUBLECLICKTIME_REGKEY "Control Panel\\Mouse" #define SPI_SETDOUBLECLICKTIME_VALNAME "DoubleClickSpeed" #define SPI_SETMOUSEBUTTONSWAP_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSEBUTTONSWAP_VALNAME "SwapMouseButtons" #define SPI_SETWORKAREA_REGKEY "Control Panel\\Desktop" #define SPI_SETWORKAREA_VALNAME "WINE_WorkArea" #define SPI_SETSHOWSOUNDS_REGKEY "Control Panel\\Accessibility\\ShowSounds" #define SPI_SETSHOWSOUNDS_VALNAME "On" #define SPI_SETKEYBOARDPREF_REGKEY "Control Panel\\Accessibility\\Keyboard Preference" #define SPI_SETKEYBOARDPREF_VALNAME "On" #define SPI_SETKEYBOARDPREF_REGKEY_LEGACY "Control Panel\\Accessibility" #define SPI_SETKEYBOARDPREF_VALNAME_LEGACY "Keyboard Preference" #define SPI_SETSCREENREADER_REGKEY "Control Panel\\Accessibility\\Blind Access" #define SPI_SETSCREENREADER_VALNAME "On" #define SPI_SETSCREENREADER_REGKEY_LEGACY "Control Panel\\Accessibility" #define SPI_SETSCREENREADER_VALNAME_LEGACY "Blind Access" #define SPI_SETFONTSMOOTHING_REGKEY "Control Panel\\Desktop" #define SPI_SETFONTSMOOTHING_VALNAME "FontSmoothing" #define SPI_SETFONTSMOOTHINGTYPE_VALNAME "FontSmoothingType" #define SPI_SETFONTSMOOTHINGCONTRAST_VALNAME "FontSmoothingGamma" #define SPI_SETFONTSMOOTHINGORIENTATION_VALNAME "FontSmoothingOrientation" #define SPI_SETLOWPOWERACTIVE_REGKEY "Control Panel\\Desktop" #define SPI_SETLOWPOWERACTIVE_VALNAME "LowPowerActive" #define SPI_SETPOWEROFFACTIVE_REGKEY "Control Panel\\Desktop" #define SPI_SETPOWEROFFACTIVE_VALNAME "PowerOffActive" #define SPI_SETDRAGFULLWINDOWS_REGKEY "Control Panel\\Desktop" #define SPI_SETDRAGFULLWINDOWS_VALNAME "DragFullWindows" #define SPI_SETSNAPTODEFBUTTON_REGKEY "Control Panel\\Mouse" #define SPI_SETSNAPTODEFBUTTON_VALNAME "SnapToDefaultButton" #define SPI_SETMOUSEHOVERWIDTH_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSEHOVERWIDTH_VALNAME "MouseHoverWidth" #define SPI_SETMOUSEHOVERHEIGHT_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSEHOVERHEIGHT_VALNAME "MouseHoverHeight" #define SPI_SETMOUSEHOVERTIME_REGKEY "Control Panel\\Mouse" #define SPI_SETMOUSEHOVERTIME_VALNAME "MouseHoverTime" #define SPI_SETMOUSESCROLLCHARS_REGKEY "Control Panel\\Desktop" #define SPI_SETMOUSESCROLLCHARS_VALNAME "WheelScrollChars" #define SPI_SETMOUSESCROLLLINES_REGKEY "Control Panel\\Desktop" #define SPI_SETMOUSESCROLLLINES_VALNAME "WheelScrollLines" #define SPI_SETMENUSHOWDELAY_REGKEY "Control Panel\\Desktop" #define SPI_SETMENUSHOWDELAY_VALNAME "MenuShowDelay" #define SPI_SETDESKWALLPAPER_REGKEY "Control Panel\\Desktop" #define SPI_SETDESKWALLPAPER_VALNAME "Wallpaper" /* volatile registry branch under CURRENT_USER_REGKEY for temporary values storage */ #define WINE_CURRENT_USER_REGKEY "Wine" static HWND ghTestWnd; static DWORD WINAPI SysParamsThreadFunc( LPVOID lpParam ); static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ); static int change_counter; static int change_setworkarea_param, change_iconverticalspacing_param; static int change_last_param; static int last_bpp; static BOOL displaychange_ok = FALSE, displaychange_test_active = FALSE; static HANDLE displaychange_sem = 0; static BOOL get_reg_dword(HKEY base, const char *key_name, const char *value_name, DWORD *value) { HKEY key; DWORD type, data, size = sizeof(data); BOOL ret = FALSE; if (RegOpenKeyA(base, key_name, &key) == ERROR_SUCCESS) { if (RegQueryValueExA(key, value_name, NULL, &type, (void *)&data, &size) == ERROR_SUCCESS && type == REG_DWORD) { *value = data; ret = TRUE; } RegCloseKey(key); } return ret; } static DWORD get_real_dpi(void) { DWORD dpi; if (get_reg_dword(HKEY_CURRENT_USER, "Control Panel\\Desktop", "LogPixels", &dpi)) return dpi; if (get_reg_dword(HKEY_CURRENT_CONFIG, "Software\\Fonts", "LogPixels", &dpi)) return dpi; return USER_DEFAULT_SCREEN_DPI; } static LRESULT CALLBACK SysParamsTestWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { switch (msg) { case WM_DISPLAYCHANGE: ok(displaychange_ok, "Unexpected WM_DISPLAYCHANGE message\n"); last_bpp = wParam; displaychange_ok = FALSE; ReleaseSemaphore(displaychange_sem, 1, 0); break; case WM_SETTINGCHANGE: if (change_counter>0) { /* ignore these messages caused by resizing of toolbars */ if( wParam == SPI_SETWORKAREA){ change_setworkarea_param = 1; break; } else if( wParam == SPI_ICONVERTICALSPACING) { change_iconverticalspacing_param = 1; break; } else if( displaychange_test_active) break; if( !change_last_param){ change_last_param = wParam; break; } ok(0,"too many changes counter=%d last change=%d\n", change_counter,change_last_param); change_counter++; change_last_param = wParam; break; } change_counter++; change_last_param = change_setworkarea_param = change_iconverticalspacing_param =0; if( wParam == SPI_SETWORKAREA) change_setworkarea_param = 1; else if( wParam == SPI_ICONVERTICALSPACING) change_iconverticalspacing_param = 1; else change_last_param = wParam; break; case WM_DESTROY: PostQuitMessage( 0 ); break; /* drop through */ default: return( DefWindowProcA( hWnd, msg, wParam, lParam ) ); } return 0; } /* Performs testing for system parameters messages params: - system parameter id - supposed value of the registry key */ static void test_change_message( int action, int optional ) { if (change_counter==0 && optional==1) return; ok( 1 == change_counter, "Missed a message: change_counter=%d\n", change_counter ); change_counter = 0; ok( action == change_last_param || ( change_setworkarea_param && action == SPI_SETWORKAREA) || ( change_iconverticalspacing_param && action == SPI_ICONVERTICALSPACING), "Wrong action got %d expected %d\n", change_last_param, action ); change_last_param = 0; } static BOOL test_error_msg ( int rc, const char *name ) { DWORD last_error = GetLastError(); if (rc==0) { if (last_error==0xdeadbeef || last_error==ERROR_INVALID_SPI_VALUE || last_error==ERROR_INVALID_PARAMETER) { skip("%s not supported on this platform\n", name); } else if (last_error==ERROR_ACCESS_DENIED) { skip("%s does not have privileges to run\n", name); } else { trace("%s failed for reason: %d. Indicating test failure and skipping remainder of test\n",name,last_error); ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,last_error); } return FALSE; } else { ok(rc!=0,"SystemParametersInfoA: rc=%d err=%d\n",rc,last_error); return TRUE; } } /* * Tests the HKEY_CURRENT_USER subkey value. * The value should contain string value. */ static void _test_reg_key( LPCSTR subKey1, LPCSTR subKey2, LPCSTR valName1, LPCSTR valName2, const void *exp_value, DWORD exp_type, BOOL optional ) { CHAR value[MAX_PATH]; DWORD valueLen; DWORD type; HKEY hKey; LONG rc; int found=0; *value='\0'; valueLen=sizeof(value); RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey ); rc=RegQueryValueExA( hKey, valName1, NULL, &type, (LPBYTE)value, &valueLen ); RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); switch (exp_type) { case REG_DWORD: ok( *(DWORD *)value == *(DWORD *)exp_value, "Wrong value in registry: %s %s %08x/%08x\n", subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); break; case REG_SZ: ok( !strcmp( exp_value, value ), "Wrong value in registry: %s %s '%s' instead of '%s'\n", subKey1, valName1, value, (const char *)exp_value ); break; } found++; } else if (strict) { ok(0,"Missing registry entry: subKey=%s, valName=%s\n", subKey1, valName1); } if (valName2) { *value='\0'; valueLen=sizeof(value); RegOpenKeyA( HKEY_CURRENT_USER, subKey1, &hKey ); rc=RegQueryValueExA( hKey, valName2, NULL, &type, (LPBYTE)value, &valueLen ); RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); switch (exp_type) { case REG_DWORD: ok( *(DWORD *)value == *(DWORD *)exp_value, "Wrong value in registry: %s %s %08x/%08x\n", subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); break; case REG_SZ: ok( !strcmp( exp_value, value ), "Wrong value in registry: %s %s '%s' instead of '%s'\n", subKey1, valName1, value, (const char *)exp_value ); break; } found++; } else if (strict) { ok( 0,"Missing registry entry: subKey=%s, valName=%s\n", subKey1, valName2 ); } } if (subKey2 && !strict) { *value='\0'; valueLen=sizeof(value); RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey ); rc=RegQueryValueExA( hKey, valName1, NULL, &type, (LPBYTE)value, &valueLen ); RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); switch (exp_type) { case REG_DWORD: ok( *(DWORD *)value == *(DWORD *)exp_value, "Wrong value in registry: %s %s %08x/%08x\n", subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); break; case REG_SZ: ok( !strcmp( exp_value, value ), "Wrong value in registry: %s %s '%s' instead of '%s'\n", subKey1, valName1, value, (const char *)exp_value ); break; } found++; } else if (strict) { ok( 0,"Missing registry entry: subKey=%s, valName=%s\n", subKey2, valName1 ); } if (valName2) { *value='\0'; valueLen=sizeof(value); RegOpenKeyA( HKEY_CURRENT_USER, subKey2, &hKey ); rc=RegQueryValueExA( hKey, valName2, NULL, &type, (LPBYTE)value, &valueLen ); RegCloseKey( hKey ); if (rc==ERROR_SUCCESS) { ok( type == exp_type, "wrong type %u/%u\n", type, exp_type ); switch (exp_type) { case REG_DWORD: ok( *(DWORD *)value == *(DWORD *)exp_value, "Wrong value in registry: %s %s %08x/%08x\n", subKey1, valName1, *(DWORD *)value, *(DWORD *)exp_value ); break; case REG_SZ: ok( !strcmp( exp_value, value ), "Wrong value in registry: %s %s '%s' instead of '%s'\n", subKey1, valName1, value, (const char *)exp_value ); break; } found++; } else if (strict) { ok( 0,"Missing registry entry: subKey=%s, valName=%s\n", subKey2, valName2 ); } } } ok(found || optional, "Missing registry values: %s or %s in keys: %s or %s\n", valName1, (valName2?valName2:""), subKey1, (subKey2?subKey2:"") ); } #define test_reg_key( subKey, valName, testValue ) \ _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, FALSE ) #define test_reg_key_optional( subKey, valName, testValue ) \ _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_SZ, TRUE ) #define test_reg_key_ex( subKey1, subKey2, valName, testValue ) \ _test_reg_key( subKey1, subKey2, valName, NULL, testValue, REG_SZ, FALSE ) #define test_reg_key_ex2( subKey1, subKey2, valName1, valName2, testValue ) \ _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, FALSE ) #define test_reg_key_ex2_optional( subKey1, subKey2, valName1, valName2, testValue ) \ _test_reg_key( subKey1, subKey2, valName1, valName2, testValue, REG_SZ, TRUE ) #define test_reg_key_dword( subKey, valName, testValue ) \ _test_reg_key( subKey, NULL, valName, NULL, testValue, REG_DWORD, FALSE ) /* get a metric from the registry. If the value is negative * it is assumed to be in twips and converted to pixels */ static UINT metricfromreg( const char *keyname, const char *valname, int dpi) { HKEY hkey; char buf[64]; DWORD ret; DWORD size, type; int value; RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey ); size = sizeof(buf); ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)buf, &size ); RegCloseKey( hkey ); if( ret != ERROR_SUCCESS) return -1; value = atoi( buf); if( value < 0) value = ( -value * dpi + 720) / 1440; return value; } typedef struct { INT16 lfHeight; INT16 lfWidth; INT16 lfEscapement; INT16 lfOrientation; INT16 lfWeight; BYTE lfItalic; BYTE lfUnderline; BYTE lfStrikeOut; BYTE lfCharSet; BYTE lfOutPrecision; BYTE lfClipPrecision; BYTE lfQuality; BYTE lfPitchAndFamily; CHAR lfFaceName[LF_FACESIZE]; } LOGFONT16, *LPLOGFONT16; /* get logfont from the registry */ static int lffromreg( const char *keyname, const char *valname, LOGFONTA *plf) { HKEY hkey; LOGFONTW lfw; DWORD ret, size, type; RegOpenKeyA( HKEY_CURRENT_USER, keyname, &hkey ); size = sizeof( lfw); ret=RegQueryValueExA( hkey, valname, NULL, &type, (LPBYTE)&lfw, &size ); RegCloseKey( hkey ); ok( ret == ERROR_SUCCESS, "Key \"%s\" value \"%s\" not found\n", keyname, valname); if( ret != ERROR_SUCCESS) return FALSE; if( size <= sizeof( LOGFONT16)) { LOGFONT16 *plf16 = (LOGFONT16*) &lfw; plf->lfHeight = plf16->lfHeight; plf->lfWidth = plf16->lfWidth; plf->lfEscapement = plf16->lfEscapement; plf->lfOrientation = plf16->lfOrientation; plf->lfWeight = plf16->lfWeight; plf->lfItalic = plf16->lfItalic; plf->lfUnderline = plf16->lfUnderline; plf->lfStrikeOut = plf16->lfStrikeOut; plf->lfCharSet = plf16->lfCharSet; plf->lfOutPrecision = plf16->lfOutPrecision; plf->lfClipPrecision = plf16->lfClipPrecision; plf->lfQuality = plf16->lfQuality; plf->lfPitchAndFamily = plf16->lfPitchAndFamily; memcpy( plf->lfFaceName, plf16->lfFaceName, LF_FACESIZE ); } else if( size <= sizeof( LOGFONTA)) { plf = (LOGFONTA*) &lfw; } else { plf->lfHeight = lfw.lfHeight; plf->lfWidth = lfw.lfWidth; plf->lfEscapement = lfw.lfEscapement; plf->lfOrientation = lfw.lfOrientation; plf->lfWeight = lfw.lfWeight; plf->lfItalic = lfw.lfItalic; plf->lfUnderline = lfw.lfUnderline; plf->lfStrikeOut = lfw.lfStrikeOut; plf->lfCharSet = lfw.lfCharSet; plf->lfOutPrecision = lfw.lfOutPrecision; plf->lfClipPrecision = lfw.lfClipPrecision; plf->lfQuality = lfw.lfQuality; plf->lfPitchAndFamily = lfw.lfPitchAndFamily; WideCharToMultiByte( CP_ACP, 0, lfw.lfFaceName, -1, plf->lfFaceName, LF_FACESIZE, NULL, NULL); } return TRUE; } static void test_SPI_SETBEEP( void ) /* 2 */ { BOOL rc; BOOL old_b; BOOL b; BOOL curr_val; trace("testing SPI_{GET,SET}BEEP\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETBEEP, 0, &old_b, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}BEEP")) return; curr_val = TRUE; rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (!test_error_msg(rc,"SPI_SETBEEP")) return; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETBEEP, 0 ); test_reg_key( SPI_SETBEEP_REGKEY, SPI_SETBEEP_VALNAME, curr_val ? "Yes" : "No" ); rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" ); rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 ); if (rc || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) { ok(rc, "SystemParametersInfoW: rc=%d err=%d\n", rc, GetLastError()); eq( b, curr_val, "SystemParametersInfoW", "%d" ); } /* is a message sent for the second change? */ rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETBEEP, 0 ); curr_val = FALSE; rc=SystemParametersInfoW( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (rc == FALSE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) rc=SystemParametersInfoA( SPI_SETBEEP, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); ok(rc, "SystemParametersInfo: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETBEEP, 0 ); test_reg_key( SPI_SETBEEP_REGKEY, SPI_SETBEEP_VALNAME, curr_val ? "Yes" : "No" ); rc=SystemParametersInfoA( SPI_GETBEEP, 0, &b, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( b, curr_val, "SPI_{GET,SET}BEEP", "%d" ); rc=SystemParametersInfoW( SPI_GETBEEP, 0, &b, 0 ); if (rc || GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) { ok(rc, "SystemParametersInfoW: rc=%d err=%d\n", rc, GetLastError()); eq( b, curr_val, "SystemParametersInfoW", "%d" ); } ok( MessageBeep( MB_OK ), "Return value of MessageBeep when sound is disabled\n" ); rc=SystemParametersInfoA( SPI_SETBEEP, old_b, 0, SPIF_UPDATEINIFILE ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); } static const char *setmouse_valuenames[3] = { SPI_SETMOUSE_VALNAME1, SPI_SETMOUSE_VALNAME2, SPI_SETMOUSE_VALNAME3 }; /* * Runs check for one setting of spi_setmouse. */ static BOOL run_spi_setmouse_test( int curr_val[], POINT *req_change, POINT *proj_change, int nchange ) { BOOL rc; INT mi[3]; static int aw_turn = 0; static BOOL w_implemented = TRUE; char buf[20]; int i; aw_turn++; rc = FALSE; if ((aw_turn % 2!=0) && (w_implemented)) { /* call unicode on odd (non even) calls */ SetLastError(0xdeadbeef); rc=SystemParametersInfoW( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (rc == FALSE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) { w_implemented = FALSE; trace("SystemParametersInfoW not supported on this platform\n"); } } if ((aw_turn % 2==0) || (!w_implemented)) { /* call ascii version on even calls or if unicode is not available */ rc=SystemParametersInfoA( SPI_SETMOUSE, 0, curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); } if (!test_error_msg(rc,"SPI_SETMOUSE")) return FALSE; ok(rc, "SystemParametersInfo: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETMOUSE, 0 ); for (i = 0; i < 3; i++) { sprintf( buf, "%d", curr_val[i] ); test_reg_key( SPI_SETMOUSE_REGKEY, setmouse_valuenames[i], buf ); } rc=SystemParametersInfoA( SPI_GETMOUSE, 0, mi, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); for (i = 0; i < 3; i++) { ok(mi[i] == curr_val[i], "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]); } if (w_implemented) { rc=SystemParametersInfoW( SPI_GETMOUSE, 0, mi, 0 ); ok(rc, "SystemParametersInfoW: rc=%d err=%d\n", rc, GetLastError()); for (i = 0; i < 3; i++) { ok(mi[i] == curr_val[i], "incorrect value for %d: %d != %d\n", i, mi[i], curr_val[i]); } } if (0) { /* FIXME: this always fails for me - AJ */ for (i = 0; i < nchange; i++) { POINT mv; mouse_event( MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 0, 0, 0, 0 ); mouse_event( MOUSEEVENTF_MOVE, req_change[i].x, req_change[i].y, 0, 0 ); GetCursorPos( &mv ); ok( proj_change[i].x == mv.x, "Projected dx and real dx comparison. May fail under high load.\n" ); ok( proj_change[i].y == mv.y, "Projected dy equals real dy. May fail under high load.\n" ); } } return TRUE; } static void test_SPI_SETMOUSE( void ) /* 4 */ { BOOL rc; INT old_mi[3]; /* win nt default values - 6, 10, 1 */ INT curr_val[3] = {6, 10, 1}; /* requested and projected mouse movements */ POINT req_change[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} }; POINT proj_change1[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} }; POINT proj_change2[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {44, 20}, {400, 400} }; POINT proj_change3[] = { {6, 6}, {14, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} }; POINT proj_change4[] = { {6, 6}, { 7, 6}, { 8, 6}, {10, 10}, {11, 10}, {100, 100} }; POINT proj_change5[] = { {6, 6}, { 7, 6}, {16, 6}, {20, 20}, {22, 20}, {200, 200} }; POINT proj_change6[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; POINT proj_change7[] = { {6, 6}, {14, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; POINT proj_change8[] = { {6, 6}, {28, 6}, {32, 6}, {40, 40}, {44, 40}, {400, 400} }; int nchange = sizeof( req_change ) / sizeof( POINT ); trace("testing SPI_{GET,SET}MOUSE\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETMOUSE, 0, old_mi, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}MOUSE")) return; if (!run_spi_setmouse_test( curr_val, req_change, proj_change1, nchange )) return; /* acceleration change */ curr_val[2] = 2; run_spi_setmouse_test( curr_val, req_change, proj_change2, nchange ); /* acceleration change */ curr_val[2] = 3; run_spi_setmouse_test( curr_val, req_change, proj_change3, nchange ); /* acceleration change */ curr_val[2] = 0; run_spi_setmouse_test( curr_val, req_change, proj_change4, nchange ); /* threshold change */ curr_val[2] = 1; curr_val[0] = 7; run_spi_setmouse_test( curr_val, req_change, proj_change5, nchange ); /* threshold change */ curr_val[2] = 2; curr_val[0] = 6; curr_val[1] = 6; run_spi_setmouse_test( curr_val, req_change, proj_change6, nchange ); /* threshold change */ curr_val[1] = 7; run_spi_setmouse_test( curr_val, req_change, proj_change7, nchange ); /* threshold change */ curr_val[1] = 5; run_spi_setmouse_test( curr_val, req_change, proj_change8, nchange ); rc=SystemParametersInfoA( SPI_SETMOUSE, 0, old_mi, SPIF_UPDATEINIFILE ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); } static BOOL test_setborder(UINT curr_val, int usesetborder, int dpi) { BOOL rc; UINT border, regval; INT frame; NONCLIENTMETRICSA ncm; ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth); rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); if( usesetborder) { rc=SystemParametersInfoA( SPI_SETBORDER, curr_val, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (!test_error_msg(rc,"SPI_SETBORDER")) return FALSE; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETBORDER, 1 ); } else { /* set non client metrics */ ncm.iBorderWidth = curr_val; rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncm, SPIF_UPDATEINIFILE| SPIF_SENDCHANGE); if (!test_error_msg(rc,"SPI_SETNONCLIENTMETRICS")) return FALSE; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); } if( curr_val) { /* skip if 0, some windows versions return 0 others 1 */ regval = metricfromreg( SPI_SETBORDER_REGKEY2, SPI_SETBORDER_VALNAME, dpi); if( regval != curr_val) regval = metricfromreg( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, dpi); ok( regval==curr_val, "wrong value in registry %d, expected %d\n", regval, curr_val); } /* minimum border width is 1 */ if (curr_val == 0) curr_val = 1; /* should be the same as the non client metrics */ rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( (UINT)ncm.iBorderWidth, curr_val, "NonClientMetric.iBorderWidth", "%d"); /* and from SPI_GETBORDER */ rc=SystemParametersInfoA( SPI_GETBORDER, 0, &border, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( border, curr_val, "SPI_{GET,SET}BORDER", "%d"); /* test some SystemMetrics */ frame = curr_val + GetSystemMetrics( SM_CXDLGFRAME ); eq( frame, GetSystemMetrics( SM_CXFRAME ), "SM_CXFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CYFRAME ), "SM_CYFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CXSIZEFRAME ), "SM_CXSIZEFRAME", "%d" ); eq( frame, GetSystemMetrics( SM_CYSIZEFRAME ), "SM_CYSIZEFRAME", "%d" ); return TRUE; } static void test_SPI_SETBORDER( void ) /* 6 */ { BOOL rc; UINT old_border; NONCLIENTMETRICSA ncmsave; INT CaptionWidth, PaddedBorderWidth; ncmsave.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth); rc=SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, 0, &ncmsave, 0); if( !rc) { win_skip("SPI_GETNONCLIENTMETRICS is not available\n"); return; } /* CaptionWidth from the registry may have different value of iCaptionWidth * from the non client metrics (observed on WinXP). * Fix this so we can safely restore settings with the nonclientmetrics */ CaptionWidth = metricfromreg( "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi); ncmsave.iCaptionWidth = CaptionWidth; /* These tests hang when XFree86 4.0 for Windows is running (tested on * WinNT, SP2, Cygwin/XFree 4.1.0. Skip the test when XFree86 is * running. */ if (FindWindowA( NULL, "Cygwin/XFree86" )) return; trace("testing SPI_{GET,SET}BORDER\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETBORDER, 0, &old_border, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}BORDER")) return; /* FIXME: include new PaddedBorderWidth parameter */ PaddedBorderWidth = ncmsave.iBorderWidth - old_border; if( PaddedBorderWidth){ win_skip( "Cannot reliably restore border width yet (PaddedBorderWidth = %d)\n", PaddedBorderWidth); return; } /* This will restore sane values if the test hang previous run. */ if ( old_border == 7 || old_border == 20 ) old_border = 1; /* The SPI_SETBORDER seems to be buggy on Win9x/ME (looks like you need to * do it twice to make the intended change). So skip parts of the tests on * those platforms */ if( !iswin9x) { /* win2k3 fails if you set the same border twice, or if size is 0 */ if (!test_setborder(2, 1, dpi)) return; test_setborder(1, 1, dpi); test_setborder(3, 1, dpi); } if (!test_setborder(1, 0, dpi)) return; test_setborder(0, 0, dpi); test_setborder(3, 0, dpi); rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, 0, &ncmsave, SPIF_UPDATEINIFILE| SPIF_SENDCHANGE); test_change_message( SPI_SETNONCLIENTMETRICS, 1 ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); } static void test_SPI_SETKEYBOARDSPEED( void ) /* 10 */ { BOOL rc; UINT old_speed; const UINT vals[]={0,20,31}; unsigned int i; trace("testing SPI_{GET,SET}KEYBOARDSPEED\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETKEYBOARDSPEED, 0, &old_speed, 0 ); if (!test_error_msg(rc,"SPI_{GET,SET}KEYBOARDSPEED")) return; for (i=0;i= 8 && Ncmcur.iCaptionWidth <= 13) || Ncmcur.iCaptionWidth == Ncmstart.iCaptionWidth, /* with windows XP theme, the value never changes */ "CaptionWidth: %d expected from [8, 13] or %d\n", Ncmcur.iCaptionWidth, Ncmstart.iCaptionWidth); ok( Ncmcur.iScrollWidth == 8, "ScrollWidth: %d expected 8\n", Ncmcur.iScrollWidth); ok( Ncmcur.iScrollHeight == 8, "ScrollHeight: %d expected 8\n", Ncmcur.iScrollHeight); /* test the system metrics with these settings */ test_GetSystemMetrics(); /* restore */ rc=SystemParametersInfoA( SPI_SETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICSA), &Ncmorig, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); test_change_message( SPI_SETNONCLIENTMETRICS, 0 ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); /* test the system metrics with these settings */ test_GetSystemMetrics(); } static void test_SPI_SETMINIMIZEDMETRICS( void ) /* 44 */ { BOOL rc; INT regval; MINIMIZEDMETRICS lpMm_orig; MINIMIZEDMETRICS lpMm_new; MINIMIZEDMETRICS lpMm_cur; lpMm_orig.cbSize = sizeof(MINIMIZEDMETRICS); lpMm_new.cbSize = sizeof(MINIMIZEDMETRICS); lpMm_cur.cbSize = sizeof(MINIMIZEDMETRICS); trace("testing SPI_{GET,SET}MINIMIZEDMETRICS\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_orig, FALSE ); if (!test_error_msg(rc,"SPI_{GET,SET}MINIMIZEDMETRICS")) return; /* Test registry. Note that it is perfectly valid for some fields to * not be set. */ regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); ok( regval == -1 || regval == lpMm_orig.iWidth, "wrong value in registry %d, expected %d\n", regval, lpMm_orig.iWidth); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); ok( regval == -1 || regval == lpMm_orig.iHorzGap, "wrong value in registry %d, expected %d\n", regval, lpMm_orig.iHorzGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); ok( regval == -1 || regval == lpMm_orig.iVertGap, "wrong value in registry %d, expected %d\n", regval, lpMm_orig.iVertGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); ok( regval == -1 || regval == lpMm_orig.iArrange, "wrong value in registry %d, expected %d\n", regval, lpMm_orig.iArrange); /* set some new values */ lpMm_cur.iWidth = 180; lpMm_cur.iHorzGap = 1; lpMm_cur.iVertGap = 1; lpMm_cur.iArrange = 5; rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_cur, SPIF_UPDATEINIFILE ); if (!test_error_msg(rc,"SPI_SETMINIMIZEDMETRICS")) return; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); /* read them back */ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); /* and compare */ eq( lpMm_new.iWidth, lpMm_cur.iWidth, "iWidth", "%d" ); eq( lpMm_new.iHorzGap, lpMm_cur.iHorzGap, "iHorzGap", "%d" ); eq( lpMm_new.iVertGap, lpMm_cur.iVertGap, "iVertGap", "%d" ); eq( lpMm_new.iArrange, lpMm_cur.iArrange, "iArrange", "%d" ); /* test registry */ regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iWidth); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iHorzGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iVertGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iArrange); /* test some system metrics */ eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6, lpMm_new.iWidth, "iWidth", "%d" ); eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ), lpMm_new.iHorzGap, "iHorzGap", "%d" ); eq( GetSystemMetrics( SM_CYMINSPACING ) - GetSystemMetrics( SM_CYMINIMIZED ), lpMm_new.iVertGap, "iVertGap", "%d" ); eq( GetSystemMetrics( SM_ARRANGE ), lpMm_new.iArrange, "iArrange", "%d" ); /* now some really invalid settings */ lpMm_cur.iWidth = -1; lpMm_cur.iHorzGap = -1; lpMm_cur.iVertGap = -1; lpMm_cur.iArrange = - 1; rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_cur, SPIF_UPDATEINIFILE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); /* read back */ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); /* the width and H/V gaps have minimum 0, arrange is and'd with 0xf */ eq( lpMm_new.iWidth, 0, "iWidth", "%d" ); eq( lpMm_new.iHorzGap, 0, "iHorzGap", "%d" ); eq( lpMm_new.iVertGap, 0, "iVertGap", "%d" ); eq( lpMm_new.iArrange, 0xf & lpMm_cur.iArrange, "iArrange", "%d" ); /* test registry */ if (0) { /* FIXME: cannot understand the results of this (11, 11, 11, 0) */ regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINWIDTH_VALNAME, dpi); ok( regval == lpMm_new.iWidth, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iWidth); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINHORZGAP_VALNAME, dpi); ok( regval == lpMm_new.iHorzGap, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iHorzGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINVERTGAP_VALNAME, dpi); ok( regval == lpMm_new.iVertGap, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iVertGap); regval = metricfromreg( SPI_MINIMIZEDMETRICS_REGKEY, SPI_MINARRANGE_VALNAME, dpi); ok( regval == lpMm_new.iArrange, "wrong value in registry %d, expected %d\n", regval, lpMm_new.iArrange); } /* test some system metrics */ eq( GetSystemMetrics( SM_CXMINIMIZED ) - 6, lpMm_new.iWidth, "iWidth", "%d" ); eq( GetSystemMetrics( SM_CXMINSPACING ) - GetSystemMetrics( SM_CXMINIMIZED ), lpMm_new.iHorzGap, "iHorzGap", "%d" ); eq( GetSystemMetrics( SM_CYMINSPACING ) - GetSystemMetrics( SM_CYMINIMIZED ), lpMm_new.iVertGap, "iVertGap", "%d" ); eq( GetSystemMetrics( SM_ARRANGE ), lpMm_new.iArrange, "iArrange", "%d" ); /* restore */ rc=SystemParametersInfoA( SPI_SETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_orig, SPIF_UPDATEINIFILE ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); /* check that */ rc=SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, sizeof(MINIMIZEDMETRICS), &lpMm_new, FALSE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( lpMm_new.iWidth, lpMm_orig.iWidth, "iWidth", "%d" ); eq( lpMm_new.iHorzGap, lpMm_orig.iHorzGap, "iHorzGap", "%d" ); eq( lpMm_new.iVertGap, lpMm_orig.iVertGap, "iVertGap", "%d" ); eq( lpMm_new.iArrange, lpMm_orig.iArrange, "iArrange", "%d" ); } static void test_SPI_SETICONMETRICS( void ) /* 46 */ { BOOL rc, wrap; INT spacing; ICONMETRICSA im_orig; ICONMETRICSA im_new; ICONMETRICSA im_cur; INT regval; im_orig.cbSize = sizeof(ICONMETRICSA); im_new.cbSize = sizeof(ICONMETRICSA); im_cur.cbSize = sizeof(ICONMETRICSA); trace("testing SPI_{GET,SET}ICONMETRICS\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_orig, FALSE ); if (!test_error_msg(rc,"SPI_{GET,SET}ICONMETRICS")) return; /* check some registry values */ regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); ok( regval==im_orig.iHorzSpacing || broken(regval == -1), /* nt4 */ "wrong value in registry %d, expected %d\n", regval, im_orig.iHorzSpacing); regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); ok( regval==im_orig.iVertSpacing || broken(regval == -1), /* nt4 */ "wrong value in registry %d, expected %d\n", regval, im_orig.iVertSpacing); regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi); if( regval != im_orig.iTitleWrap) regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi); ok( regval==im_orig.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_orig.iTitleWrap); /* change everything without creating something invalid ( Win9x would ignore * an invalid font for instance) */ im_cur = im_orig; im_cur.iHorzSpacing += 10; im_cur.iVertSpacing += 6; im_cur.iTitleWrap = !im_cur.iTitleWrap; im_cur.lfFont.lfHeight += 1; im_cur.lfFont.lfWidth += 2; im_cur.lfFont.lfEscapement = 1; im_cur.lfFont.lfWeight = im_cur.lfFont.lfWeight > 100 ? 1 : 314; im_cur.lfFont.lfItalic = !im_cur.lfFont.lfItalic; im_cur.lfFont.lfStrikeOut = !im_cur.lfFont.lfStrikeOut; im_cur.lfFont.lfUnderline = !im_cur.lfFont.lfUnderline; im_cur.lfFont.lfCharSet = im_cur.lfFont.lfCharSet ? 0 : 1; im_cur.lfFont.lfOutPrecision = im_cur.lfFont.lfOutPrecision == OUT_DEFAULT_PRECIS ? OUT_TT_PRECIS : OUT_DEFAULT_PRECIS; im_cur.lfFont.lfClipPrecision ^= CLIP_LH_ANGLES; im_cur.lfFont.lfPitchAndFamily = im_cur.lfFont.lfPitchAndFamily ? 0 : 1; im_cur.lfFont.lfQuality = im_cur.lfFont.lfQuality == DEFAULT_QUALITY ? DRAFT_QUALITY : DEFAULT_QUALITY; if( strcmp( im_cur.lfFont.lfFaceName, "MS Serif")) strcpy( im_cur.lfFont.lfFaceName, "MS Serif"); else strcpy( im_cur.lfFont.lfFaceName, "MS Sans Serif"); rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_cur, SPIF_UPDATEINIFILE ); if (!test_error_msg(rc,"SPI_SETICONMETRICS")) return; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); /* test GET <-> SETICONMETRICS */ eq( im_new.iHorzSpacing, im_cur.iHorzSpacing, "iHorzSpacing", "%d" ); eq( im_new.iVertSpacing, im_cur.iVertSpacing, "iVertSpacing", "%d" ); eq( im_new.iTitleWrap, im_cur.iTitleWrap, "iTitleWrap", "%d" ); eq( im_new.lfFont.lfHeight, im_cur.lfFont.lfHeight, "lfHeight", "%d" ); eq( im_new.lfFont.lfWidth, im_cur.lfFont.lfWidth, "lfWidth", "%d" ); eq( im_new.lfFont.lfEscapement, im_cur.lfFont.lfEscapement, "lfEscapement", "%d" ); eq( im_new.lfFont.lfWeight, im_cur.lfFont.lfWeight, "lfWeight", "%d" ); eq( im_new.lfFont.lfItalic, im_cur.lfFont.lfItalic, "lfItalic", "%d" ); eq( im_new.lfFont.lfStrikeOut, im_cur.lfFont.lfStrikeOut, "lfStrikeOut", "%d" ); eq( im_new.lfFont.lfUnderline, im_cur.lfFont.lfUnderline, "lfUnderline", "%d" ); eq( im_new.lfFont.lfCharSet, im_cur.lfFont.lfCharSet, "lfCharSet", "%d" ); eq( im_new.lfFont.lfOutPrecision, im_cur.lfFont.lfOutPrecision, "lfOutPrecision", "%d" ); eq( im_new.lfFont.lfClipPrecision, im_cur.lfFont.lfClipPrecision, "lfClipPrecision", "%d" ); eq( im_new.lfFont.lfPitchAndFamily, im_cur.lfFont.lfPitchAndFamily, "lfPitchAndFamily", "%d" ); eq( im_new.lfFont.lfQuality, im_cur.lfFont.lfQuality, "lfQuality", "%d" ); ok( !strcmp( im_new.lfFont.lfFaceName, im_cur.lfFont.lfFaceName), "wrong facename \"%s\", should be \"%s\"\n", im_new.lfFont.lfFaceName, im_cur.lfFont.lfFaceName); /* test some system metrics */ eq( GetSystemMetrics( SM_CXICONSPACING ), im_new.iHorzSpacing, "iHorzSpacing", "%d" ); eq( GetSystemMetrics( SM_CYICONSPACING ), im_new.iVertSpacing, "iVertSpacing", "%d" ); /* check some registry values */ regval = metricfromreg( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, dpi); ok( regval==im_cur.iHorzSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iHorzSpacing); regval = metricfromreg( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, dpi); ok( regval==im_cur.iVertSpacing, "wrong value in registry %d, expected %d\n", regval, im_cur.iVertSpacing); regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY2, SPI_SETICONTITLEWRAP_VALNAME, dpi); if( regval != im_cur.iTitleWrap) regval = metricfromreg( SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_VALNAME, dpi); ok( regval==im_cur.iTitleWrap, "wrong value in registry %d, expected %d\n", regval, im_cur.iTitleWrap); /* test some values from other SPI_GETxxx calls */ rc = SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &spacing, 0 ); ok( rc && spacing == im_cur.iHorzSpacing, "SystemParametersInfoA( SPI_ICONHORIZONTALSPACING...) failed or returns wrong value %d instead of %d\n", spacing, im_cur.iHorzSpacing); rc = SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &spacing, 0 ); ok( rc && spacing == im_cur.iVertSpacing, "SystemParametersInfoA( SPI_ICONVERTICALSPACING...) failed or returns wrong value %d instead of %d\n", spacing, im_cur.iVertSpacing); rc = SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0, &wrap, 0 ); ok( rc && wrap == im_cur.iTitleWrap, "SystemParametersInfoA( SPI_GETICONTITLEWRAP...) failed or returns wrong value %d instead of %d\n", wrap, im_cur.iTitleWrap); /* restore old values */ rc=SystemParametersInfoA( SPI_SETICONMETRICS, sizeof(ICONMETRICSA), &im_orig,SPIF_UPDATEINIFILE ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); rc=SystemParametersInfoA( SPI_GETICONMETRICS, sizeof(ICONMETRICSA), &im_new, FALSE ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); eq( im_new.iHorzSpacing, im_orig.iHorzSpacing, "iHorzSpacing", "%d" ); eq( im_new.iVertSpacing, im_orig.iVertSpacing, "iVertSpacing", "%d" ); eq( im_new.iTitleWrap, im_orig.iTitleWrap, "iTitleWrap", "%d" ); } static void test_SPI_SETWORKAREA( void ) /* 47 */ { BOOL rc; RECT old_area; RECT area; RECT curr_val; trace("testing SPI_{GET,SET}WORKAREA\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA(SPI_GETWORKAREA, 0, &old_area, 0); if (!test_error_msg(rc,"SPI_{GET,SET}WORKAREA")) return; /* Modify the work area only minimally as this causes the icons that * fall outside it to be moved around thus requiring the user to * reposition them manually one by one. * Changing the work area by just one pixel should make this occurrence * reasonably unlikely. */ SetRect(&curr_val, old_area.left, old_area.top, old_area.right - 1, old_area.bottom - 1); rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &curr_val, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); if (!test_error_msg(rc,"SPI_SETWORKAREA")) return; ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); if( !EqualRect( &area, &curr_val)) /* no message if rect has not changed */ test_change_message( SPI_SETWORKAREA, 0); eq( area.left, curr_val.left, "left", "%d" ); eq( area.top, curr_val.top, "top", "%d" ); /* size may be rounded */ ok( area.right >= curr_val.right - 16 && area.right < curr_val.right + 16, "right: got %d instead of %d\n", area.right, curr_val.right ); ok( area.bottom >= curr_val.bottom - 16 && area.bottom < curr_val.bottom + 16, "bottom: got %d instead of %d\n", area.bottom, curr_val.bottom ); curr_val = area; rc=SystemParametersInfoA( SPI_SETWORKAREA, 0, &old_area, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ); ok(rc, "***warning*** failed to restore the original value: rc=%d err=%d\n", rc, GetLastError()); rc=SystemParametersInfoA( SPI_GETWORKAREA, 0, &area, 0 ); ok(rc, "SystemParametersInfoA: rc=%d err=%d\n", rc, GetLastError()); if( !EqualRect( &area, &curr_val)) /* no message if rect has not changed */ test_change_message( SPI_SETWORKAREA, 0 ); eq( area.left, old_area.left, "left", "%d" ); eq( area.top, old_area.top, "top", "%d" ); /* size may be rounded */ ok( area.right >= old_area.right - 16 && area.right < old_area.right + 16, "right: got %d instead of %d\n", area.right, old_area.right ); ok( area.bottom >= old_area.bottom - 16 && area.bottom < old_area.bottom + 16, "bottom: got %d instead of %d\n", area.bottom, old_area.bottom ); } static void test_SPI_SETSHOWSOUNDS( void ) /* 57 */ { BOOL rc; BOOL old_b; const UINT vals[]={TRUE,FALSE}; unsigned int i; trace("testing SPI_{GET,SET}SHOWSOUNDS\n"); SetLastError(0xdeadbeef); rc=SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &old_b, 0 ); /* SPI_{GET,SET}SHOWSOUNDS is completely broken on Win9x */ if (!test_error_msg(rc,"SPI_{GET,SET}SHOWSOUNDS")) return; for (i=0;itmHeight = -1; if( psz) *psz = 10; if( hfont) DeleteObject( hfont); return; } GetTextMetricsA( hdc, ptm); if( psz) if( !(*psz = _GdiGetCharDimensions( hdc, ptm, NULL))) *psz = 10; SelectObject( hdc, hfontsav); DeleteObject( hfont); } static int gsm_error_ctr; #define ok_gsm( i, e)\ {\ int exp = (e);\ int act = GetSystemMetrics( (i));\ if( exp != act) gsm_error_ctr++;\ ok( !( exp != act),"GetSystemMetrics(%s): expected %d actual %d\n", #i, exp,act);\ } #define ok_gsm_2( i, e1, e2)\ {\ int exp1 = (e1);\ int exp2 = (e2);\ int act = GetSystemMetrics( (i));\ if( exp1 != act && exp2 != act) gsm_error_ctr++;\ ok( !( exp1 != act && exp2 != act), "GetSystemMetrics(%s): expected %d or %d actual %d\n", #i, exp1, exp2, act);\ } #define ok_gsm_3( i, e1, e2, e3)\ {\ int exp1 = (e1);\ int exp2 = (e2);\ int exp3 = (e3);\ int act = GetSystemMetrics( (i));\ if( exp1 != act && exp2 != act && exp3 != act) gsm_error_ctr++;\ ok( !( exp1 != act && exp2 != act && exp3 != act),"GetSystemMetrics(%s): expected %d or %d or %d actual %d\n", #i, exp1, exp2, exp3, act);\ } static INT CALLBACK enum_all_fonts_proc(const LOGFONTA *elf, const TEXTMETRICA *ntm, DWORD type, LPARAM lparam) { return lstrcmpiA(elf->lfFaceName, (const char *)lparam); } static BOOL is_font_enumerated(const char *name) { HDC hdc = CreateCompatibleDC(0); BOOL ret = FALSE; if (!EnumFontFamiliesA(hdc, NULL, enum_all_fonts_proc, (LPARAM)name)) ret = TRUE; DeleteDC(hdc); return ret; } static void test_GetSystemMetrics( void) { TEXTMETRICA tmMenuFont; UINT IconSpacing, IconVerticalSpacing; BOOL rc; HDC hdc = CreateICA( "Display", 0, 0, 0); UINT avcwCaption; INT CaptionWidthfromreg, smicon, broken_val; MINIMIZEDMETRICS minim; NONCLIENTMETRICSA ncm; SIZE screen; assert(sizeof(ncm) == 344); ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth); rc = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(rc, "SystemParametersInfoA failed\n"); ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth) - 1; rc = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(!rc, "SystemParametersInfoA should fail\n"); ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth) + 1; SetLastError(0xdeadbeef); rc = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(!rc, "SystemParametersInfoA should fail\n"); ncm.cbSize = sizeof(ncm); /* Vista added padding */ SetLastError(0xdeadbeef); rc = SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); ok(rc || broken(!rc) /* before Vista */, "SystemParametersInfoA failed\n"); minim.cbSize = sizeof( minim); ncm.cbSize = FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth); SystemParametersInfoA( SPI_GETMINIMIZEDMETRICS, 0, &minim, 0); rc = SystemParametersInfoA( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0); if( !rc) { win_skip("SPI_GETNONCLIENTMETRICS is not available\n"); return; } ok(is_font_enumerated(ncm.lfCaptionFont.lfFaceName), "font %s should be enumerated\n", ncm.lfCaptionFont.lfFaceName); ok(is_font_enumerated(ncm.lfSmCaptionFont.lfFaceName), "font %s should be enumerated\n", ncm.lfSmCaptionFont.lfFaceName); ok(is_font_enumerated(ncm.lfMenuFont.lfFaceName), "font %s should be enumerated\n", ncm.lfMenuFont.lfFaceName); ok(is_font_enumerated(ncm.lfStatusFont.lfFaceName), "font %s should be enumerated\n", ncm.lfStatusFont.lfFaceName); ok(is_font_enumerated(ncm.lfMessageFont.lfFaceName), "font %s should be enumerated\n", ncm.lfMessageFont.lfFaceName); /* CaptionWidth from the registry may have different value of iCaptionWidth * from the non client metrics (observed on WinXP) */ CaptionWidthfromreg = metricfromreg( "Control Panel\\Desktop\\WindowMetrics","CaptionWidth", dpi); get_text_metr_size( hdc, &ncm.lfMenuFont, &tmMenuFont, NULL); get_text_metr_size( hdc, &ncm.lfCaptionFont, NULL, &avcwCaption); /* FIXME: use icon metric */ if( !SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0, &IconVerticalSpacing, 0)) IconVerticalSpacing = 0; if( !SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0, &IconSpacing, 0 )) IconSpacing = 0; /* reset error counters */ gsm_error_ctr = 0; /* the tests: */ /* SM_CXSCREEN, cannot test these two */ /* SM_CYSCREEN */ ok_gsm( SM_CXVSCROLL, ncm.iScrollWidth); ok_gsm( SM_CYHSCROLL, ncm.iScrollWidth); ok_gsm( SM_CYCAPTION, ncm.iCaptionHeight+1); ok_gsm( SM_CXBORDER, 1); ok_gsm( SM_CYBORDER, 1); ok_gsm( SM_CXDLGFRAME, 3); ok_gsm( SM_CYDLGFRAME, 3); ok_gsm( SM_CYVTHUMB, ncm.iScrollHeight); ok_gsm( SM_CXHTHUMB, ncm.iScrollHeight); /* These don't depend on the Shell Icon Size registry value */ ok_gsm( SM_CXICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) ); ok_gsm( SM_CYICON, MulDiv( 32, dpi, USER_DEFAULT_SCREEN_DPI ) ); /* SM_CXCURSOR */ /* SM_CYCURSOR */ ok_gsm( SM_CYMENU, ncm.iMenuHeight + 1); ok_gsm( SM_CXFULLSCREEN, GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME)); ok_gsm( SM_CYFULLSCREEN, GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN)); /* SM_CYKANJIWINDOW */ /* SM_MOUSEPRESENT */ ok_gsm( SM_CYVSCROLL, ncm.iScrollHeight); ok_gsm( SM_CXHSCROLL, ncm.iScrollHeight); /* SM_DEBUG */ /* SM_SWAPBUTTON */ /* SM_RESERVED1 */ /* SM_RESERVED2 */ /* SM_RESERVED3 */ /* SM_RESERVED4 */ ok_gsm( SM_CXMIN, 3 * max( CaptionWidthfromreg >= 0 ? CaptionWidthfromreg : ncm.iCaptionWidth, 8) + GetSystemMetrics( SM_CYSIZE) + 4 + 4 * avcwCaption + 2 * GetSystemMetrics( SM_CXFRAME)); ok_gsm( SM_CYMIN, GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME)); ok_gsm_2( SM_CXSIZE, ncm.iCaptionWidth, /* classic/standard windows style */ GetSystemMetrics( SM_CYCAPTION) - 1 /* WinXP style */ ); ok_gsm( SM_CYSIZE, ncm.iCaptionHeight); ok_gsm( SM_CXFRAME, ncm.iBorderWidth + 3); ok_gsm( SM_CYFRAME, ncm.iBorderWidth + 3); ok_gsm( SM_CXMINTRACK, GetSystemMetrics( SM_CXMIN)); ok_gsm( SM_CYMINTRACK, GetSystemMetrics( SM_CYMIN)); /* SM_CXDOUBLECLK */ /* SM_CYDOUBLECLK */ if( IconSpacing) ok_gsm( SM_CXICONSPACING, IconSpacing); if( IconVerticalSpacing) ok_gsm( SM_CYICONSPACING, IconVerticalSpacing); /* SM_MENUDROPALIGNMENT */ /* SM_PENWINDOWS */ /* SM_DBCSENABLED */ /* SM_CMOUSEBUTTONS */ /* SM_SECURE */ ok_gsm( SM_CXEDGE, 2); ok_gsm( SM_CYEDGE, 2); /* sign-extension for iHorzGap/iVertGap is broken on Win9x */ ok_gsm( SM_CXMINSPACING, GetSystemMetrics( SM_CXMINIMIZED) + (short)minim.iHorzGap ); ok_gsm( SM_CYMINSPACING, GetSystemMetrics( SM_CYMINIMIZED) + (short)minim.iVertGap ); smicon = MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI ); if (!pIsProcessDPIAware || pIsProcessDPIAware()) smicon = max( min( smicon, CaptionWidthfromreg - 2), 4 ) & ~1; todo_wine_if( real_dpi == dpi && smicon != (MulDiv( 16, dpi, USER_DEFAULT_SCREEN_DPI) & ~1) ) { broken_val = (min( ncm.iCaptionHeight, CaptionWidthfromreg ) - 2) & ~1; broken_val = min( broken_val, 20 ); if (smicon == 4) { ok_gsm_2( SM_CXSMICON, smicon, 6 ); ok_gsm_2( SM_CYSMICON, smicon, 6 ); } else if (smicon < broken_val) { ok_gsm_2( SM_CXSMICON, smicon, broken_val ); ok_gsm_2( SM_CYSMICON, smicon, broken_val ); } else { ok_gsm( SM_CXSMICON, smicon ); ok_gsm( SM_CYSMICON, smicon ); } } ok_gsm( SM_CYSMCAPTION, ncm.iSmCaptionHeight + 1); ok_gsm_3( SM_CXSMSIZE, ncm.iSmCaptionWidth, /* classic/standard windows style */ GetSystemMetrics( SM_CYSMCAPTION) - 1, /* WinXP style */ smcxsmsize /* winXP seems to cache this value: setnonclientmetric does not change it */ ); ok_gsm( SM_CYSMSIZE, GetSystemMetrics( SM_CYSMCAPTION) - 1); ok_gsm( SM_CXMENUSIZE, ncm.iMenuWidth); ok_gsm( SM_CYMENUSIZE, ncm.iMenuHeight); /* SM_ARRANGE */ ok_gsm( SM_CXMINIMIZED, minim.iWidth + 6); ok_gsm( SM_CYMINIMIZED, GetSystemMetrics( SM_CYCAPTION) + 5); screen.cx = GetSystemMetrics( SM_CXVIRTUALSCREEN ); screen.cy = GetSystemMetrics( SM_CYVIRTUALSCREEN ); if (!screen.cx || !screen.cy) /* not supported on NT4 */ { screen.cx = GetSystemMetrics( SM_CXSCREEN ); screen.cy = GetSystemMetrics( SM_CYSCREEN ); } ok_gsm_3( SM_CXMAXTRACK, screen.cx + 4 + 2 * GetSystemMetrics(SM_CXFRAME), screen.cx - 4 + 2 * GetSystemMetrics(SM_CXFRAME), /* Vista */ screen.cx + 2 * GetSystemMetrics(SM_CXFRAME)); /* Win8 */ ok_gsm_3( SM_CYMAXTRACK, screen.cy + 4 + 2 * GetSystemMetrics(SM_CYFRAME), screen.cy - 4 + 2 * GetSystemMetrics(SM_CYFRAME), /* Vista */ screen.cy + 2 * GetSystemMetrics(SM_CYFRAME)); /* Win8 */ /* the next two cannot really be tested as they depend on (application) * toolbars */ /* SM_CXMAXIMIZED */ /* SM_CYMAXIMIZED */ /* SM_NETWORK */ /* */ /* */ /* */ /* SM_CLEANBOOT */ /* SM_CXDRAG */ /* SM_CYDRAG */ /* SM_SHOWSOUNDS */ ok_gsm( SM_CXMENUCHECK, ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1); ok_gsm( SM_CYMENUCHECK, ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading+1)/2)*2-1); /* SM_SLOWMACHINE */ /* SM_MIDEASTENABLED */ /* SM_MOUSEWHEELPRESENT */ /* SM_XVIRTUALSCREEN */ /* SM_YVIRTUALSCREEN */ /* SM_CXVIRTUALSCREEN */ /* SM_CYVIRTUALSCREEN */ /* SM_CMONITORS */ /* SM_SAMEDISPLAYFORMAT */ /* SM_IMMENABLED */ /* SM_CXFOCUSBORDER */ /* SM_CYFOCUSBORDER */ /* SM_TABLETPC */ /* SM_MEDIACENTER */ /* SM_CMETRICS */ /* end of tests */ if( gsm_error_ctr ) { /* if any errors where found */ trace( "BorderWidth %d CaptionWidth %d CaptionHeight %d IconSpacing %d IconVerticalSpacing %d\n", ncm.iBorderWidth, ncm.iCaptionWidth, ncm.iCaptionHeight, IconSpacing, IconVerticalSpacing); trace( "MenuHeight %d MenuWidth %d ScrollHeight %d ScrollWidth %d SmCaptionHeight %d SmCaptionWidth %d\n", ncm.iMenuHeight, ncm.iMenuWidth, ncm.iScrollHeight, ncm.iScrollWidth, ncm.iSmCaptionHeight, ncm.iSmCaptionWidth); trace( "Captionfontchar width %d MenuFont %d,%d CaptionWidth from registry: %d screen %d,%d\n", avcwCaption, tmMenuFont.tmHeight, tmMenuFont.tmExternalLeading, CaptionWidthfromreg, screen.cx, screen.cy); } ReleaseDC( 0, hdc); } static void test_EnumDisplaySettings(void) { DEVMODEA devmode; DWORD val; HDC hdc; DWORD num; memset(&devmode, 0, sizeof(devmode)); /* Win95 doesn't handle ENUM_CURRENT_SETTINGS correctly */ EnumDisplaySettingsA(NULL, ENUM_CURRENT_SETTINGS, &devmode); hdc = GetDC(0); val = GetDeviceCaps(hdc, BITSPIXEL); ok(devmode.dmBitsPerPel == val || broken(devmode.dmDeviceName[0] == 0), /* Win95 */ "GetDeviceCaps(BITSPIXEL) returned %d, EnumDisplaySettings returned %d\n", val, devmode.dmBitsPerPel); val = GetDeviceCaps(hdc, NUMCOLORS); if(devmode.dmBitsPerPel <= 8) { ok(val == 256, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode.dmBitsPerPel, val); } else { ok(val == -1, "Screen bpp is %d, NUMCOLORS returned %d\n", devmode.dmBitsPerPel, val); } ReleaseDC(0, hdc); num = 1; while (1) { SetLastError (0xdeadbeef); if (!EnumDisplaySettingsA(NULL, num, &devmode)) { DWORD le = GetLastError(); ok(le == ERROR_NO_MORE_FILES || le == ERROR_MOD_NOT_FOUND /* Win8 */ || le == 0xdeadbeef, /* XP, 2003 */ "Expected ERROR_NO_MORE_FILES, ERROR_MOD_NOT_FOUND or 0xdeadbeef, got %d for %d\n", le, num); break; } num++; } } static void test_GetSysColorBrush(void) { HBRUSH hbr; SetLastError(0xdeadbeef); hbr = GetSysColorBrush(-1); ok(hbr == NULL, "Expected NULL brush\n"); ok(GetLastError() == 0xdeadbeef, "Expected last error not set, got %x\n", GetLastError()); /* greater than max index */ hbr = GetSysColorBrush(COLOR_MENUBAR); if (hbr) { SetLastError(0xdeadbeef); hbr = GetSysColorBrush(COLOR_MENUBAR + 1); ok(hbr == NULL, "Expected NULL brush\n"); ok(GetLastError() == 0xdeadbeef, "Expected last error not set, got %x\n", GetLastError()); } else win_skip("COLOR_MENUBAR unsupported\n"); } static void test_dpi_aware(void) { BOOL ret; if (!pIsProcessDPIAware) { win_skip("IsProcessDPIAware not available\n"); return; } ret = pSetProcessDPIAware(); ok(ret, "got %d\n", ret); ret = pIsProcessDPIAware(); ok(ret, "got %d\n", ret); dpi = real_dpi; test_GetSystemMetrics(); } START_TEST(sysparams) { int argc; char** argv; WNDCLASSA wc; MSG msg; HANDLE hThread; DWORD dwThreadId; HANDLE hInstance, hdll; hdll = GetModuleHandleA("user32.dll"); pChangeDisplaySettingsExA = (void*)GetProcAddress(hdll, "ChangeDisplaySettingsExA"); pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware"); pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware"); hInstance = GetModuleHandleA( NULL ); hdc = GetDC(0); dpi = GetDeviceCaps( hdc, LOGPIXELSY); real_dpi = get_real_dpi(); trace("dpi %d real_dpi %d\n", dpi, real_dpi); iswin9x = GetVersion() & 0x80000000; /* This test requires interactivity, if we don't have it, give up */ if (!SystemParametersInfoA( SPI_SETBEEP, TRUE, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE ) && GetLastError()==ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION) return; argc = winetest_get_mainargs(&argv); strict=(argc >= 3 && strcmp(argv[2],"strict")==0); trace("strict=%d\n",strict); trace("testing GetSystemMetrics with your current desktop settings\n"); test_GetSystemMetrics( ); trace("testing EnumDisplaySettings vs GetDeviceCaps\n"); test_EnumDisplaySettings( ); test_GetSysColorBrush( ); change_counter = 0; change_last_param = 0; wc.lpszClassName = "SysParamsTestClass"; wc.lpfnWndProc = SysParamsTestWndProc; wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW; wc.hInstance = hInstance; wc.hIcon = LoadIconA( 0, (LPCSTR)IDI_APPLICATION ); wc.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW ); wc.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 ); wc.lpszMenuName = 0; wc.cbClsExtra = 0; wc.cbWndExtra = 0; RegisterClassA( &wc ); ghTestWnd = CreateWindowA( "SysParamsTestClass", "Test System Parameters Application", WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, 0, 0, hInstance, NULL ); hThread = CreateThread( NULL, 0, SysParamsThreadFunc, 0, 0, &dwThreadId ); assert( hThread ); CloseHandle( hThread ); while( GetMessageA( &msg, 0, 0, 0 )) { TranslateMessage( &msg ); DispatchMessageA( &msg ); } ReleaseDC( 0, hdc); test_dpi_aware(); }