Hi all, SystemParametersInfoA and thus also GetSystemMetrics didn't deliver properly calculated metrics values in the case of at least (!) SPI_GETBORDER (SM_CXFRAME, SM_CYFRAME), SPI_ICONHORIZONTALSPACING (SM_CXICONSPACING) and SPI_ICONVERTICALSPACING (SM_CYICONSPACING). (immediately let me know if you find that I happened to miss any!) It simply failed to convert a possible Twips value in the registry of e.g. -1125 to the pixels value of 75. And once I mention values of -1125 and 75 in the same sentence, you immediately know that this spells despair and chaos! And chaotic it was indeed... When minimizing Win98 notepad.exe in Desktop mode, the icon got placed so far to the bottom that it wasn't even visible on the Desktop any more. This bugfix probably fixes several other programs dealing with these metrics values, too... The work on this has been triggered by a similar bug on #1272 and the discussion resulting from it, BTW. Andreas Mohr Index: windows/sysmetrics.c =================================================================== RCS file: /home/wine/wine/windows/sysmetrics.c,v retrieving revision 1.33 diff -u -r1.33 sysmetrics.c --- windows/sysmetrics.c 3 Dec 2002 23:34:52 -0000 1.33 +++ windows/sysmetrics.c 10 Feb 2003 23:26:25 -0000 @@ -43,7 +43,7 @@ * MSDN Library - April 2001 -> Resource Kits -> * Windows 2000 Resource Kit Reference -> * Technical Reference to the Windows 2000 Registry -> - * HKEY_CURRENT_USE -> Control Panel -> Desktop -> WindowMetrics + * HKEY_CURRENT_USER -> Control Panel -> Desktop -> WindowMetrics * * This is written as a function to prevent repeated evaluation of the * argument. Index: windows/sysparams.c =================================================================== RCS file: /home/wine/wine/windows/sysparams.c,v retrieving revision 1.48 diff -u -r1.48 sysparams.c --- windows/sysparams.c 20 Jan 2003 23:25:14 -0000 1.48 +++ windows/sysparams.c 10 Feb 2003 23:26:26 -0000 @@ -510,6 +510,14 @@ } } +/* copied from GetSystemMetrics()'s RegistryTwips2Pixels() */ +inline static int SYSPARAMS_Twips2Pixels(int x) +{ + if (x < 0) + x = (-x+7)/15; + return x; +} + /*********************************************************************** * SystemParametersInfoA (USER32.@) * @@ -531,6 +539,8 @@ * registry branch if saving is requested. Otherwise it is stored * in temporary branch * + * Some SPI values can also be stored as Twips values in the registry, + * don't forget the conversion! */ BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni ) @@ -638,8 +648,8 @@ if (SYSPARAMS_Load( SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME, buf )) { - int i = atoi( buf ); - if (i > 0) border = i; + /* don't forget to also convert Twips to Pixels!! */ + border = SYSPARAMS_Twips2Pixels( atoi(buf) ); } spi_loaded[spi_idx] = TRUE; if (TWEAK_WineLook > WIN31_LOOK) @@ -723,11 +733,14 @@ if (!spi_loaded[spi_idx]) { char buf[10]; + int val; if (SYSPARAMS_Load( SPI_ICONHORIZONTALSPACING_REGKEY, SPI_ICONHORIZONTALSPACING_VALNAME, buf )) { - SYSMETRICS_Set( SM_CXICONSPACING, atoi( buf ) ); + /* don't forget to also convert Twips to Pixels!! */ + val = SYSPARAMS_Twips2Pixels( atoi(buf) ); + SYSMETRICS_Set( SM_CXICONSPACING, val ); } spi_loaded[spi_idx] = TRUE; } @@ -904,11 +917,14 @@ if (!spi_loaded[spi_idx]) { char buf[10]; + int val; if (SYSPARAMS_Load( SPI_ICONVERTICALSPACING_REGKEY, SPI_ICONVERTICALSPACING_VALNAME, buf )) { - SYSMETRICS_Set( SM_CYICONSPACING, atoi( buf ) ); + /* don't forget to also convert Twips to Pixels!! */ + val = SYSPARAMS_Twips2Pixels( atoi(buf) ); + SYSMETRICS_Set( SM_CYICONSPACING, val ); } spi_loaded[spi_idx] = TRUE; } -- Andreas Mohr Stauferstr. 6, D-71272 Renningen, Germany