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