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