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