user32: Added stub for UpdateLayeredWindow.
[wine] / dlls / user / sysparams.c
1 /*
2  * System parameters functions
3  *
4  * Copyright 1994 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <assert.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winnls.h"
31 #include "wingdi.h"
32 #include "winreg.h"
33 #include "wine/winuser16.h"
34 #include "winerror.h"
35
36 #include "controls.h"
37 #include "user_private.h"
38 #include "wine/unicode.h"
39 #include "wine/debug.h"
40
41 WINE_DEFAULT_DEBUG_CHANNEL(system);
42
43 /* System parameter indexes */
44 enum spi_index
45 {
46     SPI_SETBEEP_IDX,
47     SPI_SETMOUSE_IDX,
48     SPI_SETBORDER_IDX,
49     SPI_SETKEYBOARDSPEED_IDX,
50     SPI_ICONHORIZONTALSPACING_IDX,
51     SPI_SETSCREENSAVETIMEOUT_IDX,
52     SPI_SETGRIDGRANULARITY_IDX,
53     SPI_SETKEYBOARDDELAY_IDX,
54     SPI_ICONVERTICALSPACING_IDX,
55     SPI_SETICONTITLEWRAP_IDX,
56     SPI_SETMENUDROPALIGNMENT_IDX,
57     SPI_SETDOUBLECLKWIDTH_IDX,
58     SPI_SETDOUBLECLKHEIGHT_IDX,
59     SPI_SETDOUBLECLICKTIME_IDX,
60     SPI_SETMOUSEBUTTONSWAP_IDX,
61     SPI_SETDRAGFULLWINDOWS_IDX,
62     SPI_SETWORKAREA_IDX,
63     SPI_SETSHOWSOUNDS_IDX,
64     SPI_SETKEYBOARDPREF_IDX,
65     SPI_SETSCREENREADER_IDX,
66     SPI_SETSCREENSAVERRUNNING_IDX,
67     SPI_SETFONTSMOOTHING_IDX,
68     SPI_SETLISTBOXSMOOTHSCROLLING_IDX,
69     SPI_SETMOUSEHOVERWIDTH_IDX,
70     SPI_SETMOUSEHOVERHEIGHT_IDX,
71     SPI_SETMOUSEHOVERTIME_IDX,
72     SPI_SETMOUSESCROLLLINES_IDX,
73     SPI_SETMENUSHOWDELAY_IDX,
74     SPI_SETICONTITLELOGFONT_IDX,
75     SPI_SETLOWPOWERACTIVE_IDX,
76     SPI_SETPOWEROFFACTIVE_IDX,
77     SPI_USERPREFERENCEMASK_IDX,
78     SPI_NONCLIENTMETRICS_IDX,
79     SPI_MINIMIZEDMETRICS_IDX,
80     SPI_INDEX_COUNT
81 };
82
83 static const char * const DefSysColors[] =
84 {
85     "Scrollbar", "192 192 192",              /* COLOR_SCROLLBAR */
86     "Background", "0 128 128",               /* COLOR_BACKGROUND */
87     "ActiveTitle", "0 0 128",                /* COLOR_ACTIVECAPTION */
88     "InactiveTitle", "128 128 128",          /* COLOR_INACTIVECAPTION */
89     "Menu", "192 192 192",                   /* COLOR_MENU */
90     "Window", "255 255 255",                 /* COLOR_WINDOW */
91     "WindowFrame", "0 0 0",                  /* COLOR_WINDOWFRAME */
92     "MenuText", "0 0 0",                     /* COLOR_MENUTEXT */
93     "WindowText", "0 0 0",                   /* COLOR_WINDOWTEXT */
94     "TitleText", "255 255 255",              /* COLOR_CAPTIONTEXT */
95     "ActiveBorder", "192 192 192",           /* COLOR_ACTIVEBORDER */
96     "InactiveBorder", "192 192 192",         /* COLOR_INACTIVEBORDER */
97     "AppWorkSpace", "128 128 128",           /* COLOR_APPWORKSPACE */
98     "Hilight", "0 0 128",                    /* COLOR_HIGHLIGHT */
99     "HilightText", "255 255 255",            /* COLOR_HIGHLIGHTTEXT */
100     "ButtonFace", "192 192 192",             /* COLOR_BTNFACE */
101     "ButtonShadow", "128 128 128",           /* COLOR_BTNSHADOW */
102     "GrayText", "128 128 128",               /* COLOR_GRAYTEXT */
103     "ButtonText", "0 0 0",                   /* COLOR_BTNTEXT */
104     "InactiveTitleText", "192 192 192",      /* COLOR_INACTIVECAPTIONTEXT */
105     "ButtonHilight", "255 255 255",          /* COLOR_BTNHIGHLIGHT */
106     "ButtonDkShadow", "0 0 0",               /* COLOR_3DDKSHADOW */
107     "ButtonLight", "224 224 224",            /* COLOR_3DLIGHT */
108     "InfoText", "0 0 0",                     /* COLOR_INFOTEXT */
109     "InfoWindow", "255 255 225",             /* COLOR_INFOBK */
110     "ButtonAlternateFace", "180 180 180",    /* COLOR_ALTERNATEBTNFACE */
111     "HotTrackingColor", "0 0 255",           /* COLOR_HOTLIGHT */
112     "GradientActiveTitle", "16 132 208",     /* COLOR_GRADIENTACTIVECAPTION */
113     "GradientInactiveTitle", "181 181 181",  /* COLOR_GRADIENTINACTIVECAPTION */
114     "MenuHilight", "0 0 0",                  /* COLOR_MENUHILIGHT */
115     "MenuBar", "192 192 192"                 /* COLOR_MENUBAR */
116 };
117
118 /**
119  * Names of the registry subkeys of HKEY_CURRENT_USER key and value names
120  * for the system parameters.
121  * Names of the keys are created by adding string "_REGKEY" to
122  * "SET" action names, value names are created by adding "_REG_NAME"
123  * to the "SET" action name.
124  */
125 static const WCHAR SPI_SETBEEP_REGKEY[]=                      {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','S','o','u','n','d',0};
126 static const WCHAR SPI_SETBEEP_VALNAME[]=                     {'B','e','e','p',0};
127 static const WCHAR SPI_SETMOUSE_REGKEY[]=                     {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
128 static const WCHAR SPI_SETMOUSE_VALNAME1[]=                   {'M','o','u','s','e','T','h','r','e','s','h','o','l','d','1',0};
129 static const WCHAR SPI_SETMOUSE_VALNAME2[]=                   {'M','o','u','s','e','T','h','r','e','s','h','o','l','d','2',0};
130 static const WCHAR SPI_SETMOUSE_VALNAME3[]=                   {'M','o','u','s','e','S','p','e','e','d',0};
131 static const WCHAR SPI_SETBORDER_REGKEY[]=                    {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
132                                                                'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
133 static const WCHAR SPI_SETBORDER_VALNAME[]=                   {'B','o','r','d','e','r','W','i','d','t','h',0};
134 static const WCHAR SPI_SETKEYBOARDSPEED_REGKEY[]=             {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','K','e','y','b','o','a','r','d',0};
135 static const WCHAR SPI_SETKEYBOARDSPEED_VALNAME[]=            {'K','e','y','b','o','a','r','d','S','p','e','e','d',0};
136 static const WCHAR SPI_ICONHORIZONTALSPACING_REGKEY[]=        {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
137                                                                'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
138 static const WCHAR SPI_ICONHORIZONTALSPACING_VALNAME[]=       {'I','c','o','n','S','p','a','c','i','n','g',0};
139 static const WCHAR SPI_SETSCREENSAVETIMEOUT_REGKEY[]=         {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
140 static const WCHAR SPI_SETSCREENSAVETIMEOUT_VALNAME[]=        {'S','c','r','e','e','n','S','a','v','e','T','i','m','e','O','u','t',0};
141 static const WCHAR SPI_SETSCREENSAVEACTIVE_REGKEY[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
142 static const WCHAR SPI_SETSCREENSAVEACTIVE_VALNAME[]=         {'S','c','r','e','e','n','S','a','v','e','A','c','t','i','v','e',0};
143 static const WCHAR SPI_SETGRIDGRANULARITY_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
144 static const WCHAR SPI_SETGRIDGRANULARITY_VALNAME[]=          {'G','r','i','d','G','r','a','n','u','l','a','r','i','t','y',0};
145 static const WCHAR SPI_SETKEYBOARDDELAY_REGKEY[]=             {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','K','e','y','b','o','a','r','d',0};
146 static const WCHAR SPI_SETKEYBOARDDELAY_VALNAME[]=            {'K','e','y','b','o','a','r','d','D','e','l','a','y',0};
147 static const WCHAR SPI_ICONVERTICALSPACING_REGKEY[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
148                                                                'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
149 static const WCHAR SPI_ICONVERTICALSPACING_VALNAME[]=         {'I','c','o','n','V','e','r','t','i','c','a','l','S','p','a','c','i','n','g',0};
150 static const WCHAR SPI_SETICONTITLEWRAP_REGKEY1[]=            {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
151                                                                'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
152 static const WCHAR SPI_SETICONTITLEWRAP_REGKEY2[]=            {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
153 static const WCHAR SPI_SETICONTITLEWRAP_VALNAME[]=            {'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
154 static const WCHAR SPI_SETICONTITLELOGFONT_REGKEY[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
155                                                                'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
156 static const WCHAR SPI_SETICONTITLELOGFONT_VALNAME[]=         {'I','c','o','n','F','o','n','t',0};
157 static const WCHAR SPI_SETMENUDROPALIGNMENT_REGKEY1[]=        {'S','o','f','t','w','a','r','e','\\',
158                                                                'M','i','c','r','o','s','o','f','t','\\',
159                                                                'W','i','n','d','o','w','s',' ','N','T','\\',
160                                                                'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
161                                                                'W','i','n','d','o','w','s',0};
162 static const WCHAR SPI_SETMENUDROPALIGNMENT_REGKEY2[]=        {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
163 static const WCHAR SPI_SETMENUDROPALIGNMENT_VALNAME[]=        {'M','e','n','u','D','r','o','p','A','l','i','g','n','m','e','n','t',0};
164 static const WCHAR SPI_SETDOUBLECLKWIDTH_REGKEY1[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
165 static const WCHAR SPI_SETDOUBLECLKWIDTH_REGKEY2[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
166 static const WCHAR SPI_SETDOUBLECLKWIDTH_VALNAME[]=           {'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
167 static const WCHAR SPI_SETDOUBLECLKHEIGHT_REGKEY1[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
168 static const WCHAR SPI_SETDOUBLECLKHEIGHT_REGKEY2[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
169 static const WCHAR SPI_SETDOUBLECLKHEIGHT_VALNAME[]=          {'D','o','u','b','l','e','C','l','i','c','k','H','e','i','g','h','t',0};
170 static const WCHAR SPI_SETDOUBLECLICKTIME_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
171 static const WCHAR SPI_SETDOUBLECLICKTIME_VALNAME[]=          {'D','o','u','b','l','e','C','l','i','c','k','S','p','e','e','d',0};
172 static const WCHAR SPI_SETMOUSEBUTTONSWAP_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
173 static const WCHAR SPI_SETMOUSEBUTTONSWAP_VALNAME[]=          {'S','w','a','p','M','o','u','s','e','B','u','t','t','o','n','s',0};
174 static const WCHAR SPI_SETDRAGFULLWINDOWS_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
175 static const WCHAR SPI_SETDRAGFULLWINDOWS_VALNAME[]=          {'D','r','a','g','F','u','l','l','W','i','n','d','o','w','s',0};
176 static const WCHAR SPI_SETSHOWSOUNDS_REGKEY[]=                {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
177                                                                'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
178                                                                'S','h','o','w','S','o','u','n','d','s',0};
179 static const WCHAR SPI_SETSHOWSOUNDS_VALNAME[]=               {'O','n',0};
180 static const WCHAR SPI_SETKEYBOARDPREF_REGKEY[]=              {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
181                                                                'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
182                                                                'K','e','y','b','o','a','r','d',' ','P','r','e','f','e','r','e','n','c','e',0};
183 static const WCHAR SPI_SETKEYBOARDPREF_VALNAME[]=             {'O','n',0};
184 static const WCHAR SPI_SETSCREENREADER_REGKEY[]=              {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
185                                                                'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
186                                                                'B','l','i','n','d',' ','A','c','c','e','s','s',0};
187 static const WCHAR SPI_SETSCREENREADER_VALNAME[]=             {'O','n',0};
188 static const WCHAR SPI_SETDESKWALLPAPER_REGKEY[]=             {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
189 static const WCHAR SPI_SETDESKWALLPAPER_VALNAME[]=            {'W','a','l','l','p','a','p','e','r',0};
190 static const WCHAR SPI_SETFONTSMOOTHING_REGKEY[]=             {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
191 static const WCHAR SPI_SETFONTSMOOTHING_VALNAME[]=            {'F','o','n','t','S','m','o','o','t','h','i','n','g',0};
192 static const WCHAR SPI_SETLOWPOWERACTIVE_REGKEY[]=            {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
193 static const WCHAR SPI_SETLOWPOWERACTIVE_VALNAME[]=           {'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0};
194 static const WCHAR SPI_SETPOWEROFFACTIVE_REGKEY[]=            {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
195 static const WCHAR SPI_SETPOWEROFFACTIVE_VALNAME[]=           {'P','o','w','e','r','O','f','f','A','c','t','i','v','e',0};
196 static const WCHAR SPI_USERPREFERENCEMASK_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
197 static const WCHAR SPI_USERPREFERENCEMASK_VALNAME[]=          {'U','s','e','r','P','r','e','f','e','r','e','n','c','e','m','a','s','k',0};
198 static const WCHAR SPI_SETLISTBOXSMOOTHSCROLLING_REGKEY[]=    {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
199 static const WCHAR SPI_SETLISTBOXSMOOTHSCROLLING_VALNAME[]=   {'S','m','o','o','t','h','S','c','r','o','l','l',0};
200 static const WCHAR SPI_SETMOUSEHOVERWIDTH_REGKEY[]=           {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
201 static const WCHAR SPI_SETMOUSEHOVERWIDTH_VALNAME[]=          {'M','o','u','s','e','H','o','v','e','r','W','i','d','t','h',0};
202 static const WCHAR SPI_SETMOUSEHOVERHEIGHT_REGKEY[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
203 static const WCHAR SPI_SETMOUSEHOVERHEIGHT_VALNAME[]=         {'M','o','u','s','e','H','o','v','e','r','H','e','i','g','h','t',0};
204 static const WCHAR SPI_SETMOUSEHOVERTIME_REGKEY[]=            {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
205 static const WCHAR SPI_SETMOUSEHOVERTIME_VALNAME[]=           {'M','o','u','s','e','H','o','v','e','r','T','i','m','e',0};
206 static const WCHAR SPI_SETMOUSESCROLLLINES_REGKEY[]=          {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
207 static const WCHAR SPI_SETMOUSESCROLLLINES_VALNAME[]=         {'W','h','e','e','l','S','c','r','o','l','l','L','i','n','e','s',0};
208 static const WCHAR SPI_SETMENUSHOWDELAY_REGKEY[]=             {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
209 static const WCHAR SPI_SETMENUSHOWDELAY_VALNAME[]=            {'M','e','n','u','S','h','o','w','D','e','l','a','y',0};
210
211 /* FIXME - real values */
212 static const WCHAR SPI_SETSCREENSAVERRUNNING_REGKEY[]=   {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
213 static const WCHAR SPI_SETSCREENSAVERRUNNING_VALNAME[]=  {'W','I','N','E','_','S','c','r','e','e','n','S','a','v','e','r','R','u','n','n','i','n','g',0};
214
215 static const WCHAR METRICS_REGKEY[]=                  {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
216                                                        'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
217 static const WCHAR METRICS_SCROLLWIDTH_VALNAME[]=     {'S','c','r','o','l','l','W','i','d','t','h',0};
218 static const WCHAR METRICS_SCROLLHEIGHT_VALNAME[]=    {'S','c','r','o','l','l','H','e','i','g','h','t',0};
219 static const WCHAR METRICS_CAPTIONWIDTH_VALNAME[]=    {'C','a','p','t','i','o','n','W','i','d','t','h',0};
220 static const WCHAR METRICS_CAPTIONHEIGHT_VALNAME[]=   {'C','a','p','t','i','o','n','H','e','i','g','h','t',0};
221 static const WCHAR METRICS_SMCAPTIONWIDTH_VALNAME[]=  {'S','m','C','a','p','t','i','o','n','W','i','d','t','h',0};
222 static const WCHAR METRICS_SMCAPTIONHEIGHT_VALNAME[]= {'S','m','C','a','p','t','i','o','n','H','e','i','g','h','t',0};
223 static const WCHAR METRICS_MENUWIDTH_VALNAME[]=       {'M','e','n','u','W','i','d','t','h',0};
224 static const WCHAR METRICS_MENUHEIGHT_VALNAME[]=      {'M','e','n','u','H','e','i','g','h','t',0};
225 static const WCHAR METRICS_ICONSIZE_VALNAME[]=        {'S','h','e','l','l',' ','I','c','o','n',' ','S','i','z','e',0};
226 static const WCHAR METRICS_BORDERWIDTH_VALNAME[]=     {'B','o','r','d','e','r','W','i','d','t','h',0};
227 static const WCHAR METRICS_CAPTIONLOGFONT_VALNAME[]=  {'C','a','p','t','i','o','n','F','o','n','t',0};
228 static const WCHAR METRICS_SMCAPTIONLOGFONT_VALNAME[]={'S','m','C','a','p','t','i','o','n','F','o','n','t',0};
229 static const WCHAR METRICS_MENULOGFONT_VALNAME[]=     {'M','e','n','u','F','o','n','t',0};
230 static const WCHAR METRICS_MESSAGELOGFONT_VALNAME[]=  {'M','e','s','s','a','g','e','F','o','n','t',0};
231 static const WCHAR METRICS_STATUSLOGFONT_VALNAME[]=   {'S','t','a','t','u','s','F','o','n','t',0};
232 /* minimized metrics */
233 static const WCHAR METRICS_MINWIDTH_VALNAME[] =   {'M','i','n','W','i','d','t','h','\0'}; 
234 static const WCHAR METRICS_MINHORZGAP_VALNAME[] = {'M','i','n','H','o','r','z','G','a','p','\0'};
235 static const WCHAR METRICS_MINVERTGAP_VALNAME[] = {'M','i','n','V','e','r','t','G','a','p','\0'};
236 static const WCHAR METRICS_MINARRANGE_VALNAME[] = {'M','i','n','A','r','r','a','n','g','e','\0'}; 
237
238 static const WCHAR WINE_CURRENT_USER_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
239                                                  'W','i','n','e',0};
240
241 /* volatile registry branch under WINE_CURRENT_USER_REGKEY for temporary values storage */
242 static const WCHAR WINE_CURRENT_USER_REGKEY_TEMP_PARAMS[] = {'T','e','m','p','o','r','a','r','y',' ',
243                                                              'S','y','s','t','e','m',' ',
244                                                              'P','a','r','a','m','e','t','e','r','s',0};
245
246 static const WCHAR Yes[]=                                    {'Y','e','s',0};
247 static const WCHAR No[]=                                     {'N','o',0};
248 static const WCHAR Desktop[]=                                {'D','e','s','k','t','o','p',0};
249 static const WCHAR Pattern[]=                                {'P','a','t','t','e','r','n',0};
250 static const WCHAR MenuFont[]=                               {'M','e','n','u','F','o','n','t',0};
251 static const WCHAR MenuFontSize[]=                           {'M','e','n','u','F','o','n','t','S','i','z','e',0};
252 static const WCHAR StatusFont[]=                             {'S','t','a','t','u','s','F','o','n','t',0};
253 static const WCHAR StatusFontSize[]=                         {'S','t','a','t','u','s','F','o','n','t','S','i','z','e',0};
254 static const WCHAR MessageFont[]=                            {'M','e','s','s','a','g','e','F','o','n','t',0};
255 static const WCHAR MessageFontSize[]=                        {'M','e','s','s','a','g','e','F','o','n','t','S','i','z','e',0};
256 static const WCHAR System[]=                                 {'S','y','s','t','e','m',0};
257 static const WCHAR IconTitleSize[]=                          {'I','c','o','n','T','i','t','l','e','S','i','z','e',0};
258 static const WCHAR IconTitleFaceName[]=                      {'I','c','o','n','T','i','t','l','e','F','a','c','e','N','a','m','e',0};
259 static const WCHAR defPattern[]=                             {'1','7','0',' ','8','5',' ','1','7','0',' ','8','5',' ','1','7','0',' ','8','5',
260                                                               ' ','1','7','0',' ','8','5',0};
261 static const WCHAR CSu[]=                                    {'%','u',0};
262 static const WCHAR CSd[]=                                    {'%','d',0};
263
264 /* Indicators whether system parameter value is loaded */
265 static char spi_loaded[SPI_INDEX_COUNT];
266
267 static BOOL notify_change = TRUE;
268
269 /* System parameters storage */
270 static BOOL beep_active = TRUE;
271 static int mouse_threshold1 = 6;
272 static int mouse_threshold2 = 10;
273 static int mouse_speed = 1;
274 static UINT border = 1;
275 static UINT keyboard_speed = 31;
276 static UINT screensave_timeout = 300;
277 static UINT grid_granularity = 0;
278 static UINT keyboard_delay = 1;
279 static UINT double_click_width = 4;
280 static UINT double_click_height = 4;
281 static UINT double_click_time = 500;
282 static BOOL drag_full_windows = FALSE;
283 static RECT work_area;
284 static BOOL keyboard_pref = TRUE;
285 static BOOL screen_reader = FALSE;
286 static UINT mouse_hover_width = 4;
287 static UINT mouse_hover_height = 4;
288 static UINT mouse_hover_time = 400;
289 static UINT mouse_scroll_lines = 3;
290 static UINT menu_show_delay = 400;
291 static UINT menu_drop_alignment = 0;
292 static BOOL screensaver_running = FALSE;
293 static UINT font_smoothing = 0;  /* 0x01 for 95/98/NT, 0x02 for 98/ME/2k/XP */
294 static BOOL lowpoweractive = FALSE;
295 static BOOL poweroffactive = FALSE;
296 static BOOL show_sounds = FALSE;
297 static BOOL swap_buttons = FALSE;
298 static BOOL listbox_smoothscrolling = FALSE;
299 static BYTE user_prefs[4];
300
301 static MINIMIZEDMETRICS minimized_metrics =
302 {
303     sizeof(MINIMIZEDMETRICS),
304     154,      /* iWidth */
305     0,        /* iHorzGap */
306     0,        /* iVertGap */
307     ARW_HIDE  /* iArrange */
308 };
309
310 static ICONMETRICSW icon_metrics =
311 {
312     sizeof(ICONMETRICSW),
313     75,   /* iHorzSpacing */
314     75,   /* iVertSpacing */
315     TRUE, /* iTitleWrap */
316     { -11, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET,
317       OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH }   /* lfFont */
318 };
319
320 static NONCLIENTMETRICSW nonclient_metrics =
321 {
322     sizeof(NONCLIENTMETRICSW),
323     1,     /* iBorderWidth */
324     16,    /* iScrollWidth */
325     16,    /* iScrollHeight */
326     18,    /* iCaptionWidth */
327     18,    /* iCaptionHeight */
328     { 0 }, /* lfCaptionFont */
329     13,    /* iSmCaptionWidth */
330     15,    /* iSmCaptionHeight */
331     { 0 }, /* lfSmCaptionFont */
332     18,    /* iMenuWidth */
333     18,    /* iMenuHeight */
334     { 0 }, /* lfMenuFont */
335     { 0 }, /* lfStatusFont */
336     { 0 }  /* lfMessageFont */
337 };
338
339 /* some additional non client metric info */
340 static TEXTMETRICW tmMenuFont;
341 static UINT CaptionFontAvCharWidth;
342
343 static SIZE icon_size = { 32, 32 };
344
345 #define NUM_SYS_COLORS     (COLOR_MENUBAR+1)
346
347 static COLORREF SysColors[NUM_SYS_COLORS];
348 static HBRUSH SysColorBrushes[NUM_SYS_COLORS];
349 static HPEN   SysColorPens[NUM_SYS_COLORS];
350
351 static const WORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
352
353 HBRUSH SYSCOLOR_55AABrush = 0;
354
355 extern void __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
356
357
358 /* This function is a copy of the one in objects/font.c */
359 static void SYSPARAMS_LogFont32ATo16( const LOGFONTA* font32, LPLOGFONT16 font16 )
360 {
361     font16->lfHeight = font32->lfHeight;
362     font16->lfWidth = font32->lfWidth;
363     font16->lfEscapement = font32->lfEscapement;
364     font16->lfOrientation = font32->lfOrientation;
365     font16->lfWeight = font32->lfWeight;
366     font16->lfItalic = font32->lfItalic;
367     font16->lfUnderline = font32->lfUnderline;
368     font16->lfStrikeOut = font32->lfStrikeOut;
369     font16->lfCharSet = font32->lfCharSet;
370     font16->lfOutPrecision = font32->lfOutPrecision;
371     font16->lfClipPrecision = font32->lfClipPrecision;
372     font16->lfQuality = font32->lfQuality;
373     font16->lfPitchAndFamily = font32->lfPitchAndFamily;
374     lstrcpynA( font16->lfFaceName, font32->lfFaceName, LF_FACESIZE );
375 }
376
377 static void SYSPARAMS_LogFont16To32W( const LOGFONT16 *font16, LPLOGFONTW font32 )
378 {
379     font32->lfHeight = font16->lfHeight;
380     font32->lfWidth = font16->lfWidth;
381     font32->lfEscapement = font16->lfEscapement;
382     font32->lfOrientation = font16->lfOrientation;
383     font32->lfWeight = font16->lfWeight;
384     font32->lfItalic = font16->lfItalic;
385     font32->lfUnderline = font16->lfUnderline;
386     font32->lfStrikeOut = font16->lfStrikeOut;
387     font32->lfCharSet = font16->lfCharSet;
388     font32->lfOutPrecision = font16->lfOutPrecision;
389     font32->lfClipPrecision = font16->lfClipPrecision;
390     font32->lfQuality = font16->lfQuality;
391     font32->lfPitchAndFamily = font16->lfPitchAndFamily;
392     MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
393     font32->lfFaceName[LF_FACESIZE-1] = 0;
394 }
395
396 static void SYSPARAMS_LogFont32WTo32A( const LOGFONTW* font32W, LPLOGFONTA font32A )
397 {
398     font32A->lfHeight = font32W->lfHeight;
399     font32A->lfWidth = font32W->lfWidth;
400     font32A->lfEscapement = font32W->lfEscapement;
401     font32A->lfOrientation = font32W->lfOrientation;
402     font32A->lfWeight = font32W->lfWeight;
403     font32A->lfItalic = font32W->lfItalic;
404     font32A->lfUnderline = font32W->lfUnderline;
405     font32A->lfStrikeOut = font32W->lfStrikeOut;
406     font32A->lfCharSet = font32W->lfCharSet;
407     font32A->lfOutPrecision = font32W->lfOutPrecision;
408     font32A->lfClipPrecision = font32W->lfClipPrecision;
409     font32A->lfQuality = font32W->lfQuality;
410     font32A->lfPitchAndFamily = font32W->lfPitchAndFamily;
411     WideCharToMultiByte( CP_ACP, 0, font32W->lfFaceName, -1, font32A->lfFaceName, LF_FACESIZE, NULL, NULL );
412     font32A->lfFaceName[LF_FACESIZE-1] = 0;
413 }
414
415 static void SYSPARAMS_LogFont32ATo32W( const LOGFONTA* font32A, LPLOGFONTW font32W )
416 {
417     font32W->lfHeight = font32A->lfHeight;
418     font32W->lfWidth = font32A->lfWidth;
419     font32W->lfEscapement = font32A->lfEscapement;
420     font32W->lfOrientation = font32A->lfOrientation;
421     font32W->lfWeight = font32A->lfWeight;
422     font32W->lfItalic = font32A->lfItalic;
423     font32W->lfUnderline = font32A->lfUnderline;
424     font32W->lfStrikeOut = font32A->lfStrikeOut;
425     font32W->lfCharSet = font32A->lfCharSet;
426     font32W->lfOutPrecision = font32A->lfOutPrecision;
427     font32W->lfClipPrecision = font32A->lfClipPrecision;
428     font32W->lfQuality = font32A->lfQuality;
429     font32W->lfPitchAndFamily = font32A->lfPitchAndFamily;
430     MultiByteToWideChar( CP_ACP, 0, font32A->lfFaceName, -1, font32W->lfFaceName, LF_FACESIZE );
431     font32W->lfFaceName[LF_FACESIZE-1] = 0;
432 }
433
434 static void SYSPARAMS_NonClientMetrics32ATo16( const NONCLIENTMETRICSA* lpnm32, LPNONCLIENTMETRICS16 lpnm16 )
435 {
436     lpnm16->iBorderWidth        = lpnm32->iBorderWidth;
437     lpnm16->iScrollWidth        = lpnm32->iScrollWidth;
438     lpnm16->iScrollHeight       = lpnm32->iScrollHeight;
439     lpnm16->iCaptionWidth       = lpnm32->iCaptionWidth;
440     lpnm16->iCaptionHeight      = lpnm32->iCaptionHeight;
441     SYSPARAMS_LogFont32ATo16( &lpnm32->lfCaptionFont,   &lpnm16->lfCaptionFont );
442     lpnm16->iSmCaptionWidth     = lpnm32->iSmCaptionWidth;
443     lpnm16->iSmCaptionHeight    = lpnm32->iSmCaptionHeight;
444     SYSPARAMS_LogFont32ATo16( &lpnm32->lfSmCaptionFont, &lpnm16->lfSmCaptionFont );
445     lpnm16->iMenuWidth          = lpnm32->iMenuWidth;
446     lpnm16->iMenuHeight         = lpnm32->iMenuHeight;
447     SYSPARAMS_LogFont32ATo16( &lpnm32->lfMenuFont,      &lpnm16->lfMenuFont );
448     SYSPARAMS_LogFont32ATo16( &lpnm32->lfStatusFont,    &lpnm16->lfStatusFont );
449     SYSPARAMS_LogFont32ATo16( &lpnm32->lfMessageFont,   &lpnm16->lfMessageFont );
450 }
451
452 static void SYSPARAMS_NonClientMetrics32WTo32A( const NONCLIENTMETRICSW* lpnm32W, LPNONCLIENTMETRICSA lpnm32A )
453 {
454     lpnm32A->iBorderWidth       = lpnm32W->iBorderWidth;
455     lpnm32A->iScrollWidth       = lpnm32W->iScrollWidth;
456     lpnm32A->iScrollHeight      = lpnm32W->iScrollHeight;
457     lpnm32A->iCaptionWidth      = lpnm32W->iCaptionWidth;
458     lpnm32A->iCaptionHeight     = lpnm32W->iCaptionHeight;
459     SYSPARAMS_LogFont32WTo32A(  &lpnm32W->lfCaptionFont,        &lpnm32A->lfCaptionFont );
460     lpnm32A->iSmCaptionWidth    = lpnm32W->iSmCaptionWidth;
461     lpnm32A->iSmCaptionHeight   = lpnm32W->iSmCaptionHeight;
462     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfSmCaptionFont,       &lpnm32A->lfSmCaptionFont );
463     lpnm32A->iMenuWidth         = lpnm32W->iMenuWidth;
464     lpnm32A->iMenuHeight        = lpnm32W->iMenuHeight;
465     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMenuFont,            &lpnm32A->lfMenuFont );
466     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfStatusFont,          &lpnm32A->lfStatusFont );
467     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMessageFont,         &lpnm32A->lfMessageFont );
468 }
469
470 static void SYSPARAMS_NonClientMetrics32ATo32W( const NONCLIENTMETRICSA* lpnm32A, LPNONCLIENTMETRICSW lpnm32W )
471 {
472     lpnm32W->iBorderWidth       = lpnm32A->iBorderWidth;
473     lpnm32W->iScrollWidth       = lpnm32A->iScrollWidth;
474     lpnm32W->iScrollHeight      = lpnm32A->iScrollHeight;
475     lpnm32W->iCaptionWidth      = lpnm32A->iCaptionWidth;
476     lpnm32W->iCaptionHeight     = lpnm32A->iCaptionHeight;
477     SYSPARAMS_LogFont32ATo32W(  &lpnm32A->lfCaptionFont,        &lpnm32W->lfCaptionFont );
478     lpnm32W->iSmCaptionWidth    = lpnm32A->iSmCaptionWidth;
479     lpnm32W->iSmCaptionHeight   = lpnm32A->iSmCaptionHeight;
480     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfSmCaptionFont,       &lpnm32W->lfSmCaptionFont );
481     lpnm32W->iMenuWidth         = lpnm32A->iMenuWidth;
482     lpnm32W->iMenuHeight        = lpnm32A->iMenuHeight;
483     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMenuFont,            &lpnm32W->lfMenuFont );
484     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfStatusFont,          &lpnm32W->lfStatusFont );
485     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMessageFont,         &lpnm32W->lfMessageFont );
486 }
487
488 /* get text metrics and/or "average" char width of the specified logfont 
489  * for the specified dc */
490 static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz)
491 {
492     HFONT hfont, hfontsav;
493     TEXTMETRICW tm;
494     if( !ptm) ptm = &tm;
495     hfont = CreateFontIndirectW( plf);
496     if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) {
497         ptm->tmHeight = -1;
498         if( psz) *psz = 10;
499         if( hfont) DeleteObject( hfont);
500         return;
501     }
502     GetTextMetricsW( hdc, ptm);
503     if( psz)
504         if( !(*psz = GdiGetCharDimensions( hdc, ptm, NULL)))
505             *psz = 10;
506     SelectObject( hdc, hfontsav);
507     DeleteObject( hfont);
508 }
509
510 /***********************************************************************
511  *           get_volatile_regkey
512  *
513  * Return a handle to the volatile registry key used to store
514  * non-permanently modified parameters.
515  */
516 static HKEY get_volatile_regkey(void)
517 {
518     static HKEY volatile_key;
519
520     if (!volatile_key)
521     {
522         HKEY key;
523         /* This must be non-volatile! */
524         if (RegCreateKeyExW( HKEY_CURRENT_USER, WINE_CURRENT_USER_REGKEY,
525                              0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0,
526                              &key, 0 ) != ERROR_SUCCESS)
527         {
528             ERR("Can't create wine registry branch\n");
529         }
530         else
531         {
532             /* @@ Wine registry key: HKCU\Software\Wine\Temporary System Parameters */
533             if (RegCreateKeyExW( key, WINE_CURRENT_USER_REGKEY_TEMP_PARAMS,
534                                  0, 0, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, 0,
535                                  &volatile_key, 0 ) != ERROR_SUCCESS)
536                 ERR("Can't create non-permanent wine registry branch\n");
537
538             RegCloseKey(key);
539         }
540     }
541     return volatile_key;
542 }
543
544 /***********************************************************************
545  *           SYSPARAMS_NotifyChange
546  *
547  * Sends notification about system parameter update.
548  */
549 static void SYSPARAMS_NotifyChange( UINT uiAction, UINT fWinIni )
550 {
551     static const WCHAR emptyW[1];
552
553     if (notify_change)
554     {
555         if (fWinIni & SPIF_UPDATEINIFILE)
556         {
557             if (fWinIni & (SPIF_SENDWININICHANGE | SPIF_SENDCHANGE))
558                 SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
559                                     uiAction, (LPARAM) emptyW,
560                                     SMTO_ABORTIFHUNG, 2000, NULL );
561         }
562         else
563         {
564             /* FIXME notify other wine processes with internal message */
565         }
566     }
567 }
568
569
570 /***********************************************************************
571  * Loads system parameter from user profile.
572  */
573 static BOOL SYSPARAMS_LoadRaw( LPCWSTR lpRegKey, LPCWSTR lpValName, LPBYTE lpBuf, DWORD count )
574 {
575     BOOL ret = FALSE;
576     DWORD type;
577     HKEY hKey;
578
579     memset( lpBuf, 0, count );
580     if ((RegOpenKeyW( get_volatile_regkey(), lpRegKey, &hKey ) == ERROR_SUCCESS) ||
581         (RegOpenKeyW( HKEY_CURRENT_USER, lpRegKey, &hKey ) == ERROR_SUCCESS))
582     {
583         ret = !RegQueryValueExW( hKey, lpValName, NULL, &type, (LPBYTE)lpBuf, &count);
584         RegCloseKey( hKey );
585     }
586     return ret;
587 }
588
589 static BOOL SYSPARAMS_Load( LPCWSTR lpRegKey, LPCWSTR lpValName, LPWSTR lpBuf, DWORD count )
590 {
591   return SYSPARAMS_LoadRaw( lpRegKey, lpValName, (LPBYTE)lpBuf, count );
592 }
593
594 /***********************************************************************
595  * Saves system parameter to user profile.
596  */
597
598 /* Save data as-is */
599 static BOOL SYSPARAMS_SaveRaw( LPCWSTR lpRegKey, LPCWSTR lpValName, 
600                                const BYTE* lpValue, DWORD valueSize, 
601                                DWORD type, UINT fWinIni )
602 {
603     HKEY hKey;
604     HKEY hBaseKey;
605     DWORD dwOptions;
606     BOOL ret = FALSE;
607
608     if (fWinIni & SPIF_UPDATEINIFILE)
609     {
610         hBaseKey = HKEY_CURRENT_USER;
611         dwOptions = 0;
612     }
613     else
614     {
615         hBaseKey = get_volatile_regkey();
616         dwOptions = REG_OPTION_VOLATILE;
617     }
618
619     if (RegCreateKeyExW( hBaseKey, lpRegKey,
620                          0, 0, dwOptions, KEY_ALL_ACCESS,
621                          0, &hKey, 0 ) == ERROR_SUCCESS)
622     {
623         if (RegSetValueExW( hKey, lpValName, 0, type,
624                             lpValue, valueSize) == ERROR_SUCCESS)
625         {
626             ret = TRUE;
627             if (hBaseKey == HKEY_CURRENT_USER)
628                 RegDeleteKeyW( get_volatile_regkey(), lpRegKey );
629         }
630         RegCloseKey( hKey );
631     }
632     return ret;
633 }
634
635 /* Convenience function to save strings */
636 static BOOL SYSPARAMS_Save( LPCWSTR lpRegKey, LPCWSTR lpValName, LPCWSTR lpValue,
637                             UINT fWinIni )
638 {
639     return SYSPARAMS_SaveRaw( lpRegKey, lpValName, (const BYTE*)lpValue, 
640         (strlenW(lpValue) + 1)*sizeof(WCHAR), REG_SZ, fWinIni );
641 }
642
643 /* Convenience function to save logical fonts */
644 static BOOL SYSPARAMS_SaveLogFont( LPCWSTR lpRegKey, LPCWSTR lpValName,
645                                     LPLOGFONTW plf, UINT fWinIni )
646 {
647     return SYSPARAMS_SaveRaw( lpRegKey, lpValName, (const BYTE*)plf, 
648         sizeof( LOGFONTW), REG_BINARY, fWinIni );
649 }
650
651
652 static inline HDC get_display_dc(void)
653 {
654     static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
655     static HDC display_dc;
656     if (!display_dc) display_dc = CreateICW( DISPLAY, NULL, NULL, NULL );
657     return display_dc;
658 }
659
660 static inline int get_display_dpi(void)
661 {
662     static int display_dpi;
663     if (!display_dpi) display_dpi = GetDeviceCaps( get_display_dc(), LOGPIXELSY );
664     return display_dpi;
665 }
666
667 /***********************************************************************
668  * SYSPARAMS_Twips2Pixels
669  *
670  * Convert a dimension value that was obtained from the registry.  These are
671  * quoted as being "twips" values if negative and pixels if positive.
672  * One inch is 1440 twips. So to convert, divide by 1440 to get inches and
673  * multiply that by the dots-per-inch to get the size in pixels. 
674  * See for example
675  *   MSDN Library - April 2001 -> Resource Kits ->
676  *       Windows 2000 Resource Kit Reference ->
677  *       Technical Reference to the Windows 2000 Registry ->
678  *       HKEY_CURRENT_USER -> Control Panel -> Desktop -> WindowMetrics
679  */
680 inline static int SYSPARAMS_Twips2Pixels(int x)
681 {
682     if (x < 0)
683         x = (-x * get_display_dpi() + 720) / 1440;
684     return x;
685 }
686
687 /***********************************************************************
688  * get_reg_metric
689  *
690  * Get a registry entry from the already open key.  This allows us to open the
691  * section once and read several values.
692  *
693  * Of course this function belongs somewhere more usable but here will do
694  * for now.
695  */
696 static int get_reg_metric( HKEY hkey, LPCWSTR lpValName, int default_value )
697 {
698     int value = default_value;
699     if (hkey)
700     {
701         WCHAR buffer[128];
702         DWORD type, count = sizeof(buffer);
703         if(!RegQueryValueExW( hkey, lpValName, NULL, &type, (LPBYTE)buffer, &count) )
704         {
705             if (type != REG_SZ)
706             {
707                 /* Are there any utilities for converting registry entries
708                  * between formats?
709                  */
710                 /* FIXME_(reg)("We need reg format converter\n"); */
711             }
712             else
713                 value = atoiW(buffer);
714         }
715     }
716     return SYSPARAMS_Twips2Pixels(value);
717 }
718
719
720 /*************************************************************************
721  *             SYSPARAMS_SetSysColor
722  */
723 static void SYSPARAMS_SetSysColor( int index, COLORREF color )
724 {
725     if (index < 0 || index >= NUM_SYS_COLORS) return;
726     SysColors[index] = color;
727     if (SysColorBrushes[index])
728     {
729         __wine_make_gdi_object_system( SysColorBrushes[index], FALSE);
730         DeleteObject( SysColorBrushes[index] );
731     }
732     SysColorBrushes[index] = CreateSolidBrush( color );
733     __wine_make_gdi_object_system( SysColorBrushes[index], TRUE);
734
735     if (SysColorPens[index])
736     {
737         __wine_make_gdi_object_system( SysColorPens[index], FALSE);
738         DeleteObject( SysColorPens[index] );
739     }
740     SysColorPens[index] = CreatePen( PS_SOLID, 1, color );
741     __wine_make_gdi_object_system( SysColorPens[index], TRUE);
742 }
743
744 /* load a uint parameter from the registry */
745 static BOOL get_uint_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
746                             UINT *value_ptr, UINT *ret_ptr )
747 {
748     if (!ret_ptr) return FALSE;
749     if (!spi_loaded[idx])
750     {
751         WCHAR buf[12];
752
753         if (SYSPARAMS_Load( regkey, value, buf, sizeof(buf) )) *value_ptr = atoiW( buf );
754         spi_loaded[idx] = TRUE;
755     }
756     *ret_ptr = *value_ptr;
757     return TRUE;
758 }
759
760 /* load a twips parameter from the registry */
761 static BOOL get_twips_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
762                              UINT *value_ptr, UINT *ret_ptr )
763 {
764     if (!ret_ptr) return FALSE;
765     if (!spi_loaded[idx])
766     {
767         WCHAR buf[12];
768
769         if (SYSPARAMS_Load( regkey, value, buf, sizeof(buf) ))
770             *value_ptr = SYSPARAMS_Twips2Pixels( atoiW(buf) );
771         spi_loaded[idx] = TRUE;
772     }
773     *ret_ptr = *value_ptr;
774     return TRUE;
775 }
776
777 /* load a boolean parameter from the registry */
778 static inline BOOL get_bool_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
779                                    BOOL *value_ptr, BOOL *ret_ptr )
780 {
781     return get_uint_param( idx, regkey, value, (UINT *)value_ptr, (UINT *)ret_ptr );
782 }
783
784 /* set a uint parameter that is mirrored in two different registry locations */
785 static BOOL set_uint_param_mirrored( unsigned int idx, LPCWSTR regkey, LPCWSTR regkey_mirror,
786                                      LPCWSTR value, UINT *value_ptr, UINT new_val, UINT fWinIni )
787 {
788     WCHAR buf[12];
789
790     wsprintfW(buf, CSu, new_val);
791     if (!SYSPARAMS_Save( regkey, value, buf, fWinIni )) return FALSE;
792     if (regkey_mirror) SYSPARAMS_Save( regkey_mirror, value, buf, fWinIni );
793     *value_ptr = new_val;
794     spi_loaded[idx] = TRUE;
795     return TRUE;
796 }
797
798 /* save an int parameter in registry */
799 static BOOL save_int_param( LPCWSTR regkey, LPCWSTR value, INT *value_ptr,
800                             INT new_val, UINT fWinIni )
801 {
802     WCHAR buf[12];
803
804     wsprintfW(buf, CSd, new_val);
805     if (!SYSPARAMS_Save( regkey, value, buf, fWinIni )) return FALSE;
806     if( value_ptr) *value_ptr = new_val;
807     return TRUE;
808 }
809
810 /* set an int parameter in the registry */
811 static inline BOOL set_int_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
812                                   INT *value_ptr, INT new_val, UINT fWinIni )
813 {
814     BOOL ret = save_int_param( regkey, value, value_ptr, new_val, fWinIni );
815     if (ret) spi_loaded[idx] = TRUE;
816     return ret;
817 }
818
819 /* set a uint parameter in the registry */
820 static inline BOOL set_uint_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
821                                    UINT *value_ptr, UINT new_val, UINT fWinIni )
822 {
823     return set_uint_param_mirrored( idx, regkey, NULL, value, value_ptr, new_val, fWinIni );
824 }
825
826 /* set a boolean parameter that is mirrored in two different registry locations */
827 static inline BOOL set_bool_param_mirrored( unsigned int idx, LPCWSTR regkey, LPCWSTR regkey_mirror,
828                                             LPCWSTR value, BOOL *value_ptr, BOOL new_val, UINT fWinIni )
829 {
830     return set_uint_param_mirrored( idx, regkey, regkey_mirror, value,
831                                     (UINT *)value_ptr, new_val, fWinIni );
832 }
833
834 /* set a boolean parameter in the registry */
835 static inline BOOL set_bool_param( unsigned int idx, LPCWSTR regkey, LPCWSTR value,
836                                    BOOL *value_ptr, BOOL new_val, UINT fWinIni )
837 {
838     return set_uint_param( idx, regkey, value, (UINT *)value_ptr, new_val, fWinIni );
839 }
840
841 /* load a boolean parameter from the user preference key */
842 static BOOL get_user_pref_param( UINT offset, UINT mask, BOOL *ret_ptr )
843 {
844     if (!ret_ptr) return FALSE;
845
846     if (!spi_loaded[SPI_USERPREFERENCEMASK_IDX])
847     {
848         SYSPARAMS_LoadRaw( SPI_USERPREFERENCEMASK_REGKEY,
849                            SPI_USERPREFERENCEMASK_VALNAME,
850                            user_prefs, sizeof(user_prefs) );
851         spi_loaded[SPI_USERPREFERENCEMASK_IDX] = TRUE;
852     }
853     *ret_ptr = (user_prefs[offset] & mask) != 0;
854     return TRUE;
855 }
856
857 /* set a boolean parameter in the user preference key */
858 static BOOL set_user_pref_param( UINT offset, UINT mask, BOOL value, BOOL fWinIni )
859 {
860     SYSPARAMS_LoadRaw( SPI_USERPREFERENCEMASK_REGKEY,
861                        SPI_USERPREFERENCEMASK_VALNAME,
862                        user_prefs, sizeof(user_prefs) );
863     spi_loaded[SPI_USERPREFERENCEMASK_IDX] = TRUE;
864
865     if (value) user_prefs[offset] |= mask;
866     else user_prefs[offset] &= ~mask;
867
868     SYSPARAMS_SaveRaw( SPI_USERPREFERENCEMASK_REGKEY,
869                        SPI_USERPREFERENCEMASK_VALNAME,
870                        user_prefs, sizeof(user_prefs), REG_BINARY, fWinIni );
871     return TRUE;
872 }
873
874 /***********************************************************************
875  *           SYSPARAMS_Init
876  *
877  * Initialisation of the system metrics array.
878  */
879 void SYSPARAMS_Init(void)
880 {
881     HKEY hkey; /* key to the window metrics area of the registry */
882     int i, r, g, b;
883     char buffer[100];
884     HBITMAP h55AABitmap;
885
886     /* initialize system colors */
887
888     if (RegCreateKeyExA(HKEY_CURRENT_USER, "Control Panel\\Colors", 0, 0, 0, KEY_ALL_ACCESS, 0, &hkey, 0))
889         hkey = 0;
890     for (i = 0; i < NUM_SYS_COLORS; i++)
891     {
892         BOOL bOk = FALSE;
893
894         /* first try, registry */
895         if (hkey)
896         {
897             DWORD dwDataSize = sizeof(buffer);
898             if (!(RegQueryValueExA(hkey,DefSysColors[i*2], 0, 0, (LPBYTE) buffer, &dwDataSize)))
899                 if (sscanf( buffer, "%d %d %d", &r, &g, &b ) == 3) bOk = TRUE;
900         }
901
902         /* second try, win.ini */
903         if (!bOk)
904         {
905             GetProfileStringA( "colors", DefSysColors[i*2], DefSysColors[i*2+1], buffer, 100 );
906             if (sscanf( buffer, " %d %d %d", &r, &g, &b ) == 3) bOk = TRUE;
907         }
908
909         /* last chance, take the default */
910         if (!bOk)
911         {
912             int iNumColors = sscanf( DefSysColors[i*2+1], " %d %d %d", &r, &g, &b );
913             assert (iNumColors==3);
914         }
915
916         SYSPARAMS_SetSysColor( i, RGB(r,g,b) );
917     }
918     if (hkey) RegCloseKey( hkey );
919
920     /* create 55AA bitmap */
921
922     h55AABitmap = CreateBitmap( 8, 8, 1, 1, wPattern55AA );
923     SYSCOLOR_55AABrush = CreatePatternBrush( h55AABitmap );
924     __wine_make_gdi_object_system( SYSCOLOR_55AABrush, TRUE );
925 }
926
927
928 /***********************************************************************
929  *              reg_get_logfont
930  *
931  *  Tries to retrieve logfont info from the specified key and value
932  */
933 static BOOL reg_get_logfont(LPCWSTR key, LPCWSTR value, LOGFONTW *lf)
934 {
935     HKEY hkey;
936     LOGFONTW lfbuf;
937     DWORD type, size;
938     BOOL found = FALSE;
939     HKEY base_keys[2];
940     int i;
941
942     base_keys[0] = get_volatile_regkey();
943     base_keys[1] = HKEY_CURRENT_USER;
944
945     for(i = 0; i < 2 && !found; i++)
946     {
947         if(RegOpenKeyW(base_keys[i], key, &hkey) == ERROR_SUCCESS)
948         {
949             size = sizeof(lfbuf);
950             if(RegQueryValueExW(hkey, value, NULL, &type, (LPBYTE)&lfbuf, &size) == ERROR_SUCCESS &&
951                     type == REG_BINARY)
952             {
953                 if( size == sizeof(lfbuf))
954                 {
955                     found = TRUE;
956                     memcpy(lf, &lfbuf, size);
957                 } else if( size == sizeof( LOGFONT16))
958                 {    /* win9x-winME format */
959                     found = TRUE;
960                     SYSPARAMS_LogFont16To32W( (LOGFONT16*) &lfbuf, lf);
961                 } else
962                     WARN("Unknown format in key %s value %s, size is %ld\n",
963                             debugstr_w( key), debugstr_w( value), size);
964             }
965             RegCloseKey(hkey);
966         }
967     }
968     if( found && lf->lfHeight > 0) { 
969         /* positive height value means points ( inch/72 ) */
970         lf->lfHeight = -MulDiv( lf->lfHeight, get_display_dpi(), 72);
971     }
972     return found;
973 }
974
975 /* load all the minimized metrics */
976 static void load_minimized_metrics(void)
977 {
978     HKEY hkey;
979     if (RegOpenKeyExW (HKEY_CURRENT_USER, METRICS_REGKEY,
980                        0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) hkey = 0;
981
982     minimized_metrics.iWidth = max( get_reg_metric(hkey,
983             METRICS_MINWIDTH_VALNAME, minimized_metrics.iWidth), 0);
984     minimized_metrics.iHorzGap = max( get_reg_metric(hkey,
985             METRICS_MINHORZGAP_VALNAME, minimized_metrics.iHorzGap), 0);
986     minimized_metrics.iVertGap = max( get_reg_metric(hkey,
987             METRICS_MINVERTGAP_VALNAME, minimized_metrics.iVertGap), 0);
988     minimized_metrics.iArrange = 0x0f & get_reg_metric(hkey,
989             METRICS_MINARRANGE_VALNAME, minimized_metrics.iArrange);
990
991     if (hkey) RegCloseKey( hkey );
992     spi_loaded[SPI_MINIMIZEDMETRICS_IDX] = TRUE;
993 }
994
995 /* adjust some of the raw values found in the registry */
996 static void normalize_nonclientmetrics( NONCLIENTMETRICSW *pncm)
997 {
998     TEXTMETRICW tm;
999     if( pncm->iBorderWidth < 1) pncm->iBorderWidth = 1;
1000     if( pncm->iCaptionWidth < 8) pncm->iCaptionWidth = 8;
1001     if( pncm->iScrollWidth < 8) pncm->iScrollWidth = 8;
1002     if( pncm->iScrollHeight < 8) pncm->iScrollHeight = 8;
1003
1004     /* get some extra metrics */
1005     get_text_metr_size( get_display_dc(), &pncm->lfMenuFont,
1006             &tmMenuFont, NULL);
1007     get_text_metr_size( get_display_dc(), &pncm->lfCaptionFont,
1008             NULL, &CaptionFontAvCharWidth);
1009
1010     /* adjust some heights to the corresponding font */
1011     pncm->iMenuHeight = max( pncm->iMenuHeight,
1012             2 + tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading);
1013     get_text_metr_size( get_display_dc(), &pncm->lfCaptionFont, &tm, NULL);
1014     pncm->iCaptionHeight = max( pncm->iCaptionHeight, 2 + tm.tmHeight);
1015     get_text_metr_size( get_display_dc(), &pncm->lfSmCaptionFont, &tm, NULL);
1016     pncm->iSmCaptionHeight = max( pncm->iSmCaptionHeight, 2 + tm.tmHeight);
1017 }
1018
1019 /* load all the non-client metrics */
1020 static void load_nonclient_metrics(void)
1021 {
1022     HKEY hkey;
1023     NONCLIENTMETRICSW ncm;
1024
1025     if (RegOpenKeyExW (HKEY_CURRENT_USER, METRICS_REGKEY,
1026                        0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) hkey = 0;
1027
1028     /* initialize geometry entries */
1029     ncm.iBorderWidth =  get_reg_metric(hkey, METRICS_BORDERWIDTH_VALNAME, 1);
1030     ncm.iScrollWidth = get_reg_metric(hkey, METRICS_SCROLLWIDTH_VALNAME, 16);
1031     ncm.iScrollHeight = get_reg_metric(hkey, METRICS_SCROLLHEIGHT_VALNAME, 16);
1032
1033     /* size of the normal caption buttons */
1034     ncm.iCaptionHeight = get_reg_metric(hkey, METRICS_CAPTIONHEIGHT_VALNAME, 18);
1035     ncm.iCaptionWidth = get_reg_metric(hkey, METRICS_CAPTIONWIDTH_VALNAME, ncm.iCaptionHeight);
1036
1037     /* caption font metrics */
1038     if (!reg_get_logfont(METRICS_REGKEY, METRICS_CAPTIONLOGFONT_VALNAME, &ncm.lfCaptionFont))
1039     {
1040         SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &ncm.lfCaptionFont, 0 );
1041         ncm.lfCaptionFont.lfWeight = FW_BOLD;
1042     }
1043
1044     /* size of the small caption buttons */
1045     ncm.iSmCaptionWidth = get_reg_metric(hkey, METRICS_SMCAPTIONWIDTH_VALNAME, 13);
1046     ncm.iSmCaptionHeight = get_reg_metric(hkey, METRICS_SMCAPTIONHEIGHT_VALNAME, 15);
1047
1048     /* small caption font metrics */
1049     if (!reg_get_logfont(METRICS_REGKEY, METRICS_SMCAPTIONLOGFONT_VALNAME, &ncm.lfSmCaptionFont))
1050         SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &ncm.lfSmCaptionFont, 0 );
1051
1052     /* menus, FIXME: names of wine.conf entries are bogus */
1053
1054     /* size of the menu (MDI) buttons */
1055     ncm.iMenuHeight = get_reg_metric(hkey, METRICS_MENUHEIGHT_VALNAME, 18);
1056     ncm.iMenuWidth = get_reg_metric(hkey, METRICS_MENUWIDTH_VALNAME, ncm.iMenuHeight);
1057
1058     /* menu font metrics */
1059     if (!reg_get_logfont(METRICS_REGKEY, METRICS_MENULOGFONT_VALNAME, &ncm.lfMenuFont))
1060     {
1061         SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &ncm.lfMenuFont, 0 );
1062         GetProfileStringW( Desktop, MenuFont, ncm.lfCaptionFont.lfFaceName,
1063                            ncm.lfMenuFont.lfFaceName, LF_FACESIZE );
1064         ncm.lfMenuFont.lfHeight = -GetProfileIntW( Desktop, MenuFontSize, 11 );
1065         ncm.lfMenuFont.lfWeight = FW_NORMAL;
1066     }
1067
1068     /* status bar font metrics */
1069     if (!reg_get_logfont(METRICS_REGKEY, METRICS_STATUSLOGFONT_VALNAME, &ncm.lfStatusFont))
1070     {
1071         SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &ncm.lfStatusFont, 0 );
1072         GetProfileStringW( Desktop, StatusFont, ncm.lfCaptionFont.lfFaceName,
1073                            ncm.lfStatusFont.lfFaceName, LF_FACESIZE );
1074         ncm.lfStatusFont.lfHeight = -GetProfileIntW( Desktop, StatusFontSize, 11 );
1075         ncm.lfStatusFont.lfWeight = FW_NORMAL;
1076     }
1077
1078     /* message font metrics */
1079     if (!reg_get_logfont(METRICS_REGKEY, METRICS_MESSAGELOGFONT_VALNAME, &ncm.lfMessageFont))
1080     {
1081         SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0, &ncm.lfMessageFont, 0 );
1082         GetProfileStringW( Desktop, MessageFont, ncm.lfCaptionFont.lfFaceName,
1083                            ncm.lfMessageFont.lfFaceName, LF_FACESIZE );
1084         ncm.lfMessageFont.lfHeight = -GetProfileIntW( Desktop, MessageFontSize, 11 );
1085         ncm.lfMessageFont.lfWeight = FW_NORMAL;
1086     }
1087
1088     /* some extra fields not in the nonclient structure */
1089     icon_size.cx = icon_size.cy = get_reg_metric( hkey, METRICS_ICONSIZE_VALNAME, 32 );
1090
1091     if (hkey) RegCloseKey( hkey );
1092     normalize_nonclientmetrics( &ncm);
1093     memcpy( &nonclient_metrics, &ncm, sizeof(nonclient_metrics) );
1094     spi_loaded[SPI_NONCLIENTMETRICS_IDX] = TRUE;
1095 }
1096
1097
1098 /***********************************************************************
1099  *              SystemParametersInfoW (USER32.@)
1100  *
1101  *     Each system parameter has flag which shows whether the parameter
1102  * is loaded or not. Parameters, stored directly in SysParametersInfo are
1103  * loaded from registry only when they are requested and the flag is
1104  * "false", after the loading the flag is set to "true". On interprocess
1105  * notification of the parameter change the corresponding parameter flag is
1106  * set to "false". The parameter value will be reloaded when it is requested
1107  * the next time.
1108  *     Parameters, backed by or depend on GetSystemMetrics are processed
1109  * differently. These parameters are always loaded. They are reloaded right
1110  * away on interprocess change notification. We can't do lazy loading because
1111  * we don't want to complicate GetSystemMetrics.
1112  *     Parameters, backed by X settings are read from corresponding setting.
1113  * On the parameter change request the setting is changed. Interprocess change
1114  * notifications are ignored.
1115  *     When parameter value is updated the changed value is stored in permanent
1116  * registry branch if saving is requested. Otherwise it is stored
1117  * in temporary branch
1118  *
1119  * Some SPI values can also be stored as Twips values in the registry,
1120  * don't forget the conversion!
1121  */
1122 BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
1123                                    PVOID pvParam, UINT fWinIni )
1124 {
1125 #define WINE_SPI_FIXME(x) \
1126     case x: \
1127         FIXME( "Unimplemented action: %u (%s)\n", x, #x ); \
1128         SetLastError( ERROR_INVALID_SPI_VALUE ); \
1129         ret = FALSE; \
1130         break
1131 #define WINE_SPI_WARN(x) \
1132     case x: \
1133         WARN( "Ignored action: %u (%s)\n", x, #x ); \
1134         break
1135
1136     BOOL ret = TRUE;
1137     unsigned spi_idx = 0;
1138
1139     switch (uiAction)
1140     {
1141     case SPI_GETBEEP:                           /*      1 */
1142         if (!pvParam) return FALSE;
1143
1144         spi_idx = SPI_SETBEEP_IDX;
1145         if (!spi_loaded[spi_idx])
1146         {
1147             WCHAR buf[5];
1148
1149             if (SYSPARAMS_Load( SPI_SETBEEP_REGKEY, SPI_SETBEEP_VALNAME, buf, sizeof(buf) ))
1150                 beep_active  = !lstrcmpiW( Yes, buf );
1151             spi_loaded[spi_idx] = TRUE;
1152         }
1153
1154         *(BOOL *)pvParam = beep_active;
1155         break;
1156
1157     case SPI_SETBEEP:                           /*      2 */
1158         spi_idx = SPI_SETBEEP_IDX;
1159         if (SYSPARAMS_Save( SPI_SETBEEP_REGKEY, SPI_SETBEEP_VALNAME,
1160                             (uiParam ? Yes : No), fWinIni ))
1161         {
1162             beep_active = uiParam;
1163             spi_loaded[spi_idx] = TRUE;
1164         }
1165         else
1166             ret = FALSE;
1167         break;
1168
1169     case SPI_GETMOUSE:                          /*      3 */
1170         if (!pvParam) return FALSE;
1171
1172         spi_idx = SPI_SETMOUSE_IDX;
1173         if (!spi_loaded[spi_idx])
1174         {
1175             WCHAR buf[12];
1176
1177             if (SYSPARAMS_Load( SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME1,
1178                                 buf, sizeof(buf) ))
1179                 mouse_threshold1 = atoiW( buf );
1180             if (SYSPARAMS_Load( SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME2,
1181                                 buf, sizeof(buf) ))
1182                 mouse_threshold2 = atoiW( buf );
1183             if (SYSPARAMS_Load( SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME3,
1184                                 buf, sizeof(buf) ))
1185                 mouse_speed = atoiW( buf );
1186             spi_loaded[spi_idx] = TRUE;
1187         }
1188         ((INT *)pvParam)[0] = mouse_threshold1;
1189         ((INT *)pvParam)[1] = mouse_threshold2;
1190         ((INT *)pvParam)[2] = mouse_speed;
1191         break;
1192
1193     case SPI_SETMOUSE:                          /*      4 */
1194     {
1195         if (!pvParam) return FALSE;
1196         ret = set_int_param( SPI_SETMOUSE_IDX, SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME1,
1197                              &mouse_threshold1, ((INT *)pvParam)[0], fWinIni);
1198         if( ret) {
1199             save_int_param( SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME2,
1200                             &mouse_threshold2, ((INT *)pvParam)[1], fWinIni);
1201             save_int_param( SPI_SETMOUSE_REGKEY, SPI_SETMOUSE_VALNAME3,
1202                             &mouse_speed, ((INT *)pvParam)[2], fWinIni);
1203         }
1204         break;
1205     }
1206
1207     case SPI_GETBORDER:
1208         ret = get_twips_param( SPI_SETBORDER_IDX,
1209                                SPI_SETBORDER_REGKEY,
1210                                SPI_SETBORDER_VALNAME,
1211                                &border, pvParam );
1212         if( *(INT*)pvParam < 1) *(INT*)pvParam = 1; 
1213         break;
1214
1215     case SPI_SETBORDER:
1216         nonclient_metrics.iBorderWidth = uiParam > 0 ? uiParam : 1;
1217         /* raw value goes to registry */
1218         ret = set_uint_param( SPI_SETBORDER_IDX,
1219                               SPI_SETBORDER_REGKEY,
1220                               SPI_SETBORDER_VALNAME,
1221                               &border, uiParam, fWinIni );
1222         break;
1223
1224     case SPI_GETKEYBOARDSPEED:
1225         ret = get_uint_param( SPI_SETKEYBOARDSPEED_IDX,
1226                               SPI_SETKEYBOARDSPEED_REGKEY,
1227                               SPI_SETKEYBOARDSPEED_VALNAME,
1228                               &keyboard_speed, pvParam );
1229         break;
1230
1231     case SPI_SETKEYBOARDSPEED:
1232         if (uiParam > 31) uiParam = 31;
1233         ret = set_uint_param( SPI_SETKEYBOARDSPEED_IDX,
1234                               SPI_SETKEYBOARDSPEED_REGKEY,
1235                               SPI_SETKEYBOARDSPEED_VALNAME,
1236                               &keyboard_speed, uiParam, fWinIni );
1237         break;
1238
1239     /* not implemented in Windows */
1240     WINE_SPI_WARN(SPI_LANGDRIVER);              /*     12 */
1241
1242     case SPI_ICONHORIZONTALSPACING:
1243         if (pvParam != NULL)
1244         {
1245             ret = get_twips_param( SPI_ICONHORIZONTALSPACING_IDX,
1246                                    SPI_ICONHORIZONTALSPACING_REGKEY,
1247                                    SPI_ICONHORIZONTALSPACING_VALNAME,
1248                                    (UINT*)&icon_metrics.iHorzSpacing, pvParam );
1249         }
1250         else
1251         {
1252             if (uiParam < 32) uiParam = 32;
1253             ret = set_uint_param( SPI_ICONHORIZONTALSPACING_IDX,
1254                                   SPI_ICONHORIZONTALSPACING_REGKEY,
1255                                   SPI_ICONHORIZONTALSPACING_VALNAME,
1256                                   (UINT*)&icon_metrics.iHorzSpacing, uiParam, fWinIni );
1257         }
1258         break;
1259
1260     case SPI_GETSCREENSAVETIMEOUT:
1261         ret = get_uint_param( SPI_SETSCREENSAVETIMEOUT_IDX,
1262                               SPI_SETSCREENSAVETIMEOUT_REGKEY,
1263                               SPI_SETSCREENSAVETIMEOUT_VALNAME,
1264                               &screensave_timeout, pvParam );
1265         break;
1266
1267     case SPI_SETSCREENSAVETIMEOUT:
1268         ret = set_uint_param( SPI_SETSCREENSAVETIMEOUT_IDX,
1269                               SPI_SETSCREENSAVETIMEOUT_REGKEY,
1270                               SPI_SETSCREENSAVETIMEOUT_VALNAME,
1271                               &screensave_timeout, uiParam, fWinIni );
1272         break;
1273
1274     case SPI_GETSCREENSAVEACTIVE:               /*     16 */
1275         if (!pvParam) return FALSE;
1276         *(BOOL *)pvParam = USER_Driver->pGetScreenSaveActive();
1277         break;
1278
1279     case SPI_SETSCREENSAVEACTIVE:               /*     17 */
1280     {
1281         WCHAR buf[12];
1282
1283         wsprintfW(buf, CSu, uiParam);
1284         USER_Driver->pSetScreenSaveActive( uiParam );
1285         /* saved value does not affect Wine */
1286         SYSPARAMS_Save( SPI_SETSCREENSAVEACTIVE_REGKEY,
1287                         SPI_SETSCREENSAVEACTIVE_VALNAME,
1288                         buf, fWinIni );
1289         break;
1290     }
1291
1292     case SPI_GETGRIDGRANULARITY:
1293         ret = get_uint_param( SPI_SETGRIDGRANULARITY_IDX,
1294                               SPI_SETGRIDGRANULARITY_REGKEY,
1295                               SPI_SETGRIDGRANULARITY_VALNAME,
1296                               &grid_granularity, pvParam );
1297         break;
1298
1299     case SPI_SETGRIDGRANULARITY:
1300         ret = set_uint_param( SPI_SETGRIDGRANULARITY_IDX,
1301                               SPI_SETGRIDGRANULARITY_REGKEY,
1302                               SPI_SETGRIDGRANULARITY_VALNAME,
1303                               &grid_granularity, uiParam, fWinIni );
1304         break;
1305
1306     case SPI_SETDESKWALLPAPER:                  /*     20 */
1307         if (!pvParam || !SetDeskWallPaper( (LPSTR)pvParam )) return FALSE;
1308         SYSPARAMS_Save(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, pvParam, fWinIni);
1309         break;
1310         
1311     case SPI_SETDESKPATTERN:                    /*     21 */
1312         /* FIXME: the ability to specify a pattern in pvParam
1313            doesn't seem to be documented for Win32 */
1314         if ((INT16)uiParam == -1)
1315         {
1316             WCHAR buf[256];
1317             GetProfileStringW( Desktop, Pattern,
1318                                defPattern,
1319                                buf, sizeof(buf)/sizeof(WCHAR) );
1320             ret = DESKTOP_SetPattern( buf );
1321         } else
1322             ret = DESKTOP_SetPattern( (LPWSTR)pvParam );
1323         break;
1324
1325     case SPI_GETKEYBOARDDELAY:
1326         ret = get_uint_param( SPI_SETKEYBOARDDELAY_IDX,
1327                               SPI_SETKEYBOARDDELAY_REGKEY,
1328                               SPI_SETKEYBOARDDELAY_VALNAME,
1329                               &keyboard_delay, pvParam );
1330         break;
1331
1332     case SPI_SETKEYBOARDDELAY:
1333         ret = set_uint_param( SPI_SETKEYBOARDDELAY_IDX,
1334                               SPI_SETKEYBOARDDELAY_REGKEY,
1335                               SPI_SETKEYBOARDDELAY_VALNAME,
1336                               &keyboard_delay, uiParam, fWinIni );
1337         break;
1338
1339     case SPI_ICONVERTICALSPACING:
1340         if (pvParam != NULL)
1341         {
1342             ret = get_twips_param( SPI_ICONVERTICALSPACING_IDX,
1343                                    SPI_ICONVERTICALSPACING_REGKEY,
1344                                    SPI_ICONVERTICALSPACING_VALNAME,
1345                                    (UINT*)&icon_metrics.iVertSpacing, pvParam );
1346             if( icon_metrics.iVertSpacing < 32) 
1347                 icon_metrics.iVertSpacing = 32;
1348         }
1349         else
1350         {
1351             if (uiParam < 32) uiParam = 32;
1352             ret = set_uint_param( SPI_ICONVERTICALSPACING_IDX,
1353                                   SPI_ICONVERTICALSPACING_REGKEY,
1354                                   SPI_ICONVERTICALSPACING_VALNAME,
1355                                   (UINT*)&icon_metrics.iVertSpacing, uiParam, fWinIni );
1356         }
1357         break;
1358
1359     case SPI_GETICONTITLEWRAP:
1360         ret = get_bool_param( SPI_SETICONTITLEWRAP_IDX,
1361                               SPI_SETICONTITLEWRAP_REGKEY1,
1362                               SPI_SETICONTITLEWRAP_VALNAME,
1363                               &icon_metrics.iTitleWrap, pvParam );
1364         break;
1365
1366     case SPI_SETICONTITLEWRAP:
1367         ret = set_bool_param_mirrored( SPI_SETICONTITLEWRAP_IDX,
1368                                        SPI_SETICONTITLEWRAP_REGKEY1,
1369                                        SPI_SETICONTITLEWRAP_REGKEY2,
1370                                        SPI_SETICONTITLEWRAP_VALNAME,
1371                                        &icon_metrics.iTitleWrap, uiParam, fWinIni );
1372         break;
1373
1374     case SPI_GETMENUDROPALIGNMENT:
1375         ret = get_uint_param( SPI_SETMENUDROPALIGNMENT_IDX,
1376                               SPI_SETMENUDROPALIGNMENT_REGKEY1,
1377                               SPI_SETMENUDROPALIGNMENT_VALNAME,
1378                               &menu_drop_alignment, pvParam );
1379         break;
1380
1381     case SPI_SETMENUDROPALIGNMENT:
1382         ret = set_uint_param_mirrored( SPI_SETMENUDROPALIGNMENT_IDX,
1383                                        SPI_SETMENUDROPALIGNMENT_REGKEY1,
1384                                        SPI_SETMENUDROPALIGNMENT_REGKEY2,
1385                                        SPI_SETMENUDROPALIGNMENT_VALNAME,
1386                                        &menu_drop_alignment, uiParam, fWinIni );
1387         break;
1388
1389     case SPI_SETDOUBLECLKWIDTH:
1390         ret = set_uint_param_mirrored( SPI_SETDOUBLECLKWIDTH_IDX,
1391                                        SPI_SETDOUBLECLKWIDTH_REGKEY1,
1392                                        SPI_SETDOUBLECLKWIDTH_REGKEY2,
1393                                        SPI_SETDOUBLECLKWIDTH_VALNAME,
1394                                        &double_click_width, uiParam, fWinIni );
1395         break;
1396
1397     case SPI_SETDOUBLECLKHEIGHT:
1398         ret = set_uint_param_mirrored( SPI_SETDOUBLECLKHEIGHT_IDX,
1399                                        SPI_SETDOUBLECLKHEIGHT_REGKEY1,
1400                                        SPI_SETDOUBLECLKHEIGHT_REGKEY2,
1401                                        SPI_SETDOUBLECLKHEIGHT_VALNAME,
1402                                        &double_click_height, uiParam, fWinIni );
1403         break;
1404
1405     case SPI_GETICONTITLELOGFONT:
1406     {
1407         LOGFONTW lfDefault;
1408
1409         if (!pvParam) return FALSE;
1410
1411         spi_idx = SPI_SETICONTITLELOGFONT_IDX;
1412         if (!spi_loaded[spi_idx])
1413         {
1414             if (!reg_get_logfont( SPI_SETICONTITLELOGFONT_REGKEY,
1415                                   SPI_SETICONTITLELOGFONT_VALNAME, &icon_metrics.lfFont ))
1416             {
1417                 /*
1418                  * The 'default GDI fonts' seems to be returned.
1419                  * If a returned font is not a correct font in your environment,
1420                  * please try to fix objects/gdiobj.c at first.
1421                  */
1422                 GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(LOGFONTW), &lfDefault );
1423
1424                 GetProfileStringW( Desktop, IconTitleFaceName,
1425                                    lfDefault.lfFaceName,
1426                                    icon_metrics.lfFont.lfFaceName,
1427                                    LF_FACESIZE );
1428                 icon_metrics.lfFont.lfHeight = -GetProfileIntW( Desktop, IconTitleSize, 11 );
1429                 icon_metrics.lfFont.lfWidth = 0;
1430                 icon_metrics.lfFont.lfEscapement = icon_metrics.lfFont.lfOrientation = 0;
1431                 icon_metrics.lfFont.lfWeight = FW_NORMAL;
1432                 icon_metrics.lfFont.lfItalic = FALSE;
1433                 icon_metrics.lfFont.lfStrikeOut = FALSE;
1434                 icon_metrics.lfFont.lfUnderline = FALSE;
1435                 icon_metrics.lfFont.lfCharSet = lfDefault.lfCharSet; /* at least 'charset' should not be hard-coded */
1436                 icon_metrics.lfFont.lfOutPrecision = OUT_DEFAULT_PRECIS;
1437                 icon_metrics.lfFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1438                 icon_metrics.lfFont.lfQuality = DEFAULT_QUALITY;
1439                 icon_metrics.lfFont.lfPitchAndFamily = DEFAULT_PITCH;
1440                 spi_loaded[spi_idx] = TRUE;
1441             }
1442         }
1443         *(LOGFONTW *)pvParam = icon_metrics.lfFont;
1444         break;
1445     }
1446
1447     case SPI_SETDOUBLECLICKTIME:
1448         ret = set_uint_param( SPI_SETDOUBLECLICKTIME_IDX,
1449                               SPI_SETDOUBLECLICKTIME_REGKEY,
1450                               SPI_SETDOUBLECLICKTIME_VALNAME,
1451                               &double_click_time, uiParam, fWinIni );
1452         break;
1453
1454     case SPI_SETMOUSEBUTTONSWAP:
1455         ret = set_bool_param( SPI_SETMOUSEBUTTONSWAP_IDX,
1456                               SPI_SETMOUSEBUTTONSWAP_REGKEY,
1457                               SPI_SETMOUSEBUTTONSWAP_VALNAME,
1458                               &swap_buttons, uiParam, fWinIni );
1459         break;
1460
1461     case SPI_SETICONTITLELOGFONT:               /*     34 */
1462         if( uiParam == sizeof( ICONMETRICSW)) {
1463             ret = SYSPARAMS_SaveLogFont( SPI_SETICONTITLELOGFONT_REGKEY,
1464                     SPI_SETICONTITLELOGFONT_VALNAME, (LOGFONTW *)pvParam, fWinIni);
1465             if( ret) {
1466                 icon_metrics.lfFont = *(LOGFONTW *)pvParam;
1467                 spi_loaded[SPI_SETICONTITLELOGFONT_IDX] = TRUE;
1468             }
1469         } else
1470             ret = FALSE;
1471         break;
1472
1473     case SPI_GETFASTTASKSWITCH:                 /*     35 */
1474         if (!pvParam) return FALSE;
1475         *(BOOL *)pvParam = 1;
1476         break;
1477
1478     case SPI_SETFASTTASKSWITCH:                 /*     36 */
1479         /* the action is disabled */
1480         ret = FALSE;
1481         break;
1482
1483     case SPI_SETDRAGFULLWINDOWS:
1484         ret = set_bool_param( SPI_SETDRAGFULLWINDOWS_IDX,
1485                               SPI_SETDRAGFULLWINDOWS_REGKEY,
1486                               SPI_SETDRAGFULLWINDOWS_VALNAME,
1487                               &drag_full_windows, uiParam, fWinIni );
1488         break;
1489
1490     case SPI_GETDRAGFULLWINDOWS:
1491         ret = get_bool_param( SPI_SETDRAGFULLWINDOWS_IDX,
1492                               SPI_SETDRAGFULLWINDOWS_REGKEY,
1493                               SPI_SETDRAGFULLWINDOWS_VALNAME,
1494                               &drag_full_windows, pvParam );
1495         break;
1496
1497     case SPI_GETNONCLIENTMETRICS:
1498     {
1499         LPNONCLIENTMETRICSW lpnm = pvParam;
1500
1501         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
1502
1503         if (lpnm && lpnm->cbSize == sizeof(NONCLIENTMETRICSW))
1504             memcpy( lpnm, &nonclient_metrics, sizeof(*lpnm) );
1505         else
1506             ret = FALSE;
1507         break;
1508     }
1509
1510     case SPI_SETNONCLIENTMETRICS:
1511     {
1512         LPNONCLIENTMETRICSW lpnm = pvParam;
1513
1514         if (lpnm && lpnm->cbSize == sizeof(NONCLIENTMETRICSW))
1515         {
1516             NONCLIENTMETRICSW ncm;
1517             ret = set_uint_param( SPI_SETBORDER_IDX,
1518                     SPI_SETBORDER_REGKEY, SPI_SETBORDER_VALNAME,
1519                     &border, lpnm->iBorderWidth, fWinIni );
1520             if( ret) ret = save_int_param( METRICS_REGKEY,
1521                     METRICS_SCROLLWIDTH_VALNAME, NULL,
1522                     lpnm->iScrollWidth, fWinIni );
1523             if( ret) ret = save_int_param( METRICS_REGKEY,
1524                     METRICS_SCROLLHEIGHT_VALNAME, NULL,
1525                     lpnm->iScrollHeight, fWinIni );
1526             if( ret) ret = save_int_param( METRICS_REGKEY,
1527                     METRICS_CAPTIONWIDTH_VALNAME, NULL,
1528                     lpnm->iCaptionWidth, fWinIni );
1529             if( ret) ret = save_int_param( METRICS_REGKEY,
1530                     METRICS_CAPTIONHEIGHT_VALNAME, NULL,
1531                     lpnm->iCaptionHeight, fWinIni );
1532             if( ret) ret = save_int_param( METRICS_REGKEY,
1533                     METRICS_SMCAPTIONWIDTH_VALNAME, NULL,
1534                     lpnm->iSmCaptionWidth, fWinIni );
1535             if( ret) ret = save_int_param( METRICS_REGKEY,
1536                     METRICS_SMCAPTIONHEIGHT_VALNAME, NULL,
1537                     lpnm->iSmCaptionHeight, fWinIni );
1538             if( ret) ret = save_int_param( METRICS_REGKEY,
1539                     METRICS_MENUWIDTH_VALNAME, NULL,
1540                     lpnm->iMenuWidth, fWinIni );
1541             if( ret) ret = save_int_param( METRICS_REGKEY,
1542                     METRICS_MENUHEIGHT_VALNAME, NULL,
1543                     lpnm->iMenuHeight, fWinIni );
1544             if( ret) ret = SYSPARAMS_SaveLogFont(
1545                     METRICS_REGKEY, METRICS_MENULOGFONT_VALNAME,
1546                     &lpnm->lfMenuFont, fWinIni);
1547             if( ret) ret = SYSPARAMS_SaveLogFont(
1548                     METRICS_REGKEY, METRICS_CAPTIONLOGFONT_VALNAME,
1549                     &lpnm->lfCaptionFont, fWinIni);
1550             if( ret) ret = SYSPARAMS_SaveLogFont(
1551                     METRICS_REGKEY, METRICS_SMCAPTIONLOGFONT_VALNAME,
1552                     &lpnm->lfSmCaptionFont, fWinIni);
1553             if( ret) ret = SYSPARAMS_SaveLogFont(
1554                     METRICS_REGKEY, METRICS_STATUSLOGFONT_VALNAME,
1555                     &lpnm->lfStatusFont, fWinIni);
1556             if( ret) ret = SYSPARAMS_SaveLogFont(
1557                     METRICS_REGKEY, METRICS_MESSAGELOGFONT_VALNAME,
1558                     &lpnm->lfMessageFont, fWinIni);
1559             if( ret) {
1560                 memcpy( &ncm, lpnm, sizeof(nonclient_metrics) );
1561                 normalize_nonclientmetrics( &ncm);
1562                 memcpy( &nonclient_metrics, &ncm, sizeof(nonclient_metrics) );
1563                 spi_loaded[SPI_NONCLIENTMETRICS_IDX] = TRUE;
1564             }
1565         }
1566         break;
1567     }
1568
1569     case SPI_GETMINIMIZEDMETRICS:
1570     {
1571         MINIMIZEDMETRICS * lpMm = pvParam;
1572         if (lpMm && lpMm->cbSize == sizeof(*lpMm)) {
1573             if( spi_loaded[SPI_MINIMIZEDMETRICS_IDX]) load_minimized_metrics();
1574             memcpy( lpMm, &minimized_metrics, sizeof(*lpMm) );
1575         } else
1576             ret = FALSE;
1577         break;
1578     }
1579
1580     case SPI_SETMINIMIZEDMETRICS:
1581     {
1582         MINIMIZEDMETRICS * lpMm = pvParam;
1583         if (lpMm && lpMm->cbSize == sizeof(*lpMm)) {
1584             ret = save_int_param( METRICS_REGKEY, METRICS_MINWIDTH_VALNAME,
1585                                   &minimized_metrics.iWidth, max( lpMm->iWidth, 0), fWinIni);
1586             if( ret) ret = save_int_param( METRICS_REGKEY,
1587                                            METRICS_MINHORZGAP_VALNAME, &minimized_metrics.iHorzGap,
1588                                            max( lpMm->iHorzGap, 0), fWinIni);
1589             if( ret) ret = save_int_param( METRICS_REGKEY,
1590                                            METRICS_MINVERTGAP_VALNAME, &minimized_metrics.iVertGap,
1591                                            max( lpMm->iVertGap, 0), fWinIni);
1592             if( ret) ret = save_int_param( METRICS_REGKEY,
1593                                            METRICS_MINARRANGE_VALNAME, &minimized_metrics.iArrange,
1594                                            0x0f & lpMm->iArrange, fWinIni);
1595             if( ret) spi_loaded[SPI_MINIMIZEDMETRICS_IDX] = TRUE;
1596         } else
1597             ret = FALSE;
1598         break;
1599     }
1600
1601     case SPI_GETICONMETRICS:
1602     {
1603         LPICONMETRICSW lpIcon = pvParam;
1604         if(lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1605         {
1606             SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0,
1607                                    &lpIcon->iHorzSpacing, FALSE );
1608             SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0,
1609                                    &lpIcon->iVertSpacing, FALSE );
1610             SystemParametersInfoW( SPI_GETICONTITLEWRAP, 0,
1611                                    &lpIcon->iTitleWrap, FALSE );
1612             SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0,
1613                                    &lpIcon->lfFont, FALSE );
1614         }
1615         else
1616         {
1617             ret = FALSE;
1618         }
1619         break;
1620     }
1621
1622     case SPI_SETICONMETRICS:
1623     {
1624         LPICONMETRICSW lpIcon = pvParam;
1625         if (lpIcon && lpIcon->cbSize == sizeof(*lpIcon)) {
1626             ret = set_int_param( SPI_ICONVERTICALSPACING_IDX,
1627                                  SPI_ICONVERTICALSPACING_REGKEY,
1628                                  SPI_ICONVERTICALSPACING_VALNAME,
1629                                  &icon_metrics.iVertSpacing,
1630                                  lpIcon->iVertSpacing, fWinIni);
1631             if( ret) {
1632                 ret = set_int_param( SPI_ICONHORIZONTALSPACING_IDX,
1633                                      SPI_ICONHORIZONTALSPACING_REGKEY,
1634                                      SPI_ICONHORIZONTALSPACING_VALNAME,
1635                                      &icon_metrics.iHorzSpacing,
1636                                      lpIcon->iHorzSpacing, fWinIni );
1637             }
1638             if( ret) {
1639                 ret = set_bool_param_mirrored( SPI_SETICONTITLEWRAP_IDX,
1640                     SPI_SETICONTITLEWRAP_REGKEY1, SPI_SETICONTITLEWRAP_REGKEY2,
1641                     SPI_SETICONTITLEWRAP_VALNAME, &icon_metrics.iTitleWrap,
1642                     lpIcon->iTitleWrap, fWinIni );
1643             }
1644             if( ret) ret = SYSPARAMS_SaveLogFont( SPI_SETICONTITLELOGFONT_REGKEY,
1645                     SPI_SETICONTITLELOGFONT_VALNAME, &lpIcon->lfFont, fWinIni);
1646             if( ret) {
1647                 icon_metrics.lfFont = lpIcon->lfFont;
1648                 spi_loaded[SPI_SETICONTITLELOGFONT_IDX] = TRUE;
1649             }
1650         } else
1651             ret = FALSE;
1652         break;
1653     }
1654
1655     case SPI_SETWORKAREA:                       /*     47  WINVER >= 0x400 */
1656     {
1657         if (!pvParam) return FALSE;
1658
1659         spi_idx = SPI_SETWORKAREA_IDX;
1660         CopyRect( &work_area, (RECT *)pvParam );
1661         spi_loaded[spi_idx] = TRUE;
1662         break;
1663     }
1664
1665     case SPI_GETWORKAREA:                       /*     48  WINVER >= 0x400 */
1666     {
1667         if (!pvParam) return FALSE;
1668
1669         spi_idx = SPI_SETWORKAREA_IDX;
1670         if (!spi_loaded[spi_idx])
1671         {
1672             SetRect( &work_area, 0, 0,
1673                      GetSystemMetrics( SM_CXSCREEN ),
1674                      GetSystemMetrics( SM_CYSCREEN ) );
1675             spi_loaded[spi_idx] = TRUE;
1676         }
1677         CopyRect( (RECT *)pvParam, &work_area );
1678
1679         break;
1680     }
1681
1682     WINE_SPI_FIXME(SPI_SETPENWINDOWS);          /*     49  WINVER >= 0x400 */
1683
1684     case SPI_GETFILTERKEYS:                     /*     50 */
1685     {
1686         LPFILTERKEYS lpFilterKeys = (LPFILTERKEYS)pvParam;
1687         WARN("SPI_GETFILTERKEYS not fully implemented\n");
1688         if (lpFilterKeys && lpFilterKeys->cbSize == sizeof(FILTERKEYS))
1689         {
1690             /* Indicate that no FilterKeys feature available */
1691             lpFilterKeys->dwFlags = 0;
1692             lpFilterKeys->iWaitMSec = 0;
1693             lpFilterKeys->iDelayMSec = 0;
1694             lpFilterKeys->iRepeatMSec = 0;
1695             lpFilterKeys->iBounceMSec = 0;
1696          }
1697         else
1698         {
1699             ret = FALSE;
1700         }
1701         break;
1702     }
1703     WINE_SPI_FIXME(SPI_SETFILTERKEYS);          /*     51 */
1704
1705     case SPI_GETTOGGLEKEYS:                     /*     52 */
1706     {
1707         LPTOGGLEKEYS lpToggleKeys = (LPTOGGLEKEYS)pvParam;
1708         WARN("SPI_GETTOGGLEKEYS not fully implemented\n");
1709         if (lpToggleKeys && lpToggleKeys->cbSize == sizeof(TOGGLEKEYS))
1710         {
1711             /* Indicate that no ToggleKeys feature available */
1712             lpToggleKeys->dwFlags = 0;
1713         }
1714         else
1715         {
1716             ret = FALSE;
1717         }
1718         break;
1719     }
1720     WINE_SPI_FIXME(SPI_SETTOGGLEKEYS);          /*     53 */
1721
1722     case SPI_GETMOUSEKEYS:                      /*     54 */
1723     {
1724         LPMOUSEKEYS lpMouseKeys = (LPMOUSEKEYS)pvParam;
1725         WARN("SPI_GETMOUSEKEYS not fully implemented\n");
1726         if (lpMouseKeys && lpMouseKeys->cbSize == sizeof(MOUSEKEYS))
1727         {
1728             /* Indicate that no MouseKeys feature available */
1729             lpMouseKeys->dwFlags = 0;
1730             lpMouseKeys->iMaxSpeed = 360;
1731             lpMouseKeys->iTimeToMaxSpeed = 1000;
1732             lpMouseKeys->iCtrlSpeed = 0;
1733             lpMouseKeys->dwReserved1 = 0;
1734             lpMouseKeys->dwReserved2 = 0;
1735         }
1736         else
1737         {
1738             ret = FALSE;
1739         }
1740         break;
1741     }
1742     WINE_SPI_FIXME(SPI_SETMOUSEKEYS);           /*     55 */
1743
1744     case SPI_GETSHOWSOUNDS:
1745         ret = get_bool_param( SPI_SETSHOWSOUNDS_IDX,
1746                               SPI_SETSHOWSOUNDS_REGKEY,
1747                               SPI_SETSHOWSOUNDS_VALNAME,
1748                               &show_sounds, pvParam );
1749         break;
1750
1751     case SPI_SETSHOWSOUNDS:
1752         ret = set_bool_param( SPI_SETSHOWSOUNDS_IDX,
1753                               SPI_SETSHOWSOUNDS_REGKEY,
1754                               SPI_SETSHOWSOUNDS_VALNAME,
1755                               &show_sounds, uiParam, fWinIni );
1756         break;
1757
1758     case SPI_GETSTICKYKEYS:                     /*     58 */
1759     {
1760         LPSTICKYKEYS lpStickyKeys = (LPSTICKYKEYS)pvParam;
1761         WARN("SPI_GETSTICKYKEYS not fully implemented\n");
1762         if (lpStickyKeys && lpStickyKeys->cbSize == sizeof(STICKYKEYS))
1763         {
1764             /* Indicate that no StickyKeys feature available */
1765             lpStickyKeys->dwFlags = 0;
1766         }
1767         else
1768         {
1769             ret = FALSE;
1770         }
1771         break;
1772     }
1773     WINE_SPI_FIXME(SPI_SETSTICKYKEYS);          /*     59 */
1774
1775     case SPI_GETACCESSTIMEOUT:                  /*     60 */
1776     {
1777         LPACCESSTIMEOUT lpAccessTimeout = (LPACCESSTIMEOUT)pvParam;
1778         WARN("SPI_GETACCESSTIMEOUT not fully implemented\n");
1779         if (lpAccessTimeout && lpAccessTimeout->cbSize == sizeof(ACCESSTIMEOUT))
1780         {
1781             /* Indicate that no accessibility features timeout is available */
1782             lpAccessTimeout->dwFlags = 0;
1783             lpAccessTimeout->iTimeOutMSec = 0;
1784         }
1785         else
1786         {
1787             ret = FALSE;
1788         }
1789         break;
1790     }
1791     WINE_SPI_FIXME(SPI_SETACCESSTIMEOUT);       /*     61 */
1792
1793     case SPI_GETSERIALKEYS:                     /*     62  WINVER >= 0x400 */
1794     {
1795         LPSERIALKEYSW lpSerialKeysW = (LPSERIALKEYSW)pvParam;
1796         WARN("SPI_GETSERIALKEYS not fully implemented\n");
1797         if (lpSerialKeysW && lpSerialKeysW->cbSize == sizeof(SERIALKEYSW))
1798         {
1799             /* Indicate that no SerialKeys feature available */
1800             lpSerialKeysW->dwFlags = 0;
1801             lpSerialKeysW->lpszActivePort = NULL;
1802             lpSerialKeysW->lpszPort = NULL;
1803             lpSerialKeysW->iBaudRate = 0;
1804             lpSerialKeysW->iPortState = 0;
1805         }
1806         else
1807         {
1808             ret = FALSE;
1809         }
1810         break;
1811     }
1812     WINE_SPI_FIXME(SPI_SETSERIALKEYS);          /*     63  WINVER >= 0x400 */
1813
1814     case SPI_GETSOUNDSENTRY:                    /*     64 */
1815     {
1816         LPSOUNDSENTRYW lpSoundSentryW = (LPSOUNDSENTRYW)pvParam;
1817         WARN("SPI_GETSOUNDSENTRY not fully implemented\n");
1818         if (lpSoundSentryW && lpSoundSentryW->cbSize == sizeof(SOUNDSENTRYW))
1819         {
1820             /* Indicate that no SoundSentry feature available */
1821             lpSoundSentryW->dwFlags = 0;
1822             lpSoundSentryW->iFSTextEffect = 0;
1823             lpSoundSentryW->iFSTextEffectMSec = 0;
1824             lpSoundSentryW->iFSTextEffectColorBits = 0;
1825             lpSoundSentryW->iFSGrafEffect = 0;
1826             lpSoundSentryW->iFSGrafEffectMSec = 0;
1827             lpSoundSentryW->iFSGrafEffectColor = 0;
1828             lpSoundSentryW->iWindowsEffect = 0;
1829             lpSoundSentryW->iWindowsEffectMSec = 0;
1830             lpSoundSentryW->lpszWindowsEffectDLL = 0;
1831             lpSoundSentryW->iWindowsEffectOrdinal = 0;
1832         }
1833         else
1834         {
1835             ret = FALSE;
1836         }
1837         break;
1838     }
1839     WINE_SPI_FIXME(SPI_SETSOUNDSENTRY);         /*     65 */
1840
1841     case SPI_GETHIGHCONTRAST:                   /*     66  WINVER >= 0x400 */
1842     {
1843         LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)pvParam;
1844         WARN("SPI_GETHIGHCONTRAST not fully implemented\n");
1845         if (lpHighContrastW && lpHighContrastW->cbSize == sizeof(HIGHCONTRASTW))
1846         {
1847             /* Indicate that no high contrast feature available */
1848             lpHighContrastW->dwFlags = 0;
1849             lpHighContrastW->lpszDefaultScheme = NULL;
1850         }
1851         else
1852         {
1853             ret = FALSE;
1854         }
1855         break;
1856     }
1857     WINE_SPI_FIXME(SPI_SETHIGHCONTRAST);        /*     67  WINVER >= 0x400 */
1858
1859     case SPI_GETKEYBOARDPREF:
1860         ret = get_bool_param( SPI_SETKEYBOARDPREF_IDX,
1861                               SPI_SETKEYBOARDPREF_REGKEY,
1862                               SPI_SETKEYBOARDPREF_VALNAME,
1863                               &keyboard_pref, pvParam );
1864         break;
1865
1866     case SPI_SETKEYBOARDPREF:
1867         ret = set_bool_param( SPI_SETKEYBOARDPREF_IDX,
1868                               SPI_SETKEYBOARDPREF_REGKEY,
1869                               SPI_SETKEYBOARDPREF_VALNAME,
1870                               &keyboard_pref, uiParam, fWinIni );
1871         break;
1872
1873     case SPI_GETSCREENREADER:
1874         ret = get_bool_param( SPI_SETSCREENREADER_IDX,
1875                               SPI_SETSCREENREADER_REGKEY,
1876                               SPI_SETSCREENREADER_VALNAME,
1877                               &screen_reader, pvParam );
1878         break;
1879
1880     case SPI_SETSCREENREADER:
1881         ret = set_bool_param( SPI_SETSCREENREADER_IDX,
1882                               SPI_SETSCREENREADER_REGKEY,
1883                               SPI_SETSCREENREADER_VALNAME,
1884                               &screen_reader, uiParam, fWinIni );
1885         break;
1886
1887     case SPI_GETANIMATION:                      /*     72  WINVER >= 0x400 */
1888     {
1889         LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)pvParam;
1890
1891         /* Tell it "disabled" */
1892         if (lpAnimInfo && lpAnimInfo->cbSize == sizeof(ANIMATIONINFO))
1893             lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1894         else
1895             ret = FALSE;
1896         break;
1897     }
1898     WINE_SPI_WARN(SPI_SETANIMATION);            /*     73  WINVER >= 0x400 */
1899
1900     case SPI_GETFONTSMOOTHING:
1901         ret = get_uint_param( SPI_SETFONTSMOOTHING_IDX,
1902                               SPI_SETFONTSMOOTHING_REGKEY,
1903                               SPI_SETFONTSMOOTHING_VALNAME,
1904                               &font_smoothing, pvParam );
1905         break;
1906
1907     case SPI_SETFONTSMOOTHING:
1908         ret = set_uint_param( SPI_SETFONTSMOOTHING_IDX,
1909                               SPI_SETFONTSMOOTHING_REGKEY,
1910                               SPI_SETFONTSMOOTHING_VALNAME,
1911                               &font_smoothing, uiParam, fWinIni );
1912         break;
1913
1914     WINE_SPI_FIXME(SPI_SETDRAGWIDTH);           /*     76  WINVER >= 0x400 */
1915     WINE_SPI_FIXME(SPI_SETDRAGHEIGHT);          /*     77  WINVER >= 0x400 */
1916
1917     WINE_SPI_FIXME(SPI_SETHANDHELD);            /*     78  WINVER >= 0x400 */
1918
1919     WINE_SPI_FIXME(SPI_GETLOWPOWERTIMEOUT);     /*     79  WINVER >= 0x400 */
1920     WINE_SPI_FIXME(SPI_GETPOWEROFFTIMEOUT);     /*     80  WINVER >= 0x400 */
1921     WINE_SPI_FIXME(SPI_SETLOWPOWERTIMEOUT);     /*     81  WINVER >= 0x400 */
1922     WINE_SPI_FIXME(SPI_SETPOWEROFFTIMEOUT);     /*     82  WINVER >= 0x400 */
1923
1924     case SPI_GETLOWPOWERACTIVE:
1925         ret = get_bool_param( SPI_SETLOWPOWERACTIVE_IDX,
1926                               SPI_SETLOWPOWERACTIVE_REGKEY,
1927                               SPI_SETLOWPOWERACTIVE_VALNAME,
1928                               &lowpoweractive, pvParam );
1929         break;
1930
1931     case SPI_GETPOWEROFFACTIVE:
1932         ret = get_bool_param( SPI_SETPOWEROFFACTIVE_IDX,
1933                               SPI_SETPOWEROFFACTIVE_REGKEY,
1934                               SPI_SETPOWEROFFACTIVE_VALNAME,
1935                               &poweroffactive, pvParam );
1936         break;
1937
1938     case SPI_SETLOWPOWERACTIVE:
1939         ret = set_bool_param( SPI_SETLOWPOWERACTIVE_IDX,
1940                               SPI_SETLOWPOWERACTIVE_REGKEY,
1941                               SPI_SETLOWPOWERACTIVE_VALNAME,
1942                               &lowpoweractive, uiParam, fWinIni );
1943         break;
1944
1945     case SPI_SETPOWEROFFACTIVE:
1946         ret = set_bool_param( SPI_SETPOWEROFFACTIVE_IDX,
1947                               SPI_SETPOWEROFFACTIVE_REGKEY,
1948                               SPI_SETPOWEROFFACTIVE_VALNAME,
1949                               &poweroffactive, uiParam, fWinIni );
1950         break;
1951
1952     WINE_SPI_FIXME(SPI_SETCURSORS);             /*     87  WINVER >= 0x400 */
1953     WINE_SPI_FIXME(SPI_SETICONS);               /*     88  WINVER >= 0x400 */
1954
1955     case SPI_GETDEFAULTINPUTLANG:       /*     89  WINVER >= 0x400 */
1956         ret = GetKeyboardLayout(0) ? TRUE : FALSE;
1957         break;
1958
1959     WINE_SPI_FIXME(SPI_SETDEFAULTINPUTLANG);    /*     90  WINVER >= 0x400 */
1960
1961     WINE_SPI_FIXME(SPI_SETLANGTOGGLE);          /*     91  WINVER >= 0x400 */
1962
1963     case SPI_GETWINDOWSEXTENSION:               /*     92  WINVER >= 0x400 */
1964         WARN("pretend no support for Win9x Plus! for now.\n");
1965         ret = FALSE; /* yes, this is the result value */
1966         break;
1967
1968     WINE_SPI_FIXME(SPI_SETMOUSETRAILS);         /*     93  WINVER >= 0x400 */
1969     WINE_SPI_FIXME(SPI_GETMOUSETRAILS);         /*     94  WINVER >= 0x400 */
1970     WINE_SPI_FIXME(SPI_GETSNAPTODEFBUTTON);     /*     95  WINVER >= 0x400 */
1971     WINE_SPI_FIXME(SPI_SETSNAPTODEFBUTTON);     /*     96  WINVER >= 0x400 */
1972
1973     case SPI_SETSCREENSAVERRUNNING:
1974         ret = set_bool_param( SPI_SETSCREENSAVERRUNNING_IDX,
1975                               SPI_SETSCREENSAVERRUNNING_REGKEY,
1976                               SPI_SETSCREENSAVERRUNNING_VALNAME,
1977                               &screensaver_running, uiParam, fWinIni );
1978         break;
1979
1980     case SPI_GETMOUSEHOVERWIDTH:
1981         ret = get_uint_param( SPI_SETMOUSEHOVERWIDTH_IDX,
1982                               SPI_SETMOUSEHOVERWIDTH_REGKEY,
1983                               SPI_SETMOUSEHOVERWIDTH_VALNAME,
1984                               &mouse_hover_width, pvParam );
1985         break;
1986
1987     case SPI_SETMOUSEHOVERWIDTH:
1988         ret = set_uint_param( SPI_SETMOUSEHOVERWIDTH_IDX,
1989                               SPI_SETMOUSEHOVERWIDTH_REGKEY,
1990                               SPI_SETMOUSEHOVERWIDTH_VALNAME,
1991                               &mouse_hover_width, uiParam, fWinIni );
1992         break;
1993
1994     case SPI_GETMOUSEHOVERHEIGHT:
1995         ret = get_uint_param( SPI_SETMOUSEHOVERHEIGHT_IDX,
1996                               SPI_SETMOUSEHOVERHEIGHT_REGKEY,
1997                               SPI_SETMOUSEHOVERHEIGHT_VALNAME,
1998                               &mouse_hover_height, pvParam );
1999         break;
2000
2001     case SPI_SETMOUSEHOVERHEIGHT:
2002         ret = set_uint_param( SPI_SETMOUSEHOVERHEIGHT_IDX,
2003                               SPI_SETMOUSEHOVERHEIGHT_REGKEY,
2004                               SPI_SETMOUSEHOVERHEIGHT_VALNAME,
2005                               &mouse_hover_height, uiParam, fWinIni );
2006         break;
2007
2008     case SPI_GETMOUSEHOVERTIME:
2009         ret = get_uint_param( SPI_SETMOUSEHOVERTIME_IDX,
2010                               SPI_SETMOUSEHOVERTIME_REGKEY,
2011                               SPI_SETMOUSEHOVERTIME_VALNAME,
2012                               &mouse_hover_time, pvParam );
2013         break;
2014
2015     case SPI_SETMOUSEHOVERTIME:
2016         ret = set_uint_param( SPI_SETMOUSEHOVERTIME_IDX,
2017                               SPI_SETMOUSEHOVERTIME_REGKEY,
2018                               SPI_SETMOUSEHOVERTIME_VALNAME,
2019                               &mouse_hover_time, uiParam, fWinIni );
2020         break;
2021
2022     case SPI_GETWHEELSCROLLLINES:
2023         ret = get_uint_param( SPI_SETMOUSESCROLLLINES_IDX,
2024                               SPI_SETMOUSESCROLLLINES_REGKEY,
2025                               SPI_SETMOUSESCROLLLINES_VALNAME,
2026                               &mouse_scroll_lines, pvParam );
2027         break;
2028
2029     case SPI_SETWHEELSCROLLLINES:
2030         ret = set_uint_param( SPI_SETMOUSESCROLLLINES_IDX,
2031                               SPI_SETMOUSESCROLLLINES_REGKEY,
2032                               SPI_SETMOUSESCROLLLINES_VALNAME,
2033                               &mouse_scroll_lines, uiParam, fWinIni );
2034         break;
2035
2036     case SPI_GETMENUSHOWDELAY:
2037         ret = get_uint_param( SPI_SETMENUSHOWDELAY_IDX,
2038                               SPI_SETMENUSHOWDELAY_REGKEY,
2039                               SPI_SETMENUSHOWDELAY_VALNAME,
2040                               &menu_show_delay, pvParam );
2041         break;
2042
2043     case SPI_SETMENUSHOWDELAY:
2044         ret = set_uint_param( SPI_SETMENUSHOWDELAY_IDX,
2045                               SPI_SETMENUSHOWDELAY_REGKEY,
2046                               SPI_SETMENUSHOWDELAY_VALNAME,
2047                               &menu_show_delay, uiParam, fWinIni );
2048         break;
2049
2050     WINE_SPI_FIXME(SPI_GETSHOWIMEUI);           /*    110  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2051     WINE_SPI_FIXME(SPI_SETSHOWIMEUI);           /*    111  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2052     WINE_SPI_FIXME(SPI_GETMOUSESPEED);          /*    112  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2053     WINE_SPI_FIXME(SPI_SETMOUSESPEED);          /*    113  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2054
2055     case SPI_GETSCREENSAVERRUNNING:
2056         ret = get_bool_param( SPI_SETSCREENSAVERRUNNING_IDX,
2057                               SPI_SETSCREENSAVERRUNNING_REGKEY,
2058                               SPI_SETSCREENSAVERRUNNING_VALNAME,
2059                               &screensaver_running, pvParam );
2060         break;
2061
2062     case SPI_GETDESKWALLPAPER:                  /*    115  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2063     {
2064         WCHAR buf[MAX_PATH];
2065
2066         if (!pvParam) return FALSE;
2067
2068         if (uiParam > MAX_PATH)
2069         {
2070             uiParam = MAX_PATH;
2071         }
2072
2073         if (SYSPARAMS_Load(SPI_SETDESKWALLPAPER_REGKEY, SPI_SETDESKWALLPAPER_VALNAME, buf, sizeof(buf)))
2074         {
2075             lstrcpynW((WCHAR*)pvParam, buf, uiParam);
2076         }
2077         else
2078         {
2079             /* Return an empty string */
2080             memset((WCHAR*)pvParam, 0, uiParam);
2081         }
2082
2083         break;
2084     }
2085
2086     WINE_SPI_FIXME(SPI_GETACTIVEWINDOWTRACKING);/* 0x1000  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2087     WINE_SPI_FIXME(SPI_SETACTIVEWINDOWTRACKING);/* 0x1001  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2088     WINE_SPI_FIXME(SPI_GETMENUANIMATION);       /* 0x1002  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2089     WINE_SPI_FIXME(SPI_SETMENUANIMATION);       /* 0x1003  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2090     WINE_SPI_FIXME(SPI_GETCOMBOBOXANIMATION);   /* 0x1004  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2091     WINE_SPI_FIXME(SPI_SETCOMBOBOXANIMATION);   /* 0x1005  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2092
2093     case SPI_GETLISTBOXSMOOTHSCROLLING:    /* 0x1006  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2094         if (!pvParam) return FALSE;
2095
2096         spi_idx = SPI_SETLISTBOXSMOOTHSCROLLING_IDX;
2097         if (!spi_loaded[spi_idx])
2098         {
2099             WCHAR buf[5];
2100
2101             if (SYSPARAMS_Load( SPI_SETLISTBOXSMOOTHSCROLLING_REGKEY,
2102                                 SPI_SETLISTBOXSMOOTHSCROLLING_VALNAME, buf, sizeof(buf) ))
2103             {
2104                 if ((buf[0]&0x01) == 0x01)
2105                 {
2106                     listbox_smoothscrolling = TRUE;
2107                 }
2108             }
2109             spi_loaded[spi_idx] = TRUE;
2110         }
2111
2112         *(BOOL *)pvParam = listbox_smoothscrolling;
2113
2114         break;
2115
2116     WINE_SPI_FIXME(SPI_SETLISTBOXSMOOTHSCROLLING);/* 0x1007  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2117
2118     case SPI_GETGRADIENTCAPTIONS:
2119         ret = get_user_pref_param( 0, 0x10, pvParam );
2120         break;
2121
2122     case SPI_SETGRADIENTCAPTIONS:
2123         ret = set_user_pref_param( 0, 0x10, (BOOL)pvParam, fWinIni );
2124         break;
2125
2126     case SPI_GETKEYBOARDCUES:
2127         ret = get_user_pref_param( 0, 0x20, pvParam );
2128         break;
2129
2130     case SPI_SETKEYBOARDCUES:
2131         ret = set_user_pref_param( 0, 0x20, (BOOL)pvParam, fWinIni );
2132         break;
2133
2134     WINE_SPI_FIXME(SPI_GETACTIVEWNDTRKZORDER);  /* 0x100C  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2135     WINE_SPI_FIXME(SPI_SETACTIVEWNDTRKZORDER);  /* 0x100D  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2136     case SPI_GETHOTTRACKING:
2137         ret = get_user_pref_param( 0, 0x80, pvParam );
2138         break;
2139
2140     case SPI_SETHOTTRACKING:
2141         ret = set_user_pref_param( 0, 0x80, (BOOL)pvParam, fWinIni );
2142         break;
2143
2144     WINE_SPI_FIXME(SPI_GETMENUFADE);            /* 0x1012  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2145     WINE_SPI_FIXME(SPI_SETMENUFADE);            /* 0x1013  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2146     WINE_SPI_FIXME(SPI_GETSELECTIONFADE);       /* 0x1014  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2147     WINE_SPI_FIXME(SPI_SETSELECTIONFADE);       /* 0x1015  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2148     WINE_SPI_FIXME(SPI_GETTOOLTIPANIMATION);    /* 0x1016  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2149     WINE_SPI_FIXME(SPI_SETTOOLTIPANIMATION);    /* 0x1017  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2150     WINE_SPI_FIXME(SPI_GETTOOLTIPFADE);         /* 0x1018  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2151     WINE_SPI_FIXME(SPI_SETTOOLTIPFADE);         /* 0x1019  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2152     WINE_SPI_FIXME(SPI_GETCURSORSHADOW);        /* 0x101A  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2153     WINE_SPI_FIXME(SPI_SETCURSORSHADOW);        /* 0x101B  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2154     WINE_SPI_FIXME(SPI_GETMOUSESONAR);          /* 0x101C  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2155     WINE_SPI_FIXME(SPI_SETMOUSESONAR);          /* 0x101D  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2156     WINE_SPI_FIXME(SPI_GETMOUSECLICKLOCK);      /* 0x101E  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2157     WINE_SPI_FIXME(SPI_SETMOUSECLICKLOCK);      /* 0x101F  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2158     WINE_SPI_FIXME(SPI_GETMOUSEVANISH);         /* 0x1020  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2159     WINE_SPI_FIXME(SPI_SETMOUSEVANISH);         /* 0x1021  _WIN32_WINNT >= 0x510 || _WIN32_WINDOW >= 0x490*/
2160     case SPI_GETFLATMENU:
2161         ret = get_user_pref_param( 2, 0x02, pvParam );
2162         break;
2163
2164     case SPI_SETFLATMENU:
2165         ret = set_user_pref_param( 2, 0x02, (BOOL)pvParam, fWinIni );
2166         break;
2167
2168     WINE_SPI_FIXME(SPI_GETDROPSHADOW);          /* 0x1024  _WIN32_WINNT >= 0x510 */
2169     WINE_SPI_FIXME(SPI_SETDROPSHADOW);          /* 0x1025  _WIN32_WINNT >= 0x510 */
2170     WINE_SPI_FIXME(SPI_GETBLOCKSENDINPUTRESETS);
2171     WINE_SPI_FIXME(SPI_SETBLOCKSENDINPUTRESETS);
2172     WINE_SPI_FIXME(SPI_GETUIEFFECTS);
2173     WINE_SPI_FIXME(SPI_SETUIEFFECTS);
2174     WINE_SPI_FIXME(SPI_GETFOREGROUNDLOCKTIMEOUT);/* 0x2000  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2175     WINE_SPI_FIXME(SPI_SETFOREGROUNDLOCKTIMEOUT);/* 0x2001  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2176     WINE_SPI_FIXME(SPI_GETACTIVEWNDTRKTIMEOUT); /* 0x2002  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2177     WINE_SPI_FIXME(SPI_SETACTIVEWNDTRKTIMEOUT); /* 0x2003  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2178     WINE_SPI_FIXME(SPI_GETFOREGROUNDFLASHCOUNT);/* 0x2004  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2179     WINE_SPI_FIXME(SPI_SETFOREGROUNDFLASHCOUNT);/* 0x2005  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2180     WINE_SPI_FIXME(SPI_GETCARETWIDTH);          /* 0x2006  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2181     WINE_SPI_FIXME(SPI_SETCARETWIDTH);          /* 0x2007  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2182     WINE_SPI_FIXME(SPI_GETMOUSECLICKLOCKTIME);  /* 0x2008  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2183     WINE_SPI_FIXME(SPI_SETMOUSECLICKLOCKTIME);  /* 0x2009  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2184     WINE_SPI_FIXME(SPI_GETFONTSMOOTHINGTYPE);   /* 0x200A  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2185     WINE_SPI_FIXME(SPI_SETFONTSMOOTHINGTYPE);   /* 0x200B  _WIN32_WINNT >= 0x500 || _WIN32_WINDOW > 0x400 */
2186     WINE_SPI_FIXME(SPI_GETFONTSMOOTHINGCONTRAST);/* 0x200C  _WIN32_WINNT >= 0x510 */
2187     WINE_SPI_FIXME(SPI_SETFONTSMOOTHINGCONTRAST);/* 0x200D  _WIN32_WINNT >= 0x510 */
2188     WINE_SPI_FIXME(SPI_GETFOCUSBORDERWIDTH);    /* 0x200E  _WIN32_WINNT >= 0x510 */
2189     WINE_SPI_FIXME(SPI_SETFOCUSBORDERWIDTH);    /* 0x200F  _WIN32_WINNT >= 0x510 */
2190     WINE_SPI_FIXME(SPI_GETFOCUSBORDERHEIGHT);    /* 0x2010  _WIN32_WINNT >= 0x510 */
2191     WINE_SPI_FIXME(SPI_SETFOCUSBORDERHEIGHT);    /* 0x2011  _WIN32_WINNT >= 0x510 */
2192
2193     default:
2194         FIXME( "Unknown action: %u\n", uiAction );
2195         SetLastError( ERROR_INVALID_SPI_VALUE );
2196         ret = FALSE;
2197         break;
2198     }
2199
2200     if (ret)
2201         SYSPARAMS_NotifyChange( uiAction, fWinIni );
2202     TRACE("(%u, %u, %p, %u) ret %d\n",
2203             uiAction, uiParam, pvParam, fWinIni, ret);
2204     return ret;
2205
2206 #undef WINE_SPI_FIXME
2207 #undef WINE_SPI_WARN
2208 }
2209
2210
2211 /***********************************************************************
2212  *              SystemParametersInfo (USER.483)
2213  */
2214 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
2215                                       LPVOID lpvParam, UINT16 fuWinIni )
2216 {
2217     BOOL16 ret;
2218
2219     TRACE("(%u, %u, %p, %u)\n", uAction, uParam, lpvParam, fuWinIni);
2220
2221     switch (uAction)
2222     {
2223     case SPI_GETBEEP:                           /*      1 */
2224     case SPI_GETSCREENSAVEACTIVE:               /*     16 */
2225     case SPI_GETICONTITLEWRAP:                  /*     25 */
2226     case SPI_GETMENUDROPALIGNMENT:              /*     27 */
2227     case SPI_GETFASTTASKSWITCH:                 /*     35 */
2228     case SPI_GETDRAGFULLWINDOWS:                /*     38  WINVER >= 0x0400 */
2229     {
2230         BOOL tmp;
2231         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2232         if (ret && lpvParam)
2233             *(BOOL16 *)lpvParam = tmp;
2234         break;
2235     }
2236
2237     case SPI_GETBORDER:                         /*      5 */
2238     case SPI_ICONHORIZONTALSPACING:             /*     13 */
2239     case SPI_GETSCREENSAVETIMEOUT:              /*     14 */
2240     case SPI_GETGRIDGRANULARITY:                /*     18 */
2241     case SPI_GETKEYBOARDDELAY:                  /*     22 */
2242     case SPI_ICONVERTICALSPACING:               /*     24 */
2243     {
2244         INT tmp;
2245         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2246         if (ret && lpvParam)
2247             *(INT16 *)lpvParam = tmp;
2248         break;
2249     }
2250
2251     case SPI_GETKEYBOARDSPEED:                  /*     10 */
2252     {
2253         DWORD tmp;
2254         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2255         if (ret && lpvParam)
2256             *(WORD *)lpvParam = tmp;
2257         break;
2258     }
2259
2260     case SPI_GETICONTITLELOGFONT:               /*     31 */
2261     {
2262         LOGFONTA tmp;
2263         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2264         if (ret && lpvParam)
2265             SYSPARAMS_LogFont32ATo16( &tmp, (LPLOGFONT16)lpvParam );
2266         break;
2267     }
2268
2269     case SPI_GETNONCLIENTMETRICS:               /*     41  WINVER >= 0x400 */
2270     {
2271         NONCLIENTMETRICSA tmp;
2272         LPNONCLIENTMETRICS16 lpnm16 = (LPNONCLIENTMETRICS16)lpvParam;
2273         if (lpnm16 && lpnm16->cbSize == sizeof(NONCLIENTMETRICS16))
2274         {
2275             tmp.cbSize = sizeof(NONCLIENTMETRICSA);
2276             ret = SystemParametersInfoA( uAction, uParam, &tmp, fuWinIni );
2277             if (ret)
2278                 SYSPARAMS_NonClientMetrics32ATo16( &tmp, lpnm16 );
2279         }
2280         else /* winfile 95 sets cbSize to 340 */
2281             ret = SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
2282         break;
2283     }
2284
2285     case SPI_GETWORKAREA:                       /*     48  WINVER >= 0x400 */
2286     {
2287         RECT tmp;
2288         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2289         if (ret && lpvParam)
2290         {
2291             RECT16 *r16 = (RECT16 *)lpvParam;
2292             r16->left   = tmp.left;
2293             r16->top    = tmp.top;
2294             r16->right  = tmp.right;
2295             r16->bottom = tmp.bottom;
2296         }
2297         break;
2298     }
2299
2300     case SPI_GETMOUSEHOVERWIDTH:                /*     98  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2301     case SPI_GETMOUSEHOVERHEIGHT:               /*    100  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2302     case SPI_GETMOUSEHOVERTIME:                 /*    102  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2303     {
2304         UINT tmp;
2305         ret = SystemParametersInfoA( uAction, uParam, lpvParam ? &tmp : NULL, fuWinIni );
2306         if (ret && lpvParam)
2307             *(UINT16 *)lpvParam = tmp;
2308         break;
2309     }
2310
2311     default:
2312         ret = SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
2313     }
2314
2315     return ret;
2316 }
2317
2318 /***********************************************************************
2319  *              SystemParametersInfoA (USER32.@)
2320  */
2321 BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
2322                                    PVOID pvParam, UINT fuWinIni )
2323 {
2324     BOOL ret;
2325
2326     TRACE("(%u, %u, %p, %u)\n", uiAction, uiParam, pvParam, fuWinIni);
2327
2328     switch (uiAction)
2329     {
2330     case SPI_SETDESKWALLPAPER:                  /*     20 */
2331     case SPI_SETDESKPATTERN:                    /*     21 */
2332     {
2333         WCHAR buffer[256];
2334         if (pvParam)
2335             if (!MultiByteToWideChar( CP_ACP, 0, (LPSTR)pvParam, -1,
2336                                       buffer, sizeof(buffer)/sizeof(WCHAR) ))
2337                 buffer[sizeof(buffer)/sizeof(WCHAR)-1] = 0;
2338         ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni );
2339         break;
2340     }
2341
2342     case SPI_GETICONTITLELOGFONT:               /*     31 */
2343     {
2344         LOGFONTW tmp;
2345         ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? &tmp : NULL, fuWinIni );
2346         if (ret && pvParam)
2347             SYSPARAMS_LogFont32WTo32A( &tmp, (LPLOGFONTA)pvParam );
2348         break;
2349     }
2350
2351     case SPI_GETNONCLIENTMETRICS:               /*     41  WINVER >= 0x400 */
2352     {
2353         NONCLIENTMETRICSW tmp;
2354         LPNONCLIENTMETRICSA lpnmA = (LPNONCLIENTMETRICSA)pvParam;
2355         if (lpnmA && lpnmA->cbSize == sizeof(NONCLIENTMETRICSA))
2356         {
2357             tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2358             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2359             if (ret)
2360                 SYSPARAMS_NonClientMetrics32WTo32A( &tmp, lpnmA );
2361         }
2362         else
2363             ret = FALSE;
2364         break;
2365     }
2366
2367     case SPI_SETNONCLIENTMETRICS:               /*     42  WINVER >= 0x400 */
2368     {
2369         NONCLIENTMETRICSW tmp;
2370         LPNONCLIENTMETRICSA lpnmA = (LPNONCLIENTMETRICSA)pvParam;
2371         if (lpnmA && lpnmA->cbSize == sizeof(NONCLIENTMETRICSA))
2372         {
2373             tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2374             SYSPARAMS_NonClientMetrics32ATo32W( lpnmA, &tmp );
2375             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2376         }
2377         else
2378             ret = FALSE;
2379         break;
2380     }
2381
2382     case SPI_GETICONMETRICS:                    /*     45  WINVER >= 0x400 */
2383     {
2384         ICONMETRICSW tmp;
2385         LPICONMETRICSA lpimA = (LPICONMETRICSA)pvParam;
2386         if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2387         {
2388             tmp.cbSize = sizeof(ICONMETRICSW);
2389             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2390             if (ret)
2391             {
2392                 lpimA->iHorzSpacing = tmp.iHorzSpacing;
2393                 lpimA->iVertSpacing = tmp.iVertSpacing;
2394                 lpimA->iTitleWrap   = tmp.iTitleWrap;
2395                 SYSPARAMS_LogFont32WTo32A( &tmp.lfFont, &lpimA->lfFont );
2396             }
2397         }
2398         else
2399             ret = FALSE;
2400         break;
2401     }
2402
2403     case SPI_SETICONMETRICS:                    /*     46  WINVER >= 0x400 */
2404     {
2405         ICONMETRICSW tmp;
2406         LPICONMETRICSA lpimA = (LPICONMETRICSA)pvParam;
2407         if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2408         {
2409             tmp.cbSize = sizeof(ICONMETRICSW);
2410             tmp.iHorzSpacing = lpimA->iHorzSpacing;
2411             tmp.iVertSpacing = lpimA->iVertSpacing;
2412             tmp.iTitleWrap = lpimA->iTitleWrap;
2413             SYSPARAMS_LogFont32ATo32W(  &lpimA->lfFont, &tmp.lfFont);
2414             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2415         }
2416         else
2417             ret = FALSE;
2418         break;
2419     }
2420
2421     case SPI_GETHIGHCONTRAST:                   /*     66  WINVER >= 0x400 */
2422     {
2423         HIGHCONTRASTW tmp;
2424         LPHIGHCONTRASTA lphcA = (LPHIGHCONTRASTA)pvParam;
2425         if (lphcA && lphcA->cbSize == sizeof(HIGHCONTRASTA))
2426         {
2427             tmp.cbSize = sizeof(HIGHCONTRASTW);
2428             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2429             if (ret)
2430             {
2431                 lphcA->dwFlags = tmp.dwFlags;
2432                 lphcA->lpszDefaultScheme = NULL;  /* FIXME? */
2433             }
2434         }
2435         else
2436             ret = FALSE;
2437         break;
2438     }
2439
2440     default:
2441         ret = SystemParametersInfoW( uiAction, uiParam, pvParam, fuWinIni );
2442         break;
2443     }
2444     return ret;
2445 }
2446
2447
2448 /***********************************************************************
2449  *              GetSystemMetrics (USER32.@)
2450  */
2451 INT WINAPI GetSystemMetrics( INT index )
2452 {
2453     UINT ret;
2454
2455     /* some metrics are dynamic */
2456     switch (index)
2457     {
2458     case SM_CXSCREEN:
2459         return GetDeviceCaps( get_display_dc(), HORZRES );
2460     case SM_CYSCREEN:
2461         return GetDeviceCaps( get_display_dc(), VERTRES );
2462     case SM_CXVSCROLL:
2463         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2464         return nonclient_metrics.iScrollWidth;
2465     case SM_CYHSCROLL:
2466         return GetSystemMetrics(SM_CXVSCROLL);
2467     case SM_CYCAPTION:
2468         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2469         return nonclient_metrics.iCaptionHeight + 1;
2470     case SM_CXBORDER:
2471     case SM_CYBORDER:
2472         /* SM_C{X,Y}BORDER always returns 1 regardless of 'BorderWidth' value in registry */
2473         return 1;
2474     case SM_CXDLGFRAME:
2475     case SM_CYDLGFRAME:
2476         return 3;
2477     case SM_CYVTHUMB:
2478         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2479         return nonclient_metrics.iScrollHeight;
2480     case SM_CXHTHUMB:
2481         return GetSystemMetrics(SM_CYVTHUMB);
2482     case SM_CXICON:
2483         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2484         return icon_size.cx;
2485     case SM_CYICON:
2486         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2487         return icon_size.cy;
2488     case SM_CXCURSOR:
2489     case SM_CYCURSOR:
2490         return 32;
2491     case SM_CYMENU:
2492         return GetSystemMetrics(SM_CYMENUSIZE) + 1;
2493     case SM_CXFULLSCREEN:
2494         /* see the remark for SM_CXMAXIMIZED, at least this formulation is
2495          * correct */
2496         return GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME);
2497     case SM_CYFULLSCREEN:
2498         /* see the remark for SM_CYMAXIMIZED, at least this formulation is
2499          * correct */
2500         return GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN);
2501     case SM_CYKANJIWINDOW:
2502         return 0;
2503     case SM_MOUSEPRESENT:
2504         return 1;
2505     case SM_CYVSCROLL:
2506         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2507         return nonclient_metrics.iScrollHeight;
2508     case SM_CXHSCROLL:
2509         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2510         return nonclient_metrics.iScrollHeight;
2511     case SM_DEBUG:
2512         return 0;
2513     case SM_SWAPBUTTON:
2514         get_bool_param( SPI_SETMOUSEBUTTONSWAP_IDX, SPI_SETMOUSEBUTTONSWAP_REGKEY,
2515                         SPI_SETMOUSEBUTTONSWAP_VALNAME, &swap_buttons, (BOOL*)&ret );
2516         return ret;
2517     case SM_RESERVED1:
2518     case SM_RESERVED2:
2519     case SM_RESERVED3:
2520     case SM_RESERVED4:
2521         return 0;
2522     case SM_CXMIN:
2523         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2524         return 3 * nonclient_metrics.iCaptionWidth + GetSystemMetrics( SM_CYSIZE) +
2525             4 * CaptionFontAvCharWidth + 2 * GetSystemMetrics( SM_CXFRAME) + 4;
2526     case SM_CYMIN:
2527         return GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME);
2528     case SM_CXSIZE:
2529         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2530         return nonclient_metrics.iCaptionWidth;
2531     case SM_CYSIZE:
2532         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2533         return nonclient_metrics.iCaptionHeight;
2534     case SM_CXFRAME:
2535         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2536         return GetSystemMetrics(SM_CXDLGFRAME) + nonclient_metrics.iBorderWidth;
2537     case SM_CYFRAME:
2538         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2539         return GetSystemMetrics(SM_CYDLGFRAME) + nonclient_metrics.iBorderWidth;
2540     case SM_CXMINTRACK:
2541         return GetSystemMetrics(SM_CXMIN);
2542     case SM_CYMINTRACK:
2543         return GetSystemMetrics(SM_CYMIN);
2544     case SM_CXDOUBLECLK:
2545         get_uint_param( SPI_SETDOUBLECLKWIDTH_IDX, SPI_SETDOUBLECLKWIDTH_REGKEY1,
2546                         SPI_SETDOUBLECLKWIDTH_VALNAME, &double_click_width, &ret );
2547         return ret;
2548     case SM_CYDOUBLECLK:
2549         get_uint_param( SPI_SETDOUBLECLKHEIGHT_IDX, SPI_SETDOUBLECLKHEIGHT_REGKEY1,
2550                         SPI_SETDOUBLECLKHEIGHT_VALNAME, &double_click_height, &ret );
2551         return ret;
2552     case SM_CXICONSPACING:
2553         SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0, &ret, 0 );
2554         return ret;
2555     case SM_CYICONSPACING:
2556         SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0, &ret, 0 );
2557         return ret;
2558     case SM_MENUDROPALIGNMENT:
2559         SystemParametersInfoW( SPI_GETMENUDROPALIGNMENT, 0, &ret, 0 );
2560         return ret;
2561     case SM_PENWINDOWS:
2562         return 0;
2563     case SM_DBCSENABLED:
2564     {
2565         CPINFO cpinfo;
2566         GetCPInfo( CP_ACP, &cpinfo );
2567         return (cpinfo.MaxCharSize > 1);
2568     }
2569     case SM_CMOUSEBUTTONS:
2570         return 3;
2571     case SM_SECURE:
2572         return 0;
2573     case SM_CXEDGE:
2574         return GetSystemMetrics(SM_CXBORDER) + 1;
2575     case SM_CYEDGE:
2576         return GetSystemMetrics(SM_CYBORDER) + 1;
2577     case SM_CXMINSPACING:
2578         if( spi_loaded[SPI_MINIMIZEDMETRICS_IDX]) load_minimized_metrics();
2579         return GetSystemMetrics(SM_CXMINIMIZED) + minimized_metrics.iHorzGap;
2580     case SM_CYMINSPACING:
2581         if( spi_loaded[SPI_MINIMIZEDMETRICS_IDX]) load_minimized_metrics();
2582         return GetSystemMetrics(SM_CYMINIMIZED) + minimized_metrics.iVertGap;
2583     case SM_CXSMICON:
2584     case SM_CYSMICON:
2585         return 16;
2586     case SM_CYSMCAPTION:
2587         return GetSystemMetrics(SM_CYSMSIZE) + 1;
2588     case SM_CXSMSIZE:
2589         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2590         return nonclient_metrics.iSmCaptionWidth;
2591     case SM_CYSMSIZE:
2592         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2593         return nonclient_metrics.iSmCaptionHeight;
2594     case SM_CXMENUSIZE:
2595         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2596         return nonclient_metrics.iMenuWidth;
2597     case SM_CYMENUSIZE:
2598         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2599         return nonclient_metrics.iMenuHeight;
2600     case SM_ARRANGE:
2601         if( spi_loaded[SPI_MINIMIZEDMETRICS_IDX]) load_minimized_metrics();
2602         return minimized_metrics.iArrange;
2603     case SM_CXMINIMIZED:
2604         if( spi_loaded[SPI_MINIMIZEDMETRICS_IDX]) load_minimized_metrics();
2605         return minimized_metrics.iWidth + 6;
2606     case SM_CYMINIMIZED:
2607         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2608         return nonclient_metrics.iCaptionHeight + 6;
2609     case SM_CXMAXTRACK:
2610         return GetSystemMetrics(SM_CXSCREEN) + 4 + 2 * GetSystemMetrics(SM_CXFRAME);
2611     case SM_CYMAXTRACK:
2612         return GetSystemMetrics(SM_CYSCREEN) + 4 + 2 * GetSystemMetrics(SM_CYFRAME);
2613     case SM_CXMAXIMIZED:
2614         /* FIXME: subtract the width of any vertical application toolbars*/
2615         return GetSystemMetrics(SM_CXSCREEN) + 2 * GetSystemMetrics(SM_CXFRAME);
2616     case SM_CYMAXIMIZED:
2617         /* FIXME: subtract the width of any horizontal application toolbars*/
2618         return GetSystemMetrics(SM_CYSCREEN) + 2 * GetSystemMetrics(SM_CYCAPTION);
2619     case SM_NETWORK:
2620         return 3;  /* FIXME */
2621     case SM_CLEANBOOT:
2622         return 0; /* 0 = ok, 1 = failsafe, 2 = failsafe + network */
2623     case SM_CXDRAG:
2624     case SM_CYDRAG:
2625         return 4;
2626     case SM_SHOWSOUNDS:
2627         SystemParametersInfoW( SPI_GETSHOWSOUNDS, 0, &ret, 0 );
2628         return ret;
2629     case SM_CXMENUCHECK:
2630     case SM_CYMENUCHECK:
2631         if (!spi_loaded[SPI_NONCLIENTMETRICS_IDX]) load_nonclient_metrics();
2632         return tmMenuFont.tmHeight <= 0 ? 13 :
2633         ((tmMenuFont.tmHeight + tmMenuFont.tmExternalLeading + 1) / 2) * 2 - 1;
2634     case SM_SLOWMACHINE:
2635         return 0;  /* FIXME: Should check the type of processor */
2636     case SM_MIDEASTENABLED:
2637         return 0;  /* FIXME */
2638     case SM_MOUSEWHEELPRESENT:
2639         return 1;
2640     case SM_XVIRTUALSCREEN:
2641     case SM_YVIRTUALSCREEN:
2642         return 0;
2643     case SM_CXVIRTUALSCREEN:
2644         return GetSystemMetrics(SM_CXSCREEN);
2645     case SM_CYVIRTUALSCREEN:
2646         return GetSystemMetrics(SM_CYSCREEN);
2647     case SM_CMONITORS:
2648         return 1;
2649     case SM_SAMEDISPLAYFORMAT:
2650         return 1;
2651     case SM_IMMENABLED:
2652         return 0;  /* FIXME */
2653     case SM_CXFOCUSBORDER:
2654     case SM_CYFOCUSBORDER:
2655         return 1;
2656     case SM_TABLETPC:
2657     case SM_MEDIACENTER:
2658         return 0;
2659     case SM_CMETRICS:
2660         return SM_CMETRICS;
2661     default:
2662         return 0;
2663     }
2664 }
2665
2666
2667 /***********************************************************************
2668  *              SwapMouseButton (USER32.@)
2669  *  Reverse or restore the meaning of the left and right mouse buttons
2670  *  fSwap  [I ] TRUE - reverse, FALSE - original
2671  * RETURN
2672  *   previous state 
2673  */
2674 BOOL WINAPI SwapMouseButton( BOOL fSwap )
2675 {
2676     BOOL prev = GetSystemMetrics(SM_SWAPBUTTON);
2677     SystemParametersInfoW(SPI_SETMOUSEBUTTONSWAP, fSwap, 0, 0);
2678     return prev;
2679 }
2680
2681
2682 /**********************************************************************
2683  *              SetDoubleClickTime (USER32.@)
2684  */
2685 BOOL WINAPI SetDoubleClickTime( UINT interval )
2686 {
2687     return SystemParametersInfoW(SPI_SETDOUBLECLICKTIME, interval, 0, 0);
2688 }
2689
2690
2691 /**********************************************************************
2692  *              GetDoubleClickTime (USER32.@)
2693  */
2694 UINT WINAPI GetDoubleClickTime(void)
2695 {
2696     UINT time = 0;
2697
2698     get_uint_param( SPI_SETDOUBLECLICKTIME_IDX,
2699                     SPI_SETDOUBLECLICKTIME_REGKEY,
2700                     SPI_SETDOUBLECLICKTIME_VALNAME,
2701                     &double_click_time, &time );
2702     if (!time) time = 500;
2703     return time;
2704 }
2705
2706
2707 /*************************************************************************
2708  *              GetSysColor (USER32.@)
2709  */
2710 COLORREF WINAPI GetSysColor( INT nIndex )
2711 {
2712     if (nIndex >= 0 && nIndex < NUM_SYS_COLORS)
2713         return SysColors[nIndex];
2714     else
2715         return 0;
2716 }
2717
2718
2719 /*************************************************************************
2720  *              SetSysColors (USER32.@)
2721  */
2722 BOOL WINAPI SetSysColors( INT nChanges, const INT *lpSysColor,
2723                               const COLORREF *lpColorValues )
2724 {
2725     int i;
2726
2727     for (i = 0; i < nChanges; i++) SYSPARAMS_SetSysColor( lpSysColor[i], lpColorValues[i] );
2728
2729     /* Send WM_SYSCOLORCHANGE message to all windows */
2730
2731     SendMessageTimeoutW( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0, SMTO_ABORTIFHUNG, 2000, NULL );
2732
2733     /* Repaint affected portions of all visible windows */
2734
2735     RedrawWindow( GetDesktopWindow(), NULL, 0,
2736                 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
2737     return TRUE;
2738 }
2739
2740
2741 /*************************************************************************
2742  *              SetSysColorsTemp (USER32.@)
2743  *
2744  * UNDOCUMENTED !!
2745  *
2746  * Called by W98SE desk.cpl Control Panel Applet:
2747  * handle = SetSysColorsTemp(ptr, ptr, nCount);     ("set" call)
2748  * result = SetSysColorsTemp(NULL, NULL, handle);   ("restore" call)
2749  *
2750  * pPens is an array of COLORREF values, which seems to be used
2751  * to indicate the color values to create new pens with.
2752  *
2753  * pBrushes is an array of solid brush handles (returned by a previous
2754  * CreateSolidBrush), which seems to contain the brush handles to set
2755  * for the system colors.
2756  *
2757  * n seems to be used for
2758  *   a) indicating the number of entries to operate on (length of pPens,
2759  *      pBrushes)
2760  *   b) passing the handle that points to the previously used color settings.
2761  *      I couldn't figure out in hell what kind of handle this is on
2762  *      Windows. I just use a heap handle instead. Shouldn't matter anyway.
2763  *
2764  * RETURNS
2765  *     heap handle of our own copy of the current syscolors in case of
2766  *                 "set" call, i.e. pPens, pBrushes != NULL.
2767  *     TRUE (unconditionally !) in case of "restore" call,
2768  *          i.e. pPens, pBrushes == NULL.
2769  *     FALSE in case of either pPens != NULL and pBrushes == NULL
2770  *          or pPens == NULL and pBrushes != NULL.
2771  *
2772  * I'm not sure whether this implementation is 100% correct. [AM]
2773  */
2774 DWORD WINAPI SetSysColorsTemp( const COLORREF *pPens, const HBRUSH *pBrushes, DWORD n)
2775 {
2776     int i;
2777
2778     if (pPens && pBrushes) /* "set" call */
2779     {
2780         /* allocate our structure to remember old colors */
2781         LPVOID pOldCol = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)+n*sizeof(HPEN)+n*sizeof(HBRUSH));
2782         LPVOID p = pOldCol;
2783         *(DWORD *)p = n; p = (char*)p + sizeof(DWORD);
2784         memcpy(p, SysColorPens, n*sizeof(HPEN)); p = (char*)p + n*sizeof(HPEN);
2785         memcpy(p, SysColorBrushes, n*sizeof(HBRUSH)); p = (char*)p + n*sizeof(HBRUSH);
2786
2787         for (i=0; i < n; i++)
2788         {
2789             SysColorPens[i] = CreatePen( PS_SOLID, 1, pPens[i] );
2790             SysColorBrushes[i] = pBrushes[i];
2791         }
2792
2793         return (DWORD)pOldCol;
2794     }
2795     if (!pPens && !pBrushes) /* "restore" call */
2796     {
2797         LPVOID pOldCol = (LPVOID)n;
2798         LPVOID p = pOldCol;
2799         DWORD nCount = *(DWORD *)p;
2800         p = (char*)p + sizeof(DWORD);
2801
2802         for (i=0; i < nCount; i++)
2803         {
2804             DeleteObject(SysColorPens[i]);
2805             SysColorPens[i] = *(HPEN *)p; p = (char*)p + sizeof(HPEN);
2806         }
2807         for (i=0; i < nCount; i++)
2808         {
2809             SysColorBrushes[i] = *(HBRUSH *)p; p = (char*)p + sizeof(HBRUSH);
2810         }
2811         /* get rid of storage structure */
2812         HeapFree(GetProcessHeap(), 0, pOldCol);
2813
2814         return TRUE;
2815     }
2816     return FALSE;
2817 }
2818
2819
2820 /***********************************************************************
2821  *              GetSysColorBrush (USER32.@)
2822  */
2823 HBRUSH WINAPI GetSysColorBrush( INT index )
2824 {
2825     if (0 <= index && index < NUM_SYS_COLORS) return SysColorBrushes[index];
2826     WARN("Unknown index(%d)\n", index );
2827     return GetStockObject(LTGRAY_BRUSH);
2828 }
2829
2830
2831 /***********************************************************************
2832  *              SYSCOLOR_GetPen
2833  */
2834 HPEN SYSCOLOR_GetPen( INT index )
2835 {
2836     /* We can assert here, because this function is internal to Wine */
2837     assert (0 <= index && index < NUM_SYS_COLORS);
2838     return SysColorPens[index];
2839 }
2840
2841
2842 /***********************************************************************
2843  *              ChangeDisplaySettingsA (USER32.@)
2844  */
2845 LONG WINAPI ChangeDisplaySettingsA( LPDEVMODEA devmode, DWORD flags )
2846 {
2847     return ChangeDisplaySettingsExA(NULL,devmode,NULL,flags,NULL);
2848 }
2849
2850
2851 /***********************************************************************
2852  *              ChangeDisplaySettingsW (USER32.@)
2853  */
2854 LONG WINAPI ChangeDisplaySettingsW( LPDEVMODEW devmode, DWORD flags )
2855 {
2856     return ChangeDisplaySettingsExW(NULL,devmode,NULL,flags,NULL);
2857 }
2858
2859
2860 /***********************************************************************
2861  *              ChangeDisplaySettingsExA (USER32.@)
2862  */
2863 LONG WINAPI ChangeDisplaySettingsExA( LPCSTR devname, LPDEVMODEA devmode, HWND hwnd,
2864                                       DWORD flags, LPVOID lparam )
2865 {
2866     DEVMODEW devmodeW;
2867     LONG ret;
2868     UNICODE_STRING nameW;
2869
2870     if (devname) RtlCreateUnicodeStringFromAsciiz(&nameW, devname);
2871     else nameW.Buffer = NULL;
2872
2873     if (devmode)
2874     {
2875         devmodeW.dmBitsPerPel       = devmode->dmBitsPerPel;
2876         devmodeW.dmPelsHeight       = devmode->dmPelsHeight;
2877         devmodeW.dmPelsWidth        = devmode->dmPelsWidth;
2878         devmodeW.dmDisplayFlags     = devmode->dmDisplayFlags;
2879         devmodeW.dmDisplayFrequency = devmode->dmDisplayFrequency;
2880         devmodeW.dmFields           = devmode->dmFields;
2881         ret = ChangeDisplaySettingsExW(nameW.Buffer, &devmodeW, hwnd, flags, lparam);
2882     }
2883     else
2884     {
2885         ret = ChangeDisplaySettingsExW(nameW.Buffer, NULL, hwnd, flags, lparam);
2886     }
2887
2888     if (devname) RtlFreeUnicodeString(&nameW);
2889     return ret;
2890 }
2891
2892
2893 /***********************************************************************
2894  *              ChangeDisplaySettingsExW (USER32.@)
2895  */
2896 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
2897                                       DWORD flags, LPVOID lparam )
2898 {
2899     return USER_Driver->pChangeDisplaySettingsEx( devname, devmode, hwnd, flags, lparam );
2900 }
2901
2902
2903 /***********************************************************************
2904  *              EnumDisplaySettingsW (USER32.@)
2905  *
2906  * RETURNS
2907  *      TRUE if nth setting exists found (described in the LPDEVMODEW struct)
2908  *      FALSE if we do not have the nth setting
2909  */
2910 BOOL WINAPI EnumDisplaySettingsW( LPCWSTR name, DWORD n, LPDEVMODEW devmode )
2911 {
2912     return EnumDisplaySettingsExW(name, n, devmode, 0);
2913 }
2914
2915
2916 /***********************************************************************
2917  *              EnumDisplaySettingsA (USER32.@)
2918  */
2919 BOOL WINAPI EnumDisplaySettingsA(LPCSTR name,DWORD n,LPDEVMODEA devmode)
2920 {
2921     return EnumDisplaySettingsExA(name, n, devmode, 0);
2922 }
2923
2924
2925 /***********************************************************************
2926  *              EnumDisplaySettingsExA (USER32.@)
2927  */
2928 BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum,
2929                                    LPDEVMODEA lpDevMode, DWORD dwFlags)
2930 {
2931     DEVMODEW devmodeW;
2932     BOOL ret;
2933     UNICODE_STRING nameW;
2934
2935     if (lpszDeviceName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszDeviceName);
2936     else nameW.Buffer = NULL;
2937
2938     ret = EnumDisplaySettingsExW(nameW.Buffer,iModeNum,&devmodeW,dwFlags);
2939     if (ret)
2940     {
2941         lpDevMode->dmBitsPerPel       = devmodeW.dmBitsPerPel;
2942         lpDevMode->dmPelsHeight       = devmodeW.dmPelsHeight;
2943         lpDevMode->dmPelsWidth        = devmodeW.dmPelsWidth;
2944         lpDevMode->dmDisplayFlags     = devmodeW.dmDisplayFlags;
2945         lpDevMode->dmDisplayFrequency = devmodeW.dmDisplayFrequency;
2946         lpDevMode->dmFields           = devmodeW.dmFields;
2947     }
2948     if (lpszDeviceName) RtlFreeUnicodeString(&nameW);
2949     return ret;
2950 }
2951
2952
2953 /***********************************************************************
2954  *              EnumDisplaySettingsExW (USER32.@)
2955  */
2956 BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
2957                                    LPDEVMODEW lpDevMode, DWORD dwFlags)
2958 {
2959     return USER_Driver->pEnumDisplaySettingsEx(lpszDeviceName, iModeNum, lpDevMode, dwFlags);
2960 }