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