shell32/autocomplete: Reset the contents of the AutoComplete listbox when hiding it.
[wine.git] / dlls / user32 / sysparams.c
blob224d2f9fe07f7773a3cddb34802c3ddc5a0d72e9
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 <limits.h>
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
30 #define NONAMELESSUNION
31 #define NONAMELESSSTRUCT
33 #include "windef.h"
34 #include "winbase.h"
35 #include "winnls.h"
36 #include "wingdi.h"
37 #include "winreg.h"
38 #include "wine/wingdi16.h"
39 #include "winerror.h"
41 #include "controls.h"
42 #include "win.h"
43 #include "user_private.h"
44 #include "wine/gdi_driver.h"
45 #include "wine/unicode.h"
46 #include "wine/debug.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(system);
50 /* System parameter indexes */
51 enum spi_index
53 SPI_SETWORKAREA_IDX,
54 SPI_INDEX_COUNT
57 /**
58 * Names of the registry subkeys of HKEY_CURRENT_USER key and value names
59 * for the system parameters.
62 /* the various registry keys that are used to store parameters */
63 enum parameter_key
65 COLORS_KEY,
66 DESKTOP_KEY,
67 KEYBOARD_KEY,
68 MOUSE_KEY,
69 METRICS_KEY,
70 SOUND_KEY,
71 VERSION_KEY,
72 SHOWSOUNDS_KEY,
73 KEYBOARDPREF_KEY,
74 SCREENREADER_KEY,
75 AUDIODESC_KEY,
76 NB_PARAM_KEYS
79 static const WCHAR COLORS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','C','o','l','o','r','s',0};
80 static const WCHAR DESKTOP_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p',0};
81 static const WCHAR KEYBOARD_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','K','e','y','b','o','a','r','d',0};
82 static const WCHAR MOUSE_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
83 static const WCHAR METRICS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
84 'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
85 static const WCHAR SOUND_REGKEY[]= {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','S','o','u','n','d',0};
86 static const WCHAR VERSION_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
87 'M','i','c','r','o','s','o','f','t','\\',
88 'W','i','n','d','o','w','s',' ','N','T','\\',
89 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
90 'W','i','n','d','o','w','s',0};
91 static const WCHAR SHOWSOUNDS_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
92 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
93 'S','h','o','w','S','o','u','n','d','s',0};
94 static const WCHAR KEYBOARDPREF_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
95 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
96 'K','e','y','b','o','a','r','d',' ','P','r','e','f','e','r','e','n','c','e',0};
97 static const WCHAR SCREENREADER_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
98 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
99 'B','l','i','n','d',' ','A','c','c','e','s','s',0};
100 static const WCHAR AUDIODESC_REGKEY[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
101 'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
102 'A','u','d','i','o','D','e','s','c','r','i','p','t','i','o','n',0};
104 static const WCHAR *parameter_key_names[NB_PARAM_KEYS] =
106 COLORS_REGKEY,
107 DESKTOP_REGKEY,
108 KEYBOARD_REGKEY,
109 MOUSE_REGKEY,
110 METRICS_REGKEY,
111 SOUND_REGKEY,
112 VERSION_REGKEY,
113 SHOWSOUNDS_REGKEY,
114 KEYBOARDPREF_REGKEY,
115 SCREENREADER_REGKEY,
116 AUDIODESC_REGKEY,
119 /* parameter key values; the first char is actually an enum parameter_key to specify the key */
120 static const WCHAR BEEP_VALNAME[]= {SOUND_KEY,'B','e','e','p',0};
121 static const WCHAR MOUSETHRESHOLD1_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','1',0};
122 static const WCHAR MOUSETHRESHOLD2_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','2',0};
123 static const WCHAR MOUSEACCELERATION_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','S','p','e','e','d',0};
124 static const WCHAR BORDER_VALNAME[]= {METRICS_KEY,'B','o','r','d','e','r','W','i','d','t','h',0};
125 static const WCHAR KEYBOARDSPEED_VALNAME[]= {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','S','p','e','e','d',0};
126 static const WCHAR ICONHORIZONTALSPACING_VALNAME[]= {METRICS_KEY,'I','c','o','n','S','p','a','c','i','n','g',0};
127 static const WCHAR SCREENSAVETIMEOUT_VALNAME[]= {DESKTOP_KEY,'S','c','r','e','e','n','S','a','v','e','T','i','m','e','O','u','t',0};
128 static const WCHAR SCREENSAVEACTIVE_VALNAME[]= {DESKTOP_KEY,'S','c','r','e','e','n','S','a','v','e','A','c','t','i','v','e',0};
129 static const WCHAR GRIDGRANULARITY_VALNAME[]= {DESKTOP_KEY,'G','r','i','d','G','r','a','n','u','l','a','r','i','t','y',0};
130 static const WCHAR KEYBOARDDELAY_VALNAME[]= {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','D','e','l','a','y',0};
131 static const WCHAR ICONVERTICALSPACING_VALNAME[]= {METRICS_KEY,'I','c','o','n','V','e','r','t','i','c','a','l','S','p','a','c','i','n','g',0};
132 static const WCHAR ICONTITLEWRAP_VALNAME[]= {DESKTOP_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
133 static const WCHAR ICONTITLEWRAP_MIRROR[]= {METRICS_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
134 static const WCHAR ICONTITLELOGFONT_VALNAME[]= {METRICS_KEY,'I','c','o','n','F','o','n','t',0};
135 static const WCHAR MENUDROPALIGNMENT_VALNAME[]= {DESKTOP_KEY,'M','e','n','u','D','r','o','p','A','l','i','g','n','m','e','n','t',0};
136 static const WCHAR MENUDROPALIGNMENT_MIRROR[]= {VERSION_KEY,'M','e','n','u','D','r','o','p','A','l','i','g','n','m','e','n','t',0};
137 static const WCHAR MOUSETRAILS_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','T','r','a','i','l','s',0};
138 static const WCHAR SNAPTODEFBUTTON_VALNAME[]= {MOUSE_KEY,'S','n','a','p','T','o','D','e','f','a','u','l','t','B','u','t','t','o','n',0};
139 static const WCHAR DOUBLECLKWIDTH_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
140 static const WCHAR DOUBLECLKWIDTH_MIRROR[]= {DESKTOP_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
141 static const WCHAR DOUBLECLKHEIGHT_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','H','e','i','g','h','t',0};
142 static const WCHAR DOUBLECLKHEIGHT_MIRROR[]= {DESKTOP_KEY,'D','o','u','b','l','e','C','l','i','c','k','H','e','i','g','h','t',0};
143 static const WCHAR DOUBLECLICKTIME_VALNAME[]= {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','S','p','e','e','d',0};
144 static const WCHAR MOUSEBUTTONSWAP_VALNAME[]= {MOUSE_KEY,'S','w','a','p','M','o','u','s','e','B','u','t','t','o','n','s',0};
145 static const WCHAR DRAGFULLWINDOWS_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','F','u','l','l','W','i','n','d','o','w','s',0};
146 static const WCHAR SHOWSOUNDS_VALNAME[]= {SHOWSOUNDS_KEY,'O','n',0};
147 static const WCHAR KEYBOARDPREF_VALNAME[]= {KEYBOARDPREF_KEY,'O','n',0};
148 static const WCHAR SCREENREADER_VALNAME[]= {SCREENREADER_KEY,'O','n',0};
149 static const WCHAR DESKWALLPAPER_VALNAME[]= {DESKTOP_KEY,'W','a','l','l','p','a','p','e','r',0};
150 static const WCHAR DESKPATTERN_VALNAME[]= {DESKTOP_KEY,'P','a','t','t','e','r','n',0};
151 static const WCHAR FONTSMOOTHING_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g',0};
152 static const WCHAR DRAGWIDTH_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','W','i','d','t','h',0};
153 static const WCHAR DRAGHEIGHT_VALNAME[]= {DESKTOP_KEY,'D','r','a','g','H','e','i','g','h','t',0};
154 static const WCHAR DPISCALINGVER_VALNAME[]= {DESKTOP_KEY,'D','p','i','S','c','a','l','i','n','g','V','e','r',0};
155 static const WCHAR LOGPIXELS_VALNAME[]= {DESKTOP_KEY,'L','o','g','P','i','x','e','l','s',0};
156 static const WCHAR LOWPOWERACTIVE_VALNAME[]= {DESKTOP_KEY,'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0};
157 static const WCHAR POWEROFFACTIVE_VALNAME[]= {DESKTOP_KEY,'P','o','w','e','r','O','f','f','A','c','t','i','v','e',0};
158 static const WCHAR USERPREFERENCESMASK_VALNAME[]= {DESKTOP_KEY,'U','s','e','r','P','r','e','f','e','r','e','n','c','e','s','M','a','s','k',0};
159 static const WCHAR MOUSEHOVERWIDTH_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','W','i','d','t','h',0};
160 static const WCHAR MOUSEHOVERHEIGHT_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','H','e','i','g','h','t',0};
161 static const WCHAR MOUSEHOVERTIME_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','T','i','m','e',0};
162 static const WCHAR WHEELSCROLLCHARS_VALNAME[]= {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','C','h','a','r','s',0};
163 static const WCHAR WHEELSCROLLLINES_VALNAME[]= {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','L','i','n','e','s',0};
164 static const WCHAR ACTIVEWINDOWTRACKING_VALNAME[]= {MOUSE_KEY,'A','c','t','i','v','e','W','i','n','d','o','w','T','r','a','c','k','i','n','g',0};
165 static const WCHAR MENUSHOWDELAY_VALNAME[]= {DESKTOP_KEY,'M','e','n','u','S','h','o','w','D','e','l','a','y',0};
166 static const WCHAR BLOCKSENDINPUTRESETS_VALNAME[]= {DESKTOP_KEY,'B','l','o','c','k','S','e','n','d','I','n','p','u','t','R','e','s','e','t','s',0};
167 static const WCHAR FOREGROUNDLOCKTIMEOUT_VALNAME[]= {DESKTOP_KEY,'F','o','r','e','g','r','o','u','n','d','L','o','c','k','T','i','m','e','o','u','t',0};
168 static const WCHAR ACTIVEWNDTRKTIMEOUT_VALNAME[]= {DESKTOP_KEY,'A','c','t','i','v','e','W','n','d','T','r','a','c','k','T','i','m','e','o','u','t',0};
169 static const WCHAR FOREGROUNDFLASHCOUNT_VALNAME[]= {DESKTOP_KEY,'F','o','r','e','g','r','o','u','n','d','F','l','a','s','h','C','o','u','n','t',0};
170 static const WCHAR CARETWIDTH_VALNAME[]= {DESKTOP_KEY,'C','a','r','e','t','W','i','d','t','h',0};
171 static const WCHAR MOUSECLICKLOCKTIME_VALNAME[]= {DESKTOP_KEY,'C','l','i','c','k','L','o','c','k','T','i','m','e',0};
172 static const WCHAR MOUSESPEED_VALNAME[]= {MOUSE_KEY,'M','o','u','s','e','S','e','n','s','i','t','i','v','i','t','y',0};
173 static const WCHAR FONTSMOOTHINGTYPE_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g','T','y','p','e',0};
174 static const WCHAR FONTSMOOTHINGCONTRAST_VALNAME[]= {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g','G','a','m','m','a',0};
175 static const WCHAR FONTSMOOTHINGORIENTATION_VALNAME[]= {DESKTOP_KEY,'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};
176 static const WCHAR FOCUSBORDERWIDTH_VALNAME[]= {DESKTOP_KEY,'F','o','c','u','s','B','o','r','d','e','r','W','i','d','t','h',0};
177 static const WCHAR FOCUSBORDERHEIGHT_VALNAME[]= {DESKTOP_KEY,'F','o','c','u','s','B','o','r','d','e','r','H','e','i','g','h','t',0};
178 static const WCHAR SCROLLWIDTH_VALNAME[]= {METRICS_KEY,'S','c','r','o','l','l','W','i','d','t','h',0};
179 static const WCHAR SCROLLHEIGHT_VALNAME[]= {METRICS_KEY,'S','c','r','o','l','l','H','e','i','g','h','t',0};
180 static const WCHAR CAPTIONWIDTH_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','W','i','d','t','h',0};
181 static const WCHAR CAPTIONHEIGHT_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','H','e','i','g','h','t',0};
182 static const WCHAR SMCAPTIONWIDTH_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','W','i','d','t','h',0};
183 static const WCHAR SMCAPTIONHEIGHT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','H','e','i','g','h','t',0};
184 static const WCHAR MENUWIDTH_VALNAME[]= {METRICS_KEY,'M','e','n','u','W','i','d','t','h',0};
185 static const WCHAR MENUHEIGHT_VALNAME[]= {METRICS_KEY,'M','e','n','u','H','e','i','g','h','t',0};
186 static const WCHAR PADDEDBORDERWIDTH_VALNAME[]= {METRICS_KEY,'P','a','d','d','e','d','B','o','r','d','e','r','W','i','d','t','h',0};
187 static const WCHAR CAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'C','a','p','t','i','o','n','F','o','n','t',0};
188 static const WCHAR SMCAPTIONLOGFONT_VALNAME[]= {METRICS_KEY,'S','m','C','a','p','t','i','o','n','F','o','n','t',0};
189 static const WCHAR MENULOGFONT_VALNAME[]= {METRICS_KEY,'M','e','n','u','F','o','n','t',0};
190 static const WCHAR MESSAGELOGFONT_VALNAME[]= {METRICS_KEY,'M','e','s','s','a','g','e','F','o','n','t',0};
191 static const WCHAR STATUSLOGFONT_VALNAME[]= {METRICS_KEY,'S','t','a','t','u','s','F','o','n','t',0};
192 static const WCHAR MINWIDTH_VALNAME[] = {METRICS_KEY,'M','i','n','W','i','d','t','h',0};
193 static const WCHAR MINHORZGAP_VALNAME[] = {METRICS_KEY,'M','i','n','H','o','r','z','G','a','p',0};
194 static const WCHAR MINVERTGAP_VALNAME[] = {METRICS_KEY,'M','i','n','V','e','r','t','G','a','p',0};
195 static const WCHAR MINARRANGE_VALNAME[] = {METRICS_KEY,'M','i','n','A','r','r','a','n','g','e',0};
196 static const WCHAR COLOR_SCROLLBAR_VALNAME[] = {COLORS_KEY,'S','c','r','o','l','l','b','a','r',0};
197 static const WCHAR COLOR_BACKGROUND_VALNAME[] = {COLORS_KEY,'B','a','c','k','g','r','o','u','n','d',0};
198 static const WCHAR COLOR_ACTIVECAPTION_VALNAME[] = {COLORS_KEY,'A','c','t','i','v','e','T','i','t','l','e',0};
199 static const WCHAR COLOR_INACTIVECAPTION_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','T','i','t','l','e',0};
200 static const WCHAR COLOR_MENU_VALNAME[] = {COLORS_KEY,'M','e','n','u',0};
201 static const WCHAR COLOR_WINDOW_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w',0};
202 static const WCHAR COLOR_WINDOWFRAME_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w','F','r','a','m','e',0};
203 static const WCHAR COLOR_MENUTEXT_VALNAME[] = {COLORS_KEY,'M','e','n','u','T','e','x','t',0};
204 static const WCHAR COLOR_WINDOWTEXT_VALNAME[] = {COLORS_KEY,'W','i','n','d','o','w','T','e','x','t',0};
205 static const WCHAR COLOR_CAPTIONTEXT_VALNAME[] = {COLORS_KEY,'T','i','t','l','e','T','e','x','t',0};
206 static const WCHAR COLOR_ACTIVEBORDER_VALNAME[] = {COLORS_KEY,'A','c','t','i','v','e','B','o','r','d','e','r',0};
207 static const WCHAR COLOR_INACTIVEBORDER_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','B','o','r','d','e','r',0};
208 static const WCHAR COLOR_APPWORKSPACE_VALNAME[] = {COLORS_KEY,'A','p','p','W','o','r','k','S','p','a','c','e',0};
209 static const WCHAR COLOR_HIGHLIGHT_VALNAME[] = {COLORS_KEY,'H','i','l','i','g','h','t',0};
210 static const WCHAR COLOR_HIGHLIGHTTEXT_VALNAME[] = {COLORS_KEY,'H','i','l','i','g','h','t','T','e','x','t',0};
211 static const WCHAR COLOR_BTNFACE_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','F','a','c','e',0};
212 static const WCHAR COLOR_BTNSHADOW_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','S','h','a','d','o','w',0};
213 static const WCHAR COLOR_GRAYTEXT_VALNAME[] = {COLORS_KEY,'G','r','a','y','T','e','x','t',0};
214 static const WCHAR COLOR_BTNTEXT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','T','e','x','t',0};
215 static const WCHAR COLOR_INACTIVECAPTIONTEXT_VALNAME[] = {COLORS_KEY,'I','n','a','c','t','i','v','e','T','i','t','l','e','T','e','x','t',0};
216 static const WCHAR COLOR_BTNHIGHLIGHT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','H','i','l','i','g','h','t',0};
217 static const WCHAR COLOR_3DDKSHADOW_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','D','k','S','h','a','d','o','w',0};
218 static const WCHAR COLOR_3DLIGHT_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','L','i','g','h','t',0};
219 static const WCHAR COLOR_INFOTEXT_VALNAME[] = {COLORS_KEY,'I','n','f','o','T','e','x','t',0};
220 static const WCHAR COLOR_INFOBK_VALNAME[] = {COLORS_KEY,'I','n','f','o','W','i','n','d','o','w',0};
221 static const WCHAR COLOR_ALTERNATEBTNFACE_VALNAME[] = {COLORS_KEY,'B','u','t','t','o','n','A','l','t','e','r','n','a','t','e','F','a','c','e',0};
222 static const WCHAR COLOR_HOTLIGHT_VALNAME[] = {COLORS_KEY,'H','o','t','T','r','a','c','k','i','n','g','C','o','l','o','r',0};
223 static const WCHAR COLOR_GRADIENTACTIVECAPTION_VALNAME[] = {COLORS_KEY,'G','r','a','d','i','e','n','t','A','c','t','i','v','e','T','i','t','l','e',0};
224 static const WCHAR COLOR_GRADIENTINACTIVECAPTION_VALNAME[] = {COLORS_KEY,'G','r','a','d','i','e','n','t','I','n','a','c','t','i','v','e','T','i','t','l','e',0};
225 static const WCHAR COLOR_MENUHILIGHT_VALNAME[] = {COLORS_KEY,'M','e','n','u','H','i','l','i','g','h','t',0};
226 static const WCHAR COLOR_MENUBAR_VALNAME[] = {COLORS_KEY,'M','e','n','u','B','a','r',0};
227 static const WCHAR AUDIODESC_LOCALE_VALNAME[] = {AUDIODESC_KEY,'L','o','c','a','l','e',0};
228 static const WCHAR AUDIODESC_ON_VALNAME[] = {AUDIODESC_KEY,'O','n',0};
230 /* FIXME - real value */
231 static const WCHAR SCREENSAVERRUNNING_VALNAME[]= {DESKTOP_KEY,'W','I','N','E','_','S','c','r','e','e','n','S','a','v','e','r','R','u','n','n','i','n','g',0};
233 static const WCHAR WINE_CURRENT_USER_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
234 'W','i','n','e',0};
236 /* volatile registry branch under WINE_CURRENT_USER_REGKEY for temporary values storage */
237 static const WCHAR WINE_CURRENT_USER_REGKEY_TEMP_PARAMS[] = {'T','e','m','p','o','r','a','r','y',' ',
238 'S','y','s','t','e','m',' ',
239 'P','a','r','a','m','e','t','e','r','s',0};
241 static const WCHAR Yes[] = {'Y','e','s',0};
242 static const WCHAR No[] = {'N','o',0};
243 static const WCHAR CSu[] = {'%','u',0};
244 static const WCHAR CSd[] = {'%','d',0};
245 static const WCHAR CSrgb[] = {'%','u',' ','%','u',' ','%','u',0};
247 static HDC display_dc;
248 static CRITICAL_SECTION display_dc_section;
249 static CRITICAL_SECTION_DEBUG critsect_debug =
251 0, 0, &display_dc_section,
252 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
253 0, 0, { (DWORD_PTR)(__FILE__ ": display_dc_section") }
255 static CRITICAL_SECTION display_dc_section = { &critsect_debug, -1 ,0, 0, 0, 0 };
258 /* Indicators whether system parameter value is loaded */
259 static char spi_loaded[SPI_INDEX_COUNT];
261 static BOOL notify_change = TRUE;
263 /* System parameters storage */
264 static RECT work_area;
265 static UINT system_dpi;
266 static DPI_AWARENESS dpi_awareness;
267 static DPI_AWARENESS default_awareness = DPI_AWARENESS_UNAWARE;
269 static HKEY volatile_base_key;
271 union sysparam_all_entry;
273 struct sysparam_entry
275 BOOL (*get)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi );
276 BOOL (*set)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags );
277 BOOL (*init)( union sysparam_all_entry *entry );
278 const WCHAR *regval;
279 const WCHAR *mirror;
280 BOOL loaded;
283 struct sysparam_uint_entry
285 struct sysparam_entry hdr;
286 UINT val;
289 struct sysparam_bool_entry
291 struct sysparam_entry hdr;
292 BOOL val;
295 struct sysparam_dword_entry
297 struct sysparam_entry hdr;
298 DWORD val;
301 struct sysparam_rgb_entry
303 struct sysparam_entry hdr;
304 COLORREF val;
305 HBRUSH brush;
306 HPEN pen;
309 struct sysparam_binary_entry
311 struct sysparam_entry hdr;
312 void *ptr;
313 size_t size;
316 struct sysparam_path_entry
318 struct sysparam_entry hdr;
319 WCHAR path[MAX_PATH];
322 struct sysparam_font_entry
324 struct sysparam_entry hdr;
325 UINT weight;
326 LOGFONTW val;
329 struct sysparam_pref_entry
331 struct sysparam_entry hdr;
332 struct sysparam_binary_entry *parent;
333 UINT offset;
334 UINT mask;
337 union sysparam_all_entry
339 struct sysparam_entry hdr;
340 struct sysparam_uint_entry uint;
341 struct sysparam_bool_entry bool;
342 struct sysparam_dword_entry dword;
343 struct sysparam_rgb_entry rgb;
344 struct sysparam_binary_entry bin;
345 struct sysparam_path_entry path;
346 struct sysparam_font_entry font;
347 struct sysparam_pref_entry pref;
350 static void SYSPARAMS_LogFont16To32W( const LOGFONT16 *font16, LPLOGFONTW font32 )
352 font32->lfHeight = font16->lfHeight;
353 font32->lfWidth = font16->lfWidth;
354 font32->lfEscapement = font16->lfEscapement;
355 font32->lfOrientation = font16->lfOrientation;
356 font32->lfWeight = font16->lfWeight;
357 font32->lfItalic = font16->lfItalic;
358 font32->lfUnderline = font16->lfUnderline;
359 font32->lfStrikeOut = font16->lfStrikeOut;
360 font32->lfCharSet = font16->lfCharSet;
361 font32->lfOutPrecision = font16->lfOutPrecision;
362 font32->lfClipPrecision = font16->lfClipPrecision;
363 font32->lfQuality = font16->lfQuality;
364 font32->lfPitchAndFamily = font16->lfPitchAndFamily;
365 MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
366 font32->lfFaceName[LF_FACESIZE-1] = 0;
369 static void SYSPARAMS_LogFont32WTo32A( const LOGFONTW* font32W, LPLOGFONTA font32A )
371 font32A->lfHeight = font32W->lfHeight;
372 font32A->lfWidth = font32W->lfWidth;
373 font32A->lfEscapement = font32W->lfEscapement;
374 font32A->lfOrientation = font32W->lfOrientation;
375 font32A->lfWeight = font32W->lfWeight;
376 font32A->lfItalic = font32W->lfItalic;
377 font32A->lfUnderline = font32W->lfUnderline;
378 font32A->lfStrikeOut = font32W->lfStrikeOut;
379 font32A->lfCharSet = font32W->lfCharSet;
380 font32A->lfOutPrecision = font32W->lfOutPrecision;
381 font32A->lfClipPrecision = font32W->lfClipPrecision;
382 font32A->lfQuality = font32W->lfQuality;
383 font32A->lfPitchAndFamily = font32W->lfPitchAndFamily;
384 WideCharToMultiByte( CP_ACP, 0, font32W->lfFaceName, -1, font32A->lfFaceName, LF_FACESIZE, NULL, NULL );
385 font32A->lfFaceName[LF_FACESIZE-1] = 0;
388 static void SYSPARAMS_LogFont32ATo32W( const LOGFONTA* font32A, LPLOGFONTW font32W )
390 font32W->lfHeight = font32A->lfHeight;
391 font32W->lfWidth = font32A->lfWidth;
392 font32W->lfEscapement = font32A->lfEscapement;
393 font32W->lfOrientation = font32A->lfOrientation;
394 font32W->lfWeight = font32A->lfWeight;
395 font32W->lfItalic = font32A->lfItalic;
396 font32W->lfUnderline = font32A->lfUnderline;
397 font32W->lfStrikeOut = font32A->lfStrikeOut;
398 font32W->lfCharSet = font32A->lfCharSet;
399 font32W->lfOutPrecision = font32A->lfOutPrecision;
400 font32W->lfClipPrecision = font32A->lfClipPrecision;
401 font32W->lfQuality = font32A->lfQuality;
402 font32W->lfPitchAndFamily = font32A->lfPitchAndFamily;
403 MultiByteToWideChar( CP_ACP, 0, font32A->lfFaceName, -1, font32W->lfFaceName, LF_FACESIZE );
404 font32W->lfFaceName[LF_FACESIZE-1] = 0;
407 static void SYSPARAMS_NonClientMetrics32WTo32A( const NONCLIENTMETRICSW* lpnm32W, LPNONCLIENTMETRICSA lpnm32A )
409 lpnm32A->iBorderWidth = lpnm32W->iBorderWidth;
410 lpnm32A->iScrollWidth = lpnm32W->iScrollWidth;
411 lpnm32A->iScrollHeight = lpnm32W->iScrollHeight;
412 lpnm32A->iCaptionWidth = lpnm32W->iCaptionWidth;
413 lpnm32A->iCaptionHeight = lpnm32W->iCaptionHeight;
414 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfCaptionFont, &lpnm32A->lfCaptionFont );
415 lpnm32A->iSmCaptionWidth = lpnm32W->iSmCaptionWidth;
416 lpnm32A->iSmCaptionHeight = lpnm32W->iSmCaptionHeight;
417 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfSmCaptionFont, &lpnm32A->lfSmCaptionFont );
418 lpnm32A->iMenuWidth = lpnm32W->iMenuWidth;
419 lpnm32A->iMenuHeight = lpnm32W->iMenuHeight;
420 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMenuFont, &lpnm32A->lfMenuFont );
421 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfStatusFont, &lpnm32A->lfStatusFont );
422 SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMessageFont, &lpnm32A->lfMessageFont );
423 if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
425 if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
426 lpnm32A->iPaddedBorderWidth = lpnm32W->iPaddedBorderWidth;
427 else
428 lpnm32A->iPaddedBorderWidth = 0;
432 static void SYSPARAMS_NonClientMetrics32ATo32W( const NONCLIENTMETRICSA* lpnm32A, LPNONCLIENTMETRICSW lpnm32W )
434 lpnm32W->iBorderWidth = lpnm32A->iBorderWidth;
435 lpnm32W->iScrollWidth = lpnm32A->iScrollWidth;
436 lpnm32W->iScrollHeight = lpnm32A->iScrollHeight;
437 lpnm32W->iCaptionWidth = lpnm32A->iCaptionWidth;
438 lpnm32W->iCaptionHeight = lpnm32A->iCaptionHeight;
439 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfCaptionFont, &lpnm32W->lfCaptionFont );
440 lpnm32W->iSmCaptionWidth = lpnm32A->iSmCaptionWidth;
441 lpnm32W->iSmCaptionHeight = lpnm32A->iSmCaptionHeight;
442 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfSmCaptionFont, &lpnm32W->lfSmCaptionFont );
443 lpnm32W->iMenuWidth = lpnm32A->iMenuWidth;
444 lpnm32W->iMenuHeight = lpnm32A->iMenuHeight;
445 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMenuFont, &lpnm32W->lfMenuFont );
446 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfStatusFont, &lpnm32W->lfStatusFont );
447 SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMessageFont, &lpnm32W->lfMessageFont );
448 if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
450 if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
451 lpnm32W->iPaddedBorderWidth = lpnm32A->iPaddedBorderWidth;
452 else
453 lpnm32W->iPaddedBorderWidth = 0;
458 /* Helper functions to retrieve monitors info */
460 struct monitor_info
462 int count;
463 RECT primary_rect;
464 RECT virtual_rect;
467 static BOOL CALLBACK monitor_info_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
469 MONITORINFO mi;
470 struct monitor_info *info = (struct monitor_info *)lp;
471 info->count++;
472 UnionRect( &info->virtual_rect, &info->virtual_rect, rect );
473 mi.cbSize = sizeof(mi);
474 if (GetMonitorInfoW( monitor, &mi ) && (mi.dwFlags & MONITORINFOF_PRIMARY))
475 info->primary_rect = mi.rcMonitor;
476 return TRUE;
479 static void get_monitors_info( struct monitor_info *info )
481 info->count = 0;
482 SetRectEmpty( &info->primary_rect );
483 SetRectEmpty( &info->virtual_rect );
484 EnumDisplayMonitors( 0, NULL, monitor_info_proc, (LPARAM)info );
487 RECT get_virtual_screen_rect(void)
489 struct monitor_info info;
490 get_monitors_info( &info );
491 return info.virtual_rect;
494 /* get text metrics and/or "average" char width of the specified logfont
495 * for the specified dc */
496 static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz)
498 HFONT hfont, hfontsav;
499 TEXTMETRICW tm;
500 if( !ptm) ptm = &tm;
501 hfont = CreateFontIndirectW( plf);
502 if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) {
503 ptm->tmHeight = -1;
504 if( psz) *psz = 10;
505 if( hfont) DeleteObject( hfont);
506 return;
508 GetTextMetricsW( hdc, ptm);
509 if( psz)
510 if( !(*psz = GdiGetCharDimensions( hdc, ptm, NULL)))
511 *psz = 10;
512 SelectObject( hdc, hfontsav);
513 DeleteObject( hfont);
516 /***********************************************************************
517 * SYSPARAMS_NotifyChange
519 * Sends notification about system parameter update.
521 static void SYSPARAMS_NotifyChange( UINT uiAction, UINT fWinIni )
523 static const WCHAR emptyW[1];
525 if (notify_change)
527 if (fWinIni & SPIF_UPDATEINIFILE)
529 if (fWinIni & (SPIF_SENDWININICHANGE | SPIF_SENDCHANGE))
530 SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
531 uiAction, (LPARAM) emptyW,
532 SMTO_ABORTIFHUNG, 2000, NULL );
534 else
536 /* FIXME notify other wine processes with internal message */
541 /* retrieve the cached base keys for a given entry */
542 static BOOL get_base_keys( enum parameter_key index, HKEY *base_key, HKEY *volatile_key )
544 static HKEY base_keys[NB_PARAM_KEYS];
545 static HKEY volatile_keys[NB_PARAM_KEYS];
546 HKEY key;
548 if (!base_keys[index] && base_key)
550 if (RegCreateKeyW( HKEY_CURRENT_USER, parameter_key_names[index], &key )) return FALSE;
551 if (InterlockedCompareExchangePointer( (void **)&base_keys[index], key, 0 ))
552 RegCloseKey( key );
554 if (!volatile_keys[index] && volatile_key)
556 if (RegCreateKeyExW( volatile_base_key, parameter_key_names[index],
557 0, 0, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &key, 0 )) return FALSE;
558 if (InterlockedCompareExchangePointer( (void **)&volatile_keys[index], key, 0 ))
559 RegCloseKey( key );
561 if (base_key) *base_key = base_keys[index];
562 if (volatile_key) *volatile_key = volatile_keys[index];
563 return TRUE;
566 /* load a value to a registry entry */
567 static DWORD load_entry( struct sysparam_entry *entry, void *data, DWORD size )
569 DWORD type, count;
570 HKEY base_key, volatile_key;
572 if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
574 count = size;
575 if (RegQueryValueExW( volatile_key, entry->regval + 1, NULL, &type, data, &count ))
577 count = size;
578 if (RegQueryValueExW( base_key, entry->regval + 1, NULL, &type, data, &count )) count = 0;
580 /* make sure strings are null-terminated */
581 if (size && count == size && type == REG_SZ) ((WCHAR *)data)[count / sizeof(WCHAR) - 1] = 0;
582 entry->loaded = TRUE;
583 return count;
586 /* save a value to a registry entry */
587 static BOOL save_entry( const struct sysparam_entry *entry, const void *data, DWORD size,
588 DWORD type, UINT flags )
590 HKEY base_key, volatile_key;
592 if (flags & SPIF_UPDATEINIFILE)
594 if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
595 if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
596 RegDeleteValueW( volatile_key, entry->regval + 1 );
598 if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
599 RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
601 else
603 if (!get_base_keys( entry->regval[0], NULL, &volatile_key )) return FALSE;
604 if (RegSetValueExW( volatile_key, entry->regval + 1, 0, type, data, size )) return FALSE;
606 return TRUE;
609 /* save a string value to a registry entry */
610 static BOOL save_entry_string( const struct sysparam_entry *entry, const WCHAR *str, UINT flags )
612 return save_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ, flags );
615 /* initialize an entry in the registry if missing */
616 static BOOL init_entry( struct sysparam_entry *entry, const void *data, DWORD size, DWORD type )
618 HKEY base_key;
620 if (!get_base_keys( entry->regval[0], &base_key, NULL )) return FALSE;
621 if (!RegQueryValueExW( base_key, entry->regval + 1, NULL, NULL, NULL, NULL )) return TRUE;
622 if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
623 if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
624 RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
625 entry->loaded = TRUE;
626 return TRUE;
629 /* initialize a string value in the registry if missing */
630 static BOOL init_entry_string( struct sysparam_entry *entry, const WCHAR *str )
632 return init_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ );
635 HDC get_display_dc(void)
637 static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
638 EnterCriticalSection( &display_dc_section );
639 if (!display_dc) display_dc = CreateDCW( DISPLAY, NULL, NULL, NULL );
640 return display_dc;
643 void release_display_dc( HDC hdc )
645 LeaveCriticalSection( &display_dc_section );
648 /* map value from system dpi to standard 96 dpi for storing in the registry */
649 static int map_from_system_dpi( int val )
651 return MulDiv( val, USER_DEFAULT_SCREEN_DPI, GetDpiForSystem() );
654 /* map value from 96 dpi to system or custom dpi */
655 static int map_to_dpi( int val, UINT dpi )
657 if (!dpi) dpi = GetDpiForSystem();
658 return MulDiv( val, dpi, USER_DEFAULT_SCREEN_DPI );
661 static INT CALLBACK real_fontname_proc(const LOGFONTW *lf, const TEXTMETRICW *ntm, DWORD type, LPARAM lparam)
663 const ENUMLOGFONTW *elf = (const ENUMLOGFONTW *)lf;
664 LOGFONTW *lfW = (LOGFONTW *)lparam;
666 lstrcpynW(lfW->lfFaceName, elf->elfFullName, LF_FACESIZE);
667 return 0;
670 static void get_real_fontname( HDC hdc, LOGFONTW *lf )
672 EnumFontFamiliesExW(hdc, lf, real_fontname_proc, (LPARAM)lf, 0);
675 /* adjust some of the raw values found in the registry */
676 static void normalize_nonclientmetrics( NONCLIENTMETRICSW *pncm)
678 TEXTMETRICW tm;
679 HDC hdc = get_display_dc();
681 if( pncm->iBorderWidth < 1) pncm->iBorderWidth = 1;
682 if( pncm->iCaptionWidth < 8) pncm->iCaptionWidth = 8;
683 if( pncm->iScrollWidth < 8) pncm->iScrollWidth = 8;
684 if( pncm->iScrollHeight < 8) pncm->iScrollHeight = 8;
686 /* adjust some heights to the corresponding font */
687 get_text_metr_size( hdc, &pncm->lfMenuFont, &tm, NULL);
688 pncm->iMenuHeight = max( pncm->iMenuHeight, 2 + tm.tmHeight + tm.tmExternalLeading );
689 get_real_fontname( hdc, &pncm->lfMenuFont );
690 get_text_metr_size( hdc, &pncm->lfCaptionFont, &tm, NULL);
691 pncm->iCaptionHeight = max( pncm->iCaptionHeight, 2 + tm.tmHeight);
692 get_real_fontname( hdc, &pncm->lfCaptionFont );
693 get_text_metr_size( hdc, &pncm->lfSmCaptionFont, &tm, NULL);
694 pncm->iSmCaptionHeight = max( pncm->iSmCaptionHeight, 2 + tm.tmHeight);
695 get_real_fontname( hdc, &pncm->lfSmCaptionFont );
697 get_real_fontname( hdc, &pncm->lfStatusFont );
698 get_real_fontname( hdc, &pncm->lfMessageFont );
699 release_display_dc( hdc );
702 static BOOL CALLBACK enum_monitors( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
704 MONITORINFO mi;
706 mi.cbSize = sizeof(mi);
707 if (GetMonitorInfoW( monitor, &mi ) && (mi.dwFlags & MONITORINFOF_PRIMARY))
709 LPRECT work = (LPRECT)lp;
710 *work = mi.rcWork;
711 return FALSE;
713 return TRUE;
716 /* load a uint parameter from the registry */
717 static BOOL get_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
719 if (!ptr_param) return FALSE;
721 if (!entry->hdr.loaded)
723 WCHAR buf[32];
725 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->uint.val = atoiW( buf );
727 *(UINT *)ptr_param = entry->uint.val;
728 return TRUE;
731 /* set a uint parameter in the registry */
732 static BOOL set_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
734 WCHAR buf[32];
736 wsprintfW( buf, CSu, int_param );
737 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
738 entry->uint.val = int_param;
739 entry->hdr.loaded = TRUE;
740 return TRUE;
743 /* initialize a uint parameter */
744 static BOOL init_uint_entry( union sysparam_all_entry *entry )
746 WCHAR buf[32];
748 wsprintfW( buf, CSu, entry->uint.val );
749 return init_entry_string( &entry->hdr, buf );
752 /* set an int parameter in the registry */
753 static BOOL set_int_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
755 WCHAR buf[32];
757 wsprintfW( buf, CSd, int_param );
758 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
759 entry->uint.val = int_param;
760 entry->hdr.loaded = TRUE;
761 return TRUE;
764 /* initialize an int parameter */
765 static BOOL init_int_entry( union sysparam_all_entry *entry )
767 WCHAR buf[32];
769 wsprintfW( buf, CSd, entry->uint.val );
770 return init_entry_string( &entry->hdr, buf );
773 /* load a twips parameter from the registry */
774 static BOOL get_twips_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
776 int val;
778 if (!ptr_param) return FALSE;
780 if (!entry->hdr.loaded)
782 WCHAR buf[32];
784 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->uint.val = atoiW( buf );
787 /* Dimensions are quoted as being "twips" values if negative and pixels if positive.
788 * One inch is 1440 twips.
789 * See for example
790 * Technical Reference to the Windows 2000 Registry ->
791 * HKEY_CURRENT_USER -> Control Panel -> Desktop -> WindowMetrics
793 val = entry->uint.val;
794 if (val < 0)
795 val = MulDiv( -val, dpi, 1440 );
796 else
797 val = map_to_dpi( val, dpi );
799 *(int *)ptr_param = val;
800 return TRUE;
803 /* set a twips parameter in the registry */
804 static BOOL set_twips_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
806 int val = int_param;
807 if (val > 0) val = map_from_system_dpi( val );
808 return set_int_entry( entry, val, ptr_param, flags );
811 /* load a bool parameter from the registry */
812 static BOOL get_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
814 if (!ptr_param) return FALSE;
816 if (!entry->hdr.loaded)
818 WCHAR buf[32];
820 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = atoiW( buf ) != 0;
822 *(UINT *)ptr_param = entry->bool.val;
823 return TRUE;
826 /* set a bool parameter in the registry */
827 static BOOL set_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
829 WCHAR buf[32];
831 wsprintfW( buf, CSu, int_param != 0 );
832 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
833 entry->bool.val = int_param != 0;
834 entry->hdr.loaded = TRUE;
835 return TRUE;
838 /* initialize a bool parameter */
839 static BOOL init_bool_entry( union sysparam_all_entry *entry )
841 WCHAR buf[32];
843 wsprintfW( buf, CSu, entry->bool.val != 0 );
844 return init_entry_string( &entry->hdr, buf );
847 /* load a bool parameter using Yes/No strings from the registry */
848 static BOOL get_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
850 if (!ptr_param) return FALSE;
852 if (!entry->hdr.loaded)
854 WCHAR buf[32];
856 if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = !lstrcmpiW( Yes, buf );
858 *(UINT *)ptr_param = entry->bool.val;
859 return TRUE;
862 /* set a bool parameter using Yes/No strings from the registry */
863 static BOOL set_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
865 const WCHAR *str = int_param ? Yes : No;
867 if (!save_entry_string( &entry->hdr, str, flags )) return FALSE;
868 entry->bool.val = int_param != 0;
869 entry->hdr.loaded = TRUE;
870 return TRUE;
873 /* initialize a bool parameter using Yes/No strings */
874 static BOOL init_yesno_entry( union sysparam_all_entry *entry )
876 return init_entry_string( &entry->hdr, entry->bool.val ? Yes : No );
879 /* load a dword (binary) parameter from the registry */
880 static BOOL get_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
882 if (!ptr_param) return FALSE;
884 if (!entry->hdr.loaded)
886 DWORD val;
887 if (load_entry( &entry->hdr, &val, sizeof(val) ) == sizeof(DWORD)) entry->dword.val = val;
889 *(DWORD *)ptr_param = entry->dword.val;
890 return TRUE;
893 /* set a dword (binary) parameter in the registry */
894 static BOOL set_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
896 DWORD val = PtrToUlong( ptr_param );
898 if (!save_entry( &entry->hdr, &val, sizeof(val), REG_DWORD, flags )) return FALSE;
899 entry->dword.val = val;
900 entry->hdr.loaded = TRUE;
901 return TRUE;
904 /* initialize a dword parameter */
905 static BOOL init_dword_entry( union sysparam_all_entry *entry )
907 return init_entry( &entry->hdr, &entry->dword.val, sizeof(entry->dword.val), REG_DWORD );
910 /* load an RGB parameter from the registry */
911 static BOOL get_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
913 if (!ptr_param) return FALSE;
915 if (!entry->hdr.loaded)
917 WCHAR buf[32];
919 if (load_entry( &entry->hdr, buf, sizeof(buf) ))
921 DWORD r, g, b;
922 WCHAR *end, *str = buf;
924 r = strtoulW( str, &end, 10 );
925 if (end == str || !*end) goto done;
926 str = end + 1;
927 g = strtoulW( str, &end, 10 );
928 if (end == str || !*end) goto done;
929 str = end + 1;
930 b = strtoulW( str, &end, 10 );
931 if (end == str) goto done;
932 if (r > 255 || g > 255 || b > 255) goto done;
933 entry->rgb.val = RGB( r, g, b );
936 done:
937 *(COLORREF *)ptr_param = entry->rgb.val;
938 return TRUE;
941 /* set an RGB parameter in the registry */
942 static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
944 WCHAR buf[32];
945 HBRUSH brush;
946 HPEN pen;
948 wsprintfW( buf, CSrgb, GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
949 if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
950 entry->rgb.val = int_param;
951 entry->hdr.loaded = TRUE;
952 if ((brush = InterlockedExchangePointer( (void **)&entry->rgb.brush, 0 )))
954 __wine_make_gdi_object_system( brush, FALSE );
955 DeleteObject( brush );
957 if ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
959 __wine_make_gdi_object_system( pen, FALSE );
960 DeleteObject( pen );
962 return TRUE;
965 /* initialize an RGB parameter */
966 static BOOL init_rgb_entry( union sysparam_all_entry *entry )
968 WCHAR buf[32];
970 wsprintfW( buf, CSrgb, GetRValue(entry->rgb.val), GetGValue(entry->rgb.val), GetBValue(entry->rgb.val) );
971 return init_entry_string( &entry->hdr, buf );
974 /* load a font (binary) parameter from the registry */
975 static BOOL get_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
977 LOGFONTW font;
979 if (!ptr_param) return FALSE;
981 if (!entry->hdr.loaded)
983 switch (load_entry( &entry->hdr, &font, sizeof(font) ))
985 case sizeof(font):
986 if (font.lfHeight > 0) /* positive height value means points ( inch/72 ) */
987 font.lfHeight = -MulDiv( font.lfHeight, USER_DEFAULT_SCREEN_DPI, 72 );
988 entry->font.val = font;
989 break;
990 case sizeof(LOGFONT16): /* win9x-winME format */
991 SYSPARAMS_LogFont16To32W( (LOGFONT16 *)&font, &entry->font.val );
992 if (entry->font.val.lfHeight > 0)
993 entry->font.val.lfHeight = -MulDiv( entry->font.val.lfHeight, USER_DEFAULT_SCREEN_DPI, 72 );
994 break;
995 default:
996 WARN( "Unknown format in key %s value %s\n",
997 debugstr_w( parameter_key_names[entry->hdr.regval[0]] ),
998 debugstr_w( entry->hdr.regval + 1 ));
999 /* fall through */
1000 case 0: /* use the default GUI font */
1001 GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(font), &font );
1002 font.lfHeight = map_from_system_dpi( font.lfHeight );
1003 font.lfWeight = entry->font.weight;
1004 entry->font.val = font;
1005 break;
1007 entry->hdr.loaded = TRUE;
1009 font = entry->font.val;
1010 font.lfHeight = map_to_dpi( font.lfHeight, dpi );
1011 *(LOGFONTW *)ptr_param = font;
1012 return TRUE;
1015 /* set a font (binary) parameter in the registry */
1016 static BOOL set_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1018 LOGFONTW font;
1019 WCHAR *ptr;
1021 memcpy( &font, ptr_param, sizeof(font) );
1022 /* zero pad the end of lfFaceName so we don't save uninitialised data */
1023 ptr = memchrW( font.lfFaceName, 0, LF_FACESIZE );
1024 if (ptr) memset( ptr, 0, (font.lfFaceName + LF_FACESIZE - ptr) * sizeof(WCHAR) );
1025 if (font.lfHeight < 0) font.lfHeight = map_from_system_dpi( font.lfHeight );
1027 if (!save_entry( &entry->hdr, &font, sizeof(font), REG_BINARY, flags )) return FALSE;
1028 entry->font.val = font;
1029 entry->hdr.loaded = TRUE;
1030 return TRUE;
1033 /* initialize a font (binary) parameter */
1034 static BOOL init_font_entry( union sysparam_all_entry *entry )
1036 GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(entry->font.val), &entry->font.val );
1037 entry->font.val.lfHeight = map_from_system_dpi( entry->font.val.lfHeight );
1038 entry->font.val.lfWeight = entry->font.weight;
1039 return init_entry( &entry->hdr, &entry->font.val, sizeof(entry->font.val), REG_BINARY );
1042 /* get a path parameter in the registry */
1043 static BOOL get_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1045 if (!ptr_param) return FALSE;
1047 if (!entry->hdr.loaded)
1049 WCHAR buffer[MAX_PATH];
1051 if (load_entry( &entry->hdr, buffer, sizeof(buffer) ))
1052 lstrcpynW( entry->path.path, buffer, MAX_PATH );
1054 lstrcpynW( ptr_param, entry->path.path, int_param );
1055 return TRUE;
1058 /* set a path parameter in the registry */
1059 static BOOL set_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1061 WCHAR buffer[MAX_PATH];
1062 BOOL ret;
1064 lstrcpynW( buffer, ptr_param, MAX_PATH );
1065 ret = save_entry_string( &entry->hdr, buffer, flags );
1066 if (ret)
1068 strcpyW( entry->path.path, buffer );
1069 entry->hdr.loaded = TRUE;
1071 return ret;
1074 /* initialize a path parameter */
1075 static BOOL init_path_entry( union sysparam_all_entry *entry )
1077 return init_entry_string( &entry->hdr, entry->path.path );
1080 /* get a binary parameter in the registry */
1081 static BOOL get_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1083 if (!ptr_param) return FALSE;
1085 if (!entry->hdr.loaded)
1087 void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1088 DWORD len = load_entry( &entry->hdr, buffer, entry->bin.size );
1090 if (len)
1092 memcpy( entry->bin.ptr, buffer, entry->bin.size );
1093 memset( (char *)entry->bin.ptr + len, 0, entry->bin.size - len );
1095 HeapFree( GetProcessHeap(), 0, buffer );
1097 memcpy( ptr_param, entry->bin.ptr, min( int_param, entry->bin.size ) );
1098 return TRUE;
1101 /* set a binary parameter in the registry */
1102 static BOOL set_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1104 BOOL ret;
1105 void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1107 memcpy( buffer, entry->bin.ptr, entry->bin.size );
1108 memcpy( buffer, ptr_param, min( int_param, entry->bin.size ));
1109 ret = save_entry( &entry->hdr, buffer, entry->bin.size, REG_BINARY, flags );
1110 if (ret)
1112 memcpy( entry->bin.ptr, buffer, entry->bin.size );
1113 entry->hdr.loaded = TRUE;
1115 HeapFree( GetProcessHeap(), 0, buffer );
1116 return ret;
1119 /* initialize a binary parameter */
1120 static BOOL init_binary_entry( union sysparam_all_entry *entry )
1122 return init_entry( &entry->hdr, entry->bin.ptr, entry->bin.size, REG_BINARY );
1125 /* get a user pref parameter in the registry */
1126 static BOOL get_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT dpi )
1128 union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1129 BYTE prefs[8];
1131 if (!ptr_param) return FALSE;
1133 if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs, dpi )) return FALSE;
1134 *(BOOL *)ptr_param = (prefs[entry->pref.offset] & entry->pref.mask) != 0;
1135 return TRUE;
1138 /* set a user pref parameter in the registry */
1139 static BOOL set_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1141 union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1142 BYTE prefs[8];
1144 parent_entry->hdr.loaded = FALSE; /* force loading it again */
1145 if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs, GetDpiForSystem() )) return FALSE;
1147 if (PtrToUlong( ptr_param )) prefs[entry->pref.offset] |= entry->pref.mask;
1148 else prefs[entry->pref.offset] &= ~entry->pref.mask;
1150 return parent_entry->hdr.set( parent_entry, sizeof(prefs), prefs, flags );
1153 static BOOL get_entry_dpi( void *ptr, UINT int_param, void *ptr_param, UINT dpi )
1155 union sysparam_all_entry *entry = ptr;
1156 return entry->hdr.get( entry, int_param, ptr_param, dpi );
1159 static BOOL get_entry( void *ptr, UINT int_param, void *ptr_param )
1161 return get_entry_dpi( ptr, int_param, ptr_param, GetDpiForSystem() );
1164 static BOOL set_entry( void *ptr, UINT int_param, void *ptr_param, UINT flags )
1166 union sysparam_all_entry *entry = ptr;
1167 return entry->hdr.set( entry, int_param, ptr_param, flags );
1170 #define UINT_ENTRY(name,val) \
1171 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1172 name ##_VALNAME }, (val) }
1174 #define UINT_ENTRY_MIRROR(name,val) \
1175 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1176 name ##_VALNAME, name ##_MIRROR }, (val) }
1178 #define INT_ENTRY(name,val) \
1179 struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_int_entry, init_int_entry, \
1180 name ##_VALNAME }, (val) }
1182 #define BOOL_ENTRY(name,val) \
1183 struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1184 name ##_VALNAME }, (val) }
1186 #define BOOL_ENTRY_MIRROR(name,val) \
1187 struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1188 name ##_VALNAME, name ##_MIRROR }, (val) }
1190 #define YESNO_ENTRY(name,val) \
1191 struct sysparam_bool_entry entry_##name = { { get_yesno_entry, set_yesno_entry, init_yesno_entry, \
1192 name ##_VALNAME }, (val) }
1194 #define TWIPS_ENTRY(name,val) \
1195 struct sysparam_uint_entry entry_##name = { { get_twips_entry, set_twips_entry, init_int_entry, \
1196 name ##_VALNAME }, (val) }
1198 #define DWORD_ENTRY(name,val) \
1199 struct sysparam_dword_entry entry_##name = { { get_dword_entry, set_dword_entry, init_dword_entry, \
1200 name ##_VALNAME }, (val) }
1202 #define BINARY_ENTRY(name,data) \
1203 struct sysparam_binary_entry entry_##name = { { get_binary_entry, set_binary_entry, init_binary_entry, \
1204 name ##_VALNAME }, data, sizeof(data) }
1206 #define PATH_ENTRY(name) \
1207 struct sysparam_path_entry entry_##name = { { get_path_entry, set_path_entry, init_path_entry, \
1208 name ##_VALNAME } }
1210 #define FONT_ENTRY(name,weight) \
1211 struct sysparam_font_entry entry_##name = { { get_font_entry, set_font_entry, init_font_entry, \
1212 name ##_VALNAME }, (weight) }
1214 #define USERPREF_ENTRY(name,offset,mask) \
1215 struct sysparam_pref_entry entry_##name = { { get_userpref_entry, set_userpref_entry }, \
1216 &entry_USERPREFERENCESMASK, (offset), (mask) }
1218 static UINT_ENTRY( DRAGWIDTH, 4 );
1219 static UINT_ENTRY( DRAGHEIGHT, 4 );
1220 static UINT_ENTRY( DOUBLECLICKTIME, 500 );
1221 static UINT_ENTRY( FONTSMOOTHING, 2 );
1222 static UINT_ENTRY( GRIDGRANULARITY, 0 );
1223 static UINT_ENTRY( KEYBOARDDELAY, 1 );
1224 static UINT_ENTRY( KEYBOARDSPEED, 31 );
1225 static UINT_ENTRY( MENUSHOWDELAY, 400 );
1226 static UINT_ENTRY( MINARRANGE, ARW_HIDE );
1227 static UINT_ENTRY( MINHORZGAP, 0 );
1228 static UINT_ENTRY( MINVERTGAP, 0 );
1229 static UINT_ENTRY( MINWIDTH, 154 );
1230 static UINT_ENTRY( MOUSEHOVERHEIGHT, 4 );
1231 static UINT_ENTRY( MOUSEHOVERTIME, 400 );
1232 static UINT_ENTRY( MOUSEHOVERWIDTH, 4 );
1233 static UINT_ENTRY( MOUSESPEED, 10 );
1234 static UINT_ENTRY( MOUSETRAILS, 0 );
1235 static UINT_ENTRY( SCREENSAVETIMEOUT, 300 );
1236 static UINT_ENTRY( WHEELSCROLLCHARS, 3 );
1237 static UINT_ENTRY( WHEELSCROLLLINES, 3 );
1238 static UINT_ENTRY_MIRROR( DOUBLECLKHEIGHT, 4 );
1239 static UINT_ENTRY_MIRROR( DOUBLECLKWIDTH, 4 );
1240 static UINT_ENTRY_MIRROR( MENUDROPALIGNMENT, 0 );
1242 static INT_ENTRY( MOUSETHRESHOLD1, 6 );
1243 static INT_ENTRY( MOUSETHRESHOLD2, 10 );
1244 static INT_ENTRY( MOUSEACCELERATION, 1 );
1246 static BOOL_ENTRY( BLOCKSENDINPUTRESETS, FALSE );
1247 static BOOL_ENTRY( DRAGFULLWINDOWS, FALSE );
1248 static BOOL_ENTRY( KEYBOARDPREF, TRUE );
1249 static BOOL_ENTRY( LOWPOWERACTIVE, FALSE );
1250 static BOOL_ENTRY( MOUSEBUTTONSWAP, FALSE );
1251 static BOOL_ENTRY( POWEROFFACTIVE, FALSE );
1252 static BOOL_ENTRY( SCREENREADER, FALSE );
1253 static BOOL_ENTRY( SCREENSAVEACTIVE, TRUE );
1254 static BOOL_ENTRY( SCREENSAVERRUNNING, FALSE );
1255 static BOOL_ENTRY( SHOWSOUNDS, FALSE );
1256 static BOOL_ENTRY( SNAPTODEFBUTTON, FALSE );
1257 static BOOL_ENTRY_MIRROR( ICONTITLEWRAP, TRUE );
1258 static BOOL_ENTRY( AUDIODESC_ON, FALSE);
1260 static YESNO_ENTRY( BEEP, TRUE );
1262 static TWIPS_ENTRY( BORDER, -15 );
1263 static TWIPS_ENTRY( CAPTIONHEIGHT, -270 );
1264 static TWIPS_ENTRY( CAPTIONWIDTH, -270 );
1265 static TWIPS_ENTRY( ICONHORIZONTALSPACING, -1125 );
1266 static TWIPS_ENTRY( ICONVERTICALSPACING, -1125 );
1267 static TWIPS_ENTRY( MENUHEIGHT, -270 );
1268 static TWIPS_ENTRY( MENUWIDTH, -270 );
1269 static TWIPS_ENTRY( PADDEDBORDERWIDTH, 0 );
1270 static TWIPS_ENTRY( SCROLLHEIGHT, -240 );
1271 static TWIPS_ENTRY( SCROLLWIDTH, -240 );
1272 static TWIPS_ENTRY( SMCAPTIONHEIGHT, -225 );
1273 static TWIPS_ENTRY( SMCAPTIONWIDTH, -225 );
1275 static DWORD_ENTRY( ACTIVEWINDOWTRACKING, 0 );
1276 static DWORD_ENTRY( ACTIVEWNDTRKTIMEOUT, 0 );
1277 static DWORD_ENTRY( CARETWIDTH, 1 );
1278 static DWORD_ENTRY( DPISCALINGVER, 0 );
1279 static DWORD_ENTRY( FOCUSBORDERHEIGHT, 1 );
1280 static DWORD_ENTRY( FOCUSBORDERWIDTH, 1 );
1281 static DWORD_ENTRY( FONTSMOOTHINGCONTRAST, 0 );
1282 static DWORD_ENTRY( FONTSMOOTHINGORIENTATION, FE_FONTSMOOTHINGORIENTATIONRGB );
1283 static DWORD_ENTRY( FONTSMOOTHINGTYPE, FE_FONTSMOOTHINGSTANDARD );
1284 static DWORD_ENTRY( FOREGROUNDFLASHCOUNT, 3 );
1285 static DWORD_ENTRY( FOREGROUNDLOCKTIMEOUT, 0 );
1286 static DWORD_ENTRY( LOGPIXELS, 0 );
1287 static DWORD_ENTRY( MOUSECLICKLOCKTIME, 1200 );
1288 static DWORD_ENTRY( AUDIODESC_LOCALE, 0 );
1290 static PATH_ENTRY( DESKPATTERN );
1291 static PATH_ENTRY( DESKWALLPAPER );
1293 static BYTE user_prefs[8] = { 0x30, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00 };
1294 static BINARY_ENTRY( USERPREFERENCESMASK, user_prefs );
1296 static FONT_ENTRY( CAPTIONLOGFONT, FW_BOLD );
1297 static FONT_ENTRY( ICONTITLELOGFONT, FW_NORMAL );
1298 static FONT_ENTRY( MENULOGFONT, FW_NORMAL );
1299 static FONT_ENTRY( MESSAGELOGFONT, FW_NORMAL );
1300 static FONT_ENTRY( SMCAPTIONLOGFONT, FW_NORMAL );
1301 static FONT_ENTRY( STATUSLOGFONT, FW_NORMAL );
1303 static USERPREF_ENTRY( MENUANIMATION, 0, 0x02 );
1304 static USERPREF_ENTRY( COMBOBOXANIMATION, 0, 0x04 );
1305 static USERPREF_ENTRY( LISTBOXSMOOTHSCROLLING, 0, 0x08 );
1306 static USERPREF_ENTRY( GRADIENTCAPTIONS, 0, 0x10 );
1307 static USERPREF_ENTRY( KEYBOARDCUES, 0, 0x20 );
1308 static USERPREF_ENTRY( ACTIVEWNDTRKZORDER, 0, 0x40 );
1309 static USERPREF_ENTRY( HOTTRACKING, 0, 0x80 );
1310 static USERPREF_ENTRY( MENUFADE, 1, 0x02 );
1311 static USERPREF_ENTRY( SELECTIONFADE, 1, 0x04 );
1312 static USERPREF_ENTRY( TOOLTIPANIMATION, 1, 0x08 );
1313 static USERPREF_ENTRY( TOOLTIPFADE, 1, 0x10 );
1314 static USERPREF_ENTRY( CURSORSHADOW, 1, 0x20 );
1315 static USERPREF_ENTRY( MOUSESONAR, 1, 0x40 );
1316 static USERPREF_ENTRY( MOUSECLICKLOCK, 1, 0x80 );
1317 static USERPREF_ENTRY( MOUSEVANISH, 2, 0x01 );
1318 static USERPREF_ENTRY( FLATMENU, 2, 0x02 );
1319 static USERPREF_ENTRY( DROPSHADOW, 2, 0x04 );
1320 static USERPREF_ENTRY( UIEFFECTS, 3, 0x80 );
1321 static USERPREF_ENTRY( DISABLEOVERLAPPEDCONTENT, 4, 0x01 );
1322 static USERPREF_ENTRY( CLIENTAREAANIMATION, 4, 0x02 );
1323 static USERPREF_ENTRY( CLEARTYPE, 4, 0x10 );
1324 static USERPREF_ENTRY( SPEECHRECOGNITION, 4, 0x20 );
1326 static struct sysparam_rgb_entry system_colors[] =
1328 #define RGB_ENTRY(name,val) { { get_rgb_entry, set_rgb_entry, init_rgb_entry, name ##_VALNAME }, (val) }
1329 RGB_ENTRY( COLOR_SCROLLBAR, RGB(212, 208, 200) ),
1330 RGB_ENTRY( COLOR_BACKGROUND, RGB(58, 110, 165) ),
1331 RGB_ENTRY( COLOR_ACTIVECAPTION, RGB(10, 36, 106) ),
1332 RGB_ENTRY( COLOR_INACTIVECAPTION, RGB(128, 128, 128) ),
1333 RGB_ENTRY( COLOR_MENU, RGB(212, 208, 200) ),
1334 RGB_ENTRY( COLOR_WINDOW, RGB(255, 255, 255) ),
1335 RGB_ENTRY( COLOR_WINDOWFRAME, RGB(0, 0, 0) ),
1336 RGB_ENTRY( COLOR_MENUTEXT, RGB(0, 0, 0) ),
1337 RGB_ENTRY( COLOR_WINDOWTEXT, RGB(0, 0, 0) ),
1338 RGB_ENTRY( COLOR_CAPTIONTEXT, RGB(255, 255, 255) ),
1339 RGB_ENTRY( COLOR_ACTIVEBORDER, RGB(212, 208, 200) ),
1340 RGB_ENTRY( COLOR_INACTIVEBORDER, RGB(212, 208, 200) ),
1341 RGB_ENTRY( COLOR_APPWORKSPACE, RGB(128, 128, 128) ),
1342 RGB_ENTRY( COLOR_HIGHLIGHT, RGB(10, 36, 106) ),
1343 RGB_ENTRY( COLOR_HIGHLIGHTTEXT, RGB(255, 255, 255) ),
1344 RGB_ENTRY( COLOR_BTNFACE, RGB(212, 208, 200) ),
1345 RGB_ENTRY( COLOR_BTNSHADOW, RGB(128, 128, 128) ),
1346 RGB_ENTRY( COLOR_GRAYTEXT, RGB(128, 128, 128) ),
1347 RGB_ENTRY( COLOR_BTNTEXT, RGB(0, 0, 0) ),
1348 RGB_ENTRY( COLOR_INACTIVECAPTIONTEXT, RGB(212, 208, 200) ),
1349 RGB_ENTRY( COLOR_BTNHIGHLIGHT, RGB(255, 255, 255) ),
1350 RGB_ENTRY( COLOR_3DDKSHADOW, RGB(64, 64, 64) ),
1351 RGB_ENTRY( COLOR_3DLIGHT, RGB(212, 208, 200) ),
1352 RGB_ENTRY( COLOR_INFOTEXT, RGB(0, 0, 0) ),
1353 RGB_ENTRY( COLOR_INFOBK, RGB(255, 255, 225) ),
1354 RGB_ENTRY( COLOR_ALTERNATEBTNFACE, RGB(181, 181, 181) ),
1355 RGB_ENTRY( COLOR_HOTLIGHT, RGB(0, 0, 200) ),
1356 RGB_ENTRY( COLOR_GRADIENTACTIVECAPTION, RGB(166, 202, 240) ),
1357 RGB_ENTRY( COLOR_GRADIENTINACTIVECAPTION, RGB(192, 192, 192) ),
1358 RGB_ENTRY( COLOR_MENUHILIGHT, RGB(10, 36, 106) ),
1359 RGB_ENTRY( COLOR_MENUBAR, RGB(212, 208, 200) )
1360 #undef RGB_ENTRY
1363 /* entries that are initialized by default in the registry */
1364 static union sysparam_all_entry * const default_entries[] =
1366 (union sysparam_all_entry *)&entry_ACTIVEWINDOWTRACKING,
1367 (union sysparam_all_entry *)&entry_ACTIVEWNDTRKTIMEOUT,
1368 (union sysparam_all_entry *)&entry_BEEP,
1369 (union sysparam_all_entry *)&entry_BLOCKSENDINPUTRESETS,
1370 (union sysparam_all_entry *)&entry_BORDER,
1371 (union sysparam_all_entry *)&entry_CAPTIONHEIGHT,
1372 (union sysparam_all_entry *)&entry_CAPTIONWIDTH,
1373 (union sysparam_all_entry *)&entry_CARETWIDTH,
1374 (union sysparam_all_entry *)&entry_DESKWALLPAPER,
1375 (union sysparam_all_entry *)&entry_DOUBLECLICKTIME,
1376 (union sysparam_all_entry *)&entry_DOUBLECLKHEIGHT,
1377 (union sysparam_all_entry *)&entry_DOUBLECLKWIDTH,
1378 (union sysparam_all_entry *)&entry_DRAGFULLWINDOWS,
1379 (union sysparam_all_entry *)&entry_DRAGHEIGHT,
1380 (union sysparam_all_entry *)&entry_DRAGWIDTH,
1381 (union sysparam_all_entry *)&entry_FOCUSBORDERHEIGHT,
1382 (union sysparam_all_entry *)&entry_FOCUSBORDERWIDTH,
1383 (union sysparam_all_entry *)&entry_FONTSMOOTHING,
1384 (union sysparam_all_entry *)&entry_FONTSMOOTHINGCONTRAST,
1385 (union sysparam_all_entry *)&entry_FONTSMOOTHINGORIENTATION,
1386 (union sysparam_all_entry *)&entry_FONTSMOOTHINGTYPE,
1387 (union sysparam_all_entry *)&entry_FOREGROUNDFLASHCOUNT,
1388 (union sysparam_all_entry *)&entry_FOREGROUNDLOCKTIMEOUT,
1389 (union sysparam_all_entry *)&entry_ICONHORIZONTALSPACING,
1390 (union sysparam_all_entry *)&entry_ICONTITLEWRAP,
1391 (union sysparam_all_entry *)&entry_ICONVERTICALSPACING,
1392 (union sysparam_all_entry *)&entry_KEYBOARDDELAY,
1393 (union sysparam_all_entry *)&entry_KEYBOARDPREF,
1394 (union sysparam_all_entry *)&entry_KEYBOARDSPEED,
1395 (union sysparam_all_entry *)&entry_LOWPOWERACTIVE,
1396 (union sysparam_all_entry *)&entry_MENUHEIGHT,
1397 (union sysparam_all_entry *)&entry_MENUSHOWDELAY,
1398 (union sysparam_all_entry *)&entry_MENUWIDTH,
1399 (union sysparam_all_entry *)&entry_MOUSEACCELERATION,
1400 (union sysparam_all_entry *)&entry_MOUSEBUTTONSWAP,
1401 (union sysparam_all_entry *)&entry_MOUSECLICKLOCKTIME,
1402 (union sysparam_all_entry *)&entry_MOUSEHOVERHEIGHT,
1403 (union sysparam_all_entry *)&entry_MOUSEHOVERTIME,
1404 (union sysparam_all_entry *)&entry_MOUSEHOVERWIDTH,
1405 (union sysparam_all_entry *)&entry_MOUSESPEED,
1406 (union sysparam_all_entry *)&entry_MOUSETHRESHOLD1,
1407 (union sysparam_all_entry *)&entry_MOUSETHRESHOLD2,
1408 (union sysparam_all_entry *)&entry_PADDEDBORDERWIDTH,
1409 (union sysparam_all_entry *)&entry_SCREENREADER,
1410 (union sysparam_all_entry *)&entry_SCROLLHEIGHT,
1411 (union sysparam_all_entry *)&entry_SCROLLWIDTH,
1412 (union sysparam_all_entry *)&entry_SHOWSOUNDS,
1413 (union sysparam_all_entry *)&entry_SMCAPTIONHEIGHT,
1414 (union sysparam_all_entry *)&entry_SMCAPTIONWIDTH,
1415 (union sysparam_all_entry *)&entry_SNAPTODEFBUTTON,
1416 (union sysparam_all_entry *)&entry_USERPREFERENCESMASK,
1417 (union sysparam_all_entry *)&entry_WHEELSCROLLCHARS,
1418 (union sysparam_all_entry *)&entry_WHEELSCROLLLINES,
1419 (union sysparam_all_entry *)&entry_AUDIODESC_LOCALE,
1420 (union sysparam_all_entry *)&entry_AUDIODESC_ON,
1423 /***********************************************************************
1424 * SYSPARAMS_Init
1426 void SYSPARAMS_Init(void)
1428 static const WCHAR def_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s',0};
1429 static const WCHAR def_value_name[] = {'L','o','g','P','i','x','e','l','s',0};
1430 HKEY key;
1431 DWORD i, dispos, dpi_scaling;
1433 /* this one must be non-volatile */
1434 if (RegCreateKeyW( HKEY_CURRENT_USER, WINE_CURRENT_USER_REGKEY, &key ))
1436 ERR("Can't create wine registry branch\n");
1437 return;
1440 /* @@ Wine registry key: HKCU\Software\Wine\Temporary System Parameters */
1441 if (RegCreateKeyExW( key, WINE_CURRENT_USER_REGKEY_TEMP_PARAMS, 0, 0,
1442 REG_OPTION_VOLATILE, KEY_ALL_ACCESS, 0, &volatile_base_key, &dispos ))
1443 ERR("Can't create non-permanent wine registry branch\n");
1445 RegCloseKey( key );
1447 get_dword_entry( (union sysparam_all_entry *)&entry_LOGPIXELS, 0, &system_dpi, 0 );
1448 if (!system_dpi) /* check fallback key */
1450 if (!RegOpenKeyW( HKEY_CURRENT_CONFIG, def_key_name, &key ))
1452 DWORD type, size = sizeof(system_dpi);
1453 if (RegQueryValueExW( key, def_value_name, NULL, &type, (void *)&system_dpi, &size ) ||
1454 type != REG_DWORD)
1455 system_dpi = 0;
1456 RegCloseKey( key );
1459 if (!system_dpi) system_dpi = USER_DEFAULT_SCREEN_DPI;
1461 /* FIXME: what do the DpiScalingVer flags mean? */
1462 get_dword_entry( (union sysparam_all_entry *)&entry_DPISCALINGVER, 0, &dpi_scaling, 0 );
1463 if (!dpi_scaling)
1465 default_awareness = DPI_AWARENESS_PER_MONITOR_AWARE;
1466 if (dpi_awareness) dpi_awareness = 0x10 | default_awareness;
1469 if (volatile_base_key && dispos == REG_CREATED_NEW_KEY) /* first process, initialize entries */
1471 for (i = 0; i < ARRAY_SIZE( default_entries ); i++)
1472 default_entries[i]->hdr.init( default_entries[i] );
1476 static BOOL update_desktop_wallpaper(void)
1478 DWORD pid;
1480 if (GetWindowThreadProcessId( GetDesktopWindow(), &pid ) && pid == GetCurrentProcessId())
1482 WCHAR wallpaper[MAX_PATH], pattern[256];
1484 entry_DESKWALLPAPER.hdr.loaded = entry_DESKPATTERN.hdr.loaded = FALSE;
1485 if (get_entry( &entry_DESKWALLPAPER, MAX_PATH, wallpaper ) &&
1486 get_entry( &entry_DESKPATTERN, 256, pattern ))
1487 update_wallpaper( wallpaper, pattern );
1489 else SendMessageW( GetDesktopWindow(), WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0 );
1490 return TRUE;
1494 /***********************************************************************
1495 * SystemParametersInfoForDpi (USER32.@)
1497 BOOL WINAPI SystemParametersInfoForDpi( UINT action, UINT val, PVOID ptr, UINT winini, UINT dpi )
1499 BOOL ret = FALSE;
1501 switch (action)
1503 case SPI_GETICONTITLELOGFONT:
1504 ret = get_entry_dpi( &entry_ICONTITLELOGFONT, val, ptr, dpi );
1505 break;
1506 case SPI_GETNONCLIENTMETRICS:
1508 NONCLIENTMETRICSW *ncm = ptr;
1510 if (!ncm) break;
1511 ret = get_entry_dpi( &entry_BORDER, 0, &ncm->iBorderWidth, dpi ) &&
1512 get_entry_dpi( &entry_SCROLLWIDTH, 0, &ncm->iScrollWidth, dpi ) &&
1513 get_entry_dpi( &entry_SCROLLHEIGHT, 0, &ncm->iScrollHeight, dpi ) &&
1514 get_entry_dpi( &entry_CAPTIONWIDTH, 0, &ncm->iCaptionWidth, dpi ) &&
1515 get_entry_dpi( &entry_CAPTIONHEIGHT, 0, &ncm->iCaptionHeight, dpi ) &&
1516 get_entry_dpi( &entry_CAPTIONLOGFONT, 0, &ncm->lfCaptionFont, dpi ) &&
1517 get_entry_dpi( &entry_SMCAPTIONWIDTH, 0, &ncm->iSmCaptionWidth, dpi ) &&
1518 get_entry_dpi( &entry_SMCAPTIONHEIGHT, 0, &ncm->iSmCaptionHeight, dpi ) &&
1519 get_entry_dpi( &entry_SMCAPTIONLOGFONT, 0, &ncm->lfSmCaptionFont, dpi ) &&
1520 get_entry_dpi( &entry_MENUWIDTH, 0, &ncm->iMenuWidth, dpi ) &&
1521 get_entry_dpi( &entry_MENUHEIGHT, 0, &ncm->iMenuHeight, dpi ) &&
1522 get_entry_dpi( &entry_MENULOGFONT, 0, &ncm->lfMenuFont, dpi ) &&
1523 get_entry_dpi( &entry_STATUSLOGFONT, 0, &ncm->lfStatusFont, dpi ) &&
1524 get_entry_dpi( &entry_MESSAGELOGFONT, 0, &ncm->lfMessageFont, dpi );
1525 if (ret && ncm->cbSize == sizeof(NONCLIENTMETRICSW))
1526 ret = get_entry_dpi( &entry_PADDEDBORDERWIDTH, 0, &ncm->iPaddedBorderWidth, dpi );
1527 normalize_nonclientmetrics( ncm );
1528 break;
1530 case SPI_GETICONMETRICS:
1532 ICONMETRICSW *im = ptr;
1533 if (im && im->cbSize == sizeof(*im))
1534 ret = get_entry_dpi( &entry_ICONHORIZONTALSPACING, 0, &im->iHorzSpacing, dpi ) &&
1535 get_entry_dpi( &entry_ICONVERTICALSPACING, 0, &im->iVertSpacing, dpi ) &&
1536 get_entry_dpi( &entry_ICONTITLEWRAP, 0, &im->iTitleWrap, dpi ) &&
1537 get_entry_dpi( &entry_ICONTITLELOGFONT, 0, &im->lfFont, dpi );
1538 break;
1540 default:
1541 SetLastError( ERROR_INVALID_PARAMETER );
1542 break;
1544 return ret;
1548 /***********************************************************************
1549 * SystemParametersInfoW (USER32.@)
1551 * Each system parameter has flag which shows whether the parameter
1552 * is loaded or not. Parameters, stored directly in SysParametersInfo are
1553 * loaded from registry only when they are requested and the flag is
1554 * "false", after the loading the flag is set to "true". On interprocess
1555 * notification of the parameter change the corresponding parameter flag is
1556 * set to "false". The parameter value will be reloaded when it is requested
1557 * the next time.
1558 * Parameters, backed by or depend on GetSystemMetrics are processed
1559 * differently. These parameters are always loaded. They are reloaded right
1560 * away on interprocess change notification. We can't do lazy loading because
1561 * we don't want to complicate GetSystemMetrics.
1562 * Parameters, backed by X settings are read from corresponding setting.
1563 * On the parameter change request the setting is changed. Interprocess change
1564 * notifications are ignored.
1565 * When parameter value is updated the changed value is stored in permanent
1566 * registry branch if saving is requested. Otherwise it is stored
1567 * in temporary branch
1569 * Some SPI values can also be stored as Twips values in the registry,
1570 * don't forget the conversion!
1572 BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
1573 PVOID pvParam, UINT fWinIni )
1575 #define WINE_SPI_FIXME(x) \
1576 case x: \
1578 static BOOL warn = TRUE; \
1579 if (warn) \
1581 warn = FALSE; \
1582 FIXME( "Unimplemented action: %u (%s)\n", x, #x ); \
1585 SetLastError( ERROR_INVALID_SPI_VALUE ); \
1586 ret = FALSE; \
1587 break
1588 #define WINE_SPI_WARN(x) \
1589 case x: \
1590 WARN( "Ignored action: %u (%s)\n", x, #x ); \
1591 ret = TRUE; \
1592 break
1594 BOOL ret = USER_Driver->pSystemParametersInfo( uiAction, uiParam, pvParam, fWinIni );
1595 unsigned spi_idx = 0;
1597 if (!ret) switch (uiAction)
1599 case SPI_GETBEEP:
1600 ret = get_entry( &entry_BEEP, uiParam, pvParam );
1601 break;
1602 case SPI_SETBEEP:
1603 ret = set_entry( &entry_BEEP, uiParam, pvParam, fWinIni );
1604 break;
1605 case SPI_GETMOUSE:
1606 ret = get_entry( &entry_MOUSETHRESHOLD1, uiParam, (INT *)pvParam ) &&
1607 get_entry( &entry_MOUSETHRESHOLD2, uiParam, (INT *)pvParam + 1 ) &&
1608 get_entry( &entry_MOUSEACCELERATION, uiParam, (INT *)pvParam + 2 );
1609 break;
1610 case SPI_SETMOUSE:
1611 ret = set_entry( &entry_MOUSETHRESHOLD1, ((INT *)pvParam)[0], pvParam, fWinIni ) &&
1612 set_entry( &entry_MOUSETHRESHOLD2, ((INT *)pvParam)[1], pvParam, fWinIni ) &&
1613 set_entry( &entry_MOUSEACCELERATION, ((INT *)pvParam)[2], pvParam, fWinIni );
1614 break;
1615 case SPI_GETBORDER:
1616 ret = get_entry( &entry_BORDER, uiParam, pvParam );
1617 if (*(INT*)pvParam < 1) *(INT*)pvParam = 1;
1618 break;
1619 case SPI_SETBORDER:
1620 ret = set_entry( &entry_BORDER, uiParam, pvParam, fWinIni );
1621 break;
1622 case SPI_GETKEYBOARDSPEED:
1623 ret = get_entry( &entry_KEYBOARDSPEED, uiParam, pvParam );
1624 break;
1625 case SPI_SETKEYBOARDSPEED:
1626 if (uiParam > 31) uiParam = 31;
1627 ret = set_entry( &entry_KEYBOARDSPEED, uiParam, pvParam, fWinIni );
1628 break;
1630 /* not implemented in Windows */
1631 WINE_SPI_WARN(SPI_LANGDRIVER); /* 12 */
1633 case SPI_ICONHORIZONTALSPACING:
1634 if (pvParam != NULL)
1635 ret = get_entry( &entry_ICONHORIZONTALSPACING, uiParam, pvParam );
1636 else
1638 int min_val = map_to_dpi( 32, GetDpiForSystem() );
1639 ret = set_entry( &entry_ICONHORIZONTALSPACING, max( min_val, uiParam ), pvParam, fWinIni );
1641 break;
1642 case SPI_GETSCREENSAVETIMEOUT:
1643 ret = get_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam );
1644 break;
1645 case SPI_SETSCREENSAVETIMEOUT:
1646 ret = set_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam, fWinIni );
1647 break;
1648 case SPI_GETSCREENSAVEACTIVE:
1649 ret = get_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam );
1650 break;
1651 case SPI_SETSCREENSAVEACTIVE:
1652 ret = set_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam, fWinIni );
1653 break;
1654 case SPI_GETGRIDGRANULARITY:
1655 ret = get_entry( &entry_GRIDGRANULARITY, uiParam, pvParam );
1656 break;
1657 case SPI_SETGRIDGRANULARITY:
1658 ret = set_entry( &entry_GRIDGRANULARITY, uiParam, pvParam, fWinIni );
1659 break;
1660 case SPI_SETDESKWALLPAPER:
1661 if (!pvParam || set_entry( &entry_DESKWALLPAPER, uiParam, pvParam, fWinIni ))
1662 ret = update_desktop_wallpaper();
1663 break;
1664 case SPI_SETDESKPATTERN:
1665 if (!pvParam || set_entry( &entry_DESKPATTERN, uiParam, pvParam, fWinIni ))
1666 ret = update_desktop_wallpaper();
1667 break;
1668 case SPI_GETKEYBOARDDELAY:
1669 ret = get_entry( &entry_KEYBOARDDELAY, uiParam, pvParam );
1670 break;
1671 case SPI_SETKEYBOARDDELAY:
1672 ret = set_entry( &entry_KEYBOARDDELAY, uiParam, pvParam, fWinIni );
1673 break;
1674 case SPI_ICONVERTICALSPACING:
1675 if (pvParam != NULL)
1676 ret = get_entry( &entry_ICONVERTICALSPACING, uiParam, pvParam );
1677 else
1679 int min_val = map_to_dpi( 32, GetDpiForSystem() );
1680 ret = set_entry( &entry_ICONVERTICALSPACING, max( min_val, uiParam ), pvParam, fWinIni );
1682 break;
1683 case SPI_GETICONTITLEWRAP:
1684 ret = get_entry( &entry_ICONTITLEWRAP, uiParam, pvParam );
1685 break;
1686 case SPI_SETICONTITLEWRAP:
1687 ret = set_entry( &entry_ICONTITLEWRAP, uiParam, pvParam, fWinIni );
1688 break;
1689 case SPI_GETMENUDROPALIGNMENT:
1690 ret = get_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam );
1691 break;
1692 case SPI_SETMENUDROPALIGNMENT:
1693 ret = set_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam, fWinIni );
1694 break;
1695 case SPI_SETDOUBLECLKWIDTH:
1696 ret = set_entry( &entry_DOUBLECLKWIDTH, uiParam, pvParam, fWinIni );
1697 break;
1698 case SPI_SETDOUBLECLKHEIGHT:
1699 ret = set_entry( &entry_DOUBLECLKHEIGHT, uiParam, pvParam, fWinIni );
1700 break;
1701 case SPI_GETICONTITLELOGFONT:
1702 ret = get_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam );
1703 break;
1704 case SPI_SETDOUBLECLICKTIME:
1705 ret = set_entry( &entry_DOUBLECLICKTIME, uiParam, pvParam, fWinIni );
1706 break;
1707 case SPI_SETMOUSEBUTTONSWAP:
1708 ret = set_entry( &entry_MOUSEBUTTONSWAP, uiParam, pvParam, fWinIni );
1709 break;
1710 case SPI_SETICONTITLELOGFONT:
1711 ret = set_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam, fWinIni );
1712 break;
1714 case SPI_GETFASTTASKSWITCH: /* 35 */
1715 if (!pvParam) return FALSE;
1716 *(BOOL *)pvParam = TRUE;
1717 ret = TRUE;
1718 break;
1720 case SPI_SETFASTTASKSWITCH: /* 36 */
1721 /* the action is disabled */
1722 ret = FALSE;
1723 break;
1725 case SPI_SETDRAGFULLWINDOWS:
1726 ret = set_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam, fWinIni );
1727 break;
1728 case SPI_GETDRAGFULLWINDOWS:
1729 ret = get_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam );
1730 break;
1731 case SPI_GETNONCLIENTMETRICS:
1733 LPNONCLIENTMETRICSW lpnm = pvParam;
1734 int padded_border;
1736 if (!pvParam) return FALSE;
1738 ret = get_entry( &entry_BORDER, 0, &lpnm->iBorderWidth ) &&
1739 get_entry( &entry_PADDEDBORDERWIDTH, 0, &padded_border ) &&
1740 get_entry( &entry_SCROLLWIDTH, 0, &lpnm->iScrollWidth ) &&
1741 get_entry( &entry_SCROLLHEIGHT, 0, &lpnm->iScrollHeight ) &&
1742 get_entry( &entry_CAPTIONWIDTH, 0, &lpnm->iCaptionWidth ) &&
1743 get_entry( &entry_CAPTIONHEIGHT, 0, &lpnm->iCaptionHeight ) &&
1744 get_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont ) &&
1745 get_entry( &entry_SMCAPTIONWIDTH, 0, &lpnm->iSmCaptionWidth ) &&
1746 get_entry( &entry_SMCAPTIONHEIGHT, 0, &lpnm->iSmCaptionHeight ) &&
1747 get_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont ) &&
1748 get_entry( &entry_MENUWIDTH, 0, &lpnm->iMenuWidth ) &&
1749 get_entry( &entry_MENUHEIGHT, 0, &lpnm->iMenuHeight ) &&
1750 get_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont ) &&
1751 get_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont ) &&
1752 get_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont );
1753 lpnm->iBorderWidth += padded_border;
1754 if (ret && lpnm->cbSize == sizeof(NONCLIENTMETRICSW)) lpnm->iPaddedBorderWidth = 0;
1755 normalize_nonclientmetrics( lpnm );
1756 break;
1758 case SPI_SETNONCLIENTMETRICS:
1760 LPNONCLIENTMETRICSW lpnm = pvParam;
1761 int padded_border;
1763 if (lpnm && (lpnm->cbSize == sizeof(NONCLIENTMETRICSW) ||
1764 lpnm->cbSize == FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth)))
1766 get_entry( &entry_PADDEDBORDERWIDTH, 0, &padded_border );
1768 ret = set_entry( &entry_BORDER, lpnm->iBorderWidth - padded_border, NULL, fWinIni ) &&
1769 set_entry( &entry_SCROLLWIDTH, lpnm->iScrollWidth, NULL, fWinIni ) &&
1770 set_entry( &entry_SCROLLHEIGHT, lpnm->iScrollHeight, NULL, fWinIni ) &&
1771 set_entry( &entry_CAPTIONWIDTH, lpnm->iCaptionWidth, NULL, fWinIni ) &&
1772 set_entry( &entry_CAPTIONHEIGHT, lpnm->iCaptionHeight, NULL, fWinIni ) &&
1773 set_entry( &entry_SMCAPTIONWIDTH, lpnm->iSmCaptionWidth, NULL, fWinIni ) &&
1774 set_entry( &entry_SMCAPTIONHEIGHT, lpnm->iSmCaptionHeight, NULL, fWinIni ) &&
1775 set_entry( &entry_MENUWIDTH, lpnm->iMenuWidth, NULL, fWinIni ) &&
1776 set_entry( &entry_MENUHEIGHT, lpnm->iMenuHeight, NULL, fWinIni ) &&
1777 set_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont, fWinIni ) &&
1778 set_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont, fWinIni ) &&
1779 set_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont, fWinIni ) &&
1780 set_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont, fWinIni ) &&
1781 set_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont, fWinIni );
1783 break;
1785 case SPI_GETMINIMIZEDMETRICS:
1787 MINIMIZEDMETRICS * lpMm = pvParam;
1788 if (lpMm && lpMm->cbSize == sizeof(*lpMm)) {
1789 ret = get_entry( &entry_MINWIDTH, 0, &lpMm->iWidth ) &&
1790 get_entry( &entry_MINHORZGAP, 0, &lpMm->iHorzGap ) &&
1791 get_entry( &entry_MINVERTGAP, 0, &lpMm->iVertGap ) &&
1792 get_entry( &entry_MINARRANGE, 0, &lpMm->iArrange );
1793 lpMm->iWidth = max( 0, lpMm->iWidth );
1794 lpMm->iHorzGap = max( 0, lpMm->iHorzGap );
1795 lpMm->iVertGap = max( 0, lpMm->iVertGap );
1796 lpMm->iArrange &= 0x0f;
1798 break;
1800 case SPI_SETMINIMIZEDMETRICS:
1802 MINIMIZEDMETRICS * lpMm = pvParam;
1803 if (lpMm && lpMm->cbSize == sizeof(*lpMm))
1804 ret = set_entry( &entry_MINWIDTH, max( 0, lpMm->iWidth ), NULL, fWinIni ) &&
1805 set_entry( &entry_MINHORZGAP, max( 0, lpMm->iHorzGap ), NULL, fWinIni ) &&
1806 set_entry( &entry_MINVERTGAP, max( 0, lpMm->iVertGap ), NULL, fWinIni ) &&
1807 set_entry( &entry_MINARRANGE, lpMm->iArrange & 0x0f, NULL, fWinIni );
1808 break;
1810 case SPI_GETICONMETRICS:
1812 LPICONMETRICSW lpIcon = pvParam;
1813 if(lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1815 ret = get_entry( &entry_ICONHORIZONTALSPACING, 0, &lpIcon->iHorzSpacing ) &&
1816 get_entry( &entry_ICONVERTICALSPACING, 0, &lpIcon->iVertSpacing ) &&
1817 get_entry( &entry_ICONTITLEWRAP, 0, &lpIcon->iTitleWrap ) &&
1818 get_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont );
1820 break;
1822 case SPI_SETICONMETRICS:
1824 LPICONMETRICSW lpIcon = pvParam;
1825 if (lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1826 ret = set_entry( &entry_ICONVERTICALSPACING, max(32,lpIcon->iVertSpacing), NULL, fWinIni ) &&
1827 set_entry( &entry_ICONHORIZONTALSPACING, max(32,lpIcon->iHorzSpacing), NULL, fWinIni ) &&
1828 set_entry( &entry_ICONTITLEWRAP, lpIcon->iTitleWrap, NULL, fWinIni ) &&
1829 set_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont, fWinIni );
1830 break;
1833 case SPI_SETWORKAREA: /* 47 WINVER >= 0x400 */
1835 if (!pvParam) return FALSE;
1837 spi_idx = SPI_SETWORKAREA_IDX;
1838 work_area = *(RECT*)pvParam;
1839 spi_loaded[spi_idx] = TRUE;
1840 ret = TRUE;
1841 break;
1844 case SPI_GETWORKAREA: /* 48 WINVER >= 0x400 */
1846 if (!pvParam) return FALSE;
1848 spi_idx = SPI_SETWORKAREA_IDX;
1849 if (!spi_loaded[spi_idx])
1851 SetRect( &work_area, 0, 0,
1852 GetSystemMetrics( SM_CXSCREEN ),
1853 GetSystemMetrics( SM_CYSCREEN ) );
1854 EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area );
1855 spi_loaded[spi_idx] = TRUE;
1857 *(RECT*)pvParam = work_area;
1858 ret = TRUE;
1859 TRACE("work area %s\n", wine_dbgstr_rect( &work_area ));
1860 break;
1863 WINE_SPI_FIXME(SPI_SETPENWINDOWS); /* 49 WINVER >= 0x400 */
1865 case SPI_GETFILTERKEYS: /* 50 */
1867 LPFILTERKEYS lpFilterKeys = pvParam;
1868 WARN("SPI_GETFILTERKEYS not fully implemented\n");
1869 if (lpFilterKeys && lpFilterKeys->cbSize == sizeof(FILTERKEYS))
1871 /* Indicate that no FilterKeys feature available */
1872 lpFilterKeys->dwFlags = 0;
1873 lpFilterKeys->iWaitMSec = 0;
1874 lpFilterKeys->iDelayMSec = 0;
1875 lpFilterKeys->iRepeatMSec = 0;
1876 lpFilterKeys->iBounceMSec = 0;
1877 ret = TRUE;
1879 break;
1881 WINE_SPI_FIXME(SPI_SETFILTERKEYS); /* 51 */
1883 case SPI_GETTOGGLEKEYS: /* 52 */
1885 LPTOGGLEKEYS lpToggleKeys = pvParam;
1886 WARN("SPI_GETTOGGLEKEYS not fully implemented\n");
1887 if (lpToggleKeys && lpToggleKeys->cbSize == sizeof(TOGGLEKEYS))
1889 /* Indicate that no ToggleKeys feature available */
1890 lpToggleKeys->dwFlags = 0;
1891 ret = TRUE;
1893 break;
1895 WINE_SPI_FIXME(SPI_SETTOGGLEKEYS); /* 53 */
1897 case SPI_GETMOUSEKEYS: /* 54 */
1899 LPMOUSEKEYS lpMouseKeys = pvParam;
1900 WARN("SPI_GETMOUSEKEYS not fully implemented\n");
1901 if (lpMouseKeys && lpMouseKeys->cbSize == sizeof(MOUSEKEYS))
1903 /* Indicate that no MouseKeys feature available */
1904 lpMouseKeys->dwFlags = 0;
1905 lpMouseKeys->iMaxSpeed = 360;
1906 lpMouseKeys->iTimeToMaxSpeed = 1000;
1907 lpMouseKeys->iCtrlSpeed = 0;
1908 lpMouseKeys->dwReserved1 = 0;
1909 lpMouseKeys->dwReserved2 = 0;
1910 ret = TRUE;
1912 break;
1914 WINE_SPI_FIXME(SPI_SETMOUSEKEYS); /* 55 */
1916 case SPI_GETSHOWSOUNDS:
1917 ret = get_entry( &entry_SHOWSOUNDS, uiParam, pvParam );
1918 break;
1919 case SPI_SETSHOWSOUNDS:
1920 ret = set_entry( &entry_SHOWSOUNDS, uiParam, pvParam, fWinIni );
1921 break;
1923 case SPI_GETSTICKYKEYS: /* 58 */
1925 LPSTICKYKEYS lpStickyKeys = pvParam;
1926 WARN("SPI_GETSTICKYKEYS not fully implemented\n");
1927 if (lpStickyKeys && lpStickyKeys->cbSize == sizeof(STICKYKEYS))
1929 /* Indicate that no StickyKeys feature available */
1930 lpStickyKeys->dwFlags = 0;
1931 ret = TRUE;
1933 break;
1935 WINE_SPI_FIXME(SPI_SETSTICKYKEYS); /* 59 */
1937 case SPI_GETACCESSTIMEOUT: /* 60 */
1939 LPACCESSTIMEOUT lpAccessTimeout = pvParam;
1940 WARN("SPI_GETACCESSTIMEOUT not fully implemented\n");
1941 if (lpAccessTimeout && lpAccessTimeout->cbSize == sizeof(ACCESSTIMEOUT))
1943 /* Indicate that no accessibility features timeout is available */
1944 lpAccessTimeout->dwFlags = 0;
1945 lpAccessTimeout->iTimeOutMSec = 0;
1946 ret = TRUE;
1948 break;
1950 WINE_SPI_FIXME(SPI_SETACCESSTIMEOUT); /* 61 */
1952 case SPI_GETSERIALKEYS: /* 62 WINVER >= 0x400 */
1954 LPSERIALKEYSW lpSerialKeysW = pvParam;
1955 WARN("SPI_GETSERIALKEYS not fully implemented\n");
1956 if (lpSerialKeysW && lpSerialKeysW->cbSize == sizeof(SERIALKEYSW))
1958 /* Indicate that no SerialKeys feature available */
1959 lpSerialKeysW->dwFlags = 0;
1960 lpSerialKeysW->lpszActivePort = NULL;
1961 lpSerialKeysW->lpszPort = NULL;
1962 lpSerialKeysW->iBaudRate = 0;
1963 lpSerialKeysW->iPortState = 0;
1964 ret = TRUE;
1966 break;
1968 WINE_SPI_FIXME(SPI_SETSERIALKEYS); /* 63 WINVER >= 0x400 */
1970 case SPI_GETSOUNDSENTRY: /* 64 */
1972 LPSOUNDSENTRYW lpSoundSentryW = pvParam;
1973 WARN("SPI_GETSOUNDSENTRY not fully implemented\n");
1974 if (lpSoundSentryW && lpSoundSentryW->cbSize == sizeof(SOUNDSENTRYW))
1976 /* Indicate that no SoundSentry feature available */
1977 lpSoundSentryW->dwFlags = 0;
1978 lpSoundSentryW->iFSTextEffect = 0;
1979 lpSoundSentryW->iFSTextEffectMSec = 0;
1980 lpSoundSentryW->iFSTextEffectColorBits = 0;
1981 lpSoundSentryW->iFSGrafEffect = 0;
1982 lpSoundSentryW->iFSGrafEffectMSec = 0;
1983 lpSoundSentryW->iFSGrafEffectColor = 0;
1984 lpSoundSentryW->iWindowsEffect = 0;
1985 lpSoundSentryW->iWindowsEffectMSec = 0;
1986 lpSoundSentryW->lpszWindowsEffectDLL = 0;
1987 lpSoundSentryW->iWindowsEffectOrdinal = 0;
1988 ret = TRUE;
1990 break;
1992 WINE_SPI_FIXME(SPI_SETSOUNDSENTRY); /* 65 */
1994 case SPI_GETHIGHCONTRAST: /* 66 WINVER >= 0x400 */
1996 LPHIGHCONTRASTW lpHighContrastW = pvParam;
1997 WARN("SPI_GETHIGHCONTRAST not fully implemented\n");
1998 if (lpHighContrastW && lpHighContrastW->cbSize == sizeof(HIGHCONTRASTW))
2000 /* Indicate that no high contrast feature available */
2001 lpHighContrastW->dwFlags = 0;
2002 lpHighContrastW->lpszDefaultScheme = NULL;
2003 ret = TRUE;
2005 break;
2007 WINE_SPI_FIXME(SPI_SETHIGHCONTRAST); /* 67 WINVER >= 0x400 */
2009 case SPI_GETKEYBOARDPREF:
2010 ret = get_entry( &entry_KEYBOARDPREF, uiParam, pvParam );
2011 break;
2012 case SPI_SETKEYBOARDPREF:
2013 ret = set_entry( &entry_KEYBOARDPREF, uiParam, pvParam, fWinIni );
2014 break;
2015 case SPI_GETSCREENREADER:
2016 ret = get_entry( &entry_SCREENREADER, uiParam, pvParam );
2017 break;
2018 case SPI_SETSCREENREADER:
2019 ret = set_entry( &entry_SCREENREADER, uiParam, pvParam, fWinIni );
2020 break;
2022 case SPI_GETANIMATION: /* 72 WINVER >= 0x400 */
2024 LPANIMATIONINFO lpAnimInfo = pvParam;
2026 /* Tell it "disabled" */
2027 if (lpAnimInfo && lpAnimInfo->cbSize == sizeof(ANIMATIONINFO))
2029 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
2030 ret = TRUE;
2032 break;
2034 WINE_SPI_WARN(SPI_SETANIMATION); /* 73 WINVER >= 0x400 */
2036 case SPI_GETFONTSMOOTHING:
2037 ret = get_entry( &entry_FONTSMOOTHING, uiParam, pvParam );
2038 if (ret) *(UINT *)pvParam = (*(UINT *)pvParam != 0);
2039 break;
2040 case SPI_SETFONTSMOOTHING:
2041 uiParam = uiParam ? 2 : 0; /* Win NT4/2k/XP behavior */
2042 ret = set_entry( &entry_FONTSMOOTHING, uiParam, pvParam, fWinIni );
2043 break;
2044 case SPI_SETDRAGWIDTH:
2045 ret = set_entry( &entry_DRAGWIDTH, uiParam, pvParam, fWinIni );
2046 break;
2047 case SPI_SETDRAGHEIGHT:
2048 ret = set_entry( &entry_DRAGHEIGHT, uiParam, pvParam, fWinIni );
2049 break;
2051 WINE_SPI_FIXME(SPI_SETHANDHELD); /* 78 WINVER >= 0x400 */
2053 WINE_SPI_FIXME(SPI_GETLOWPOWERTIMEOUT); /* 79 WINVER >= 0x400 */
2054 WINE_SPI_FIXME(SPI_GETPOWEROFFTIMEOUT); /* 80 WINVER >= 0x400 */
2055 WINE_SPI_FIXME(SPI_SETLOWPOWERTIMEOUT); /* 81 WINVER >= 0x400 */
2056 WINE_SPI_FIXME(SPI_SETPOWEROFFTIMEOUT); /* 82 WINVER >= 0x400 */
2058 case SPI_GETLOWPOWERACTIVE:
2059 ret = get_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam );
2060 break;
2061 case SPI_SETLOWPOWERACTIVE:
2062 ret = set_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam, fWinIni );
2063 break;
2064 case SPI_GETPOWEROFFACTIVE:
2065 ret = get_entry( &entry_POWEROFFACTIVE, uiParam, pvParam );
2066 break;
2067 case SPI_SETPOWEROFFACTIVE:
2068 ret = set_entry( &entry_POWEROFFACTIVE, uiParam, pvParam, fWinIni );
2069 break;
2071 WINE_SPI_FIXME(SPI_SETCURSORS); /* 87 WINVER >= 0x400 */
2072 WINE_SPI_FIXME(SPI_SETICONS); /* 88 WINVER >= 0x400 */
2074 case SPI_GETDEFAULTINPUTLANG: /* 89 WINVER >= 0x400 */
2075 ret = GetKeyboardLayout(0) != 0;
2076 break;
2078 WINE_SPI_FIXME(SPI_SETDEFAULTINPUTLANG); /* 90 WINVER >= 0x400 */
2080 WINE_SPI_FIXME(SPI_SETLANGTOGGLE); /* 91 WINVER >= 0x400 */
2082 case SPI_GETWINDOWSEXTENSION: /* 92 WINVER >= 0x400 */
2083 WARN("pretend no support for Win9x Plus! for now.\n");
2084 ret = FALSE; /* yes, this is the result value */
2085 break;
2086 case SPI_SETMOUSETRAILS:
2087 ret = set_entry( &entry_MOUSETRAILS, uiParam, pvParam, fWinIni );
2088 break;
2089 case SPI_GETMOUSETRAILS:
2090 ret = get_entry( &entry_MOUSETRAILS, uiParam, pvParam );
2091 break;
2092 case SPI_GETSNAPTODEFBUTTON:
2093 ret = get_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam );
2094 break;
2095 case SPI_SETSNAPTODEFBUTTON:
2096 ret = set_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam, fWinIni );
2097 break;
2098 case SPI_SETSCREENSAVERRUNNING:
2099 ret = set_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam, fWinIni );
2100 break;
2101 case SPI_GETMOUSEHOVERWIDTH:
2102 ret = get_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam );
2103 break;
2104 case SPI_SETMOUSEHOVERWIDTH:
2105 ret = set_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam, fWinIni );
2106 break;
2107 case SPI_GETMOUSEHOVERHEIGHT:
2108 ret = get_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam );
2109 break;
2110 case SPI_SETMOUSEHOVERHEIGHT:
2111 ret = set_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam, fWinIni );
2112 break;
2113 case SPI_GETMOUSEHOVERTIME:
2114 ret = get_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam );
2115 break;
2116 case SPI_SETMOUSEHOVERTIME:
2117 ret = set_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam, fWinIni );
2118 break;
2119 case SPI_GETWHEELSCROLLLINES:
2120 ret = get_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam );
2121 break;
2122 case SPI_SETWHEELSCROLLLINES:
2123 ret = set_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam, fWinIni );
2124 break;
2125 case SPI_GETMENUSHOWDELAY:
2126 ret = get_entry( &entry_MENUSHOWDELAY, uiParam, pvParam );
2127 break;
2128 case SPI_SETMENUSHOWDELAY:
2129 ret = set_entry( &entry_MENUSHOWDELAY, uiParam, pvParam, fWinIni );
2130 break;
2131 case SPI_GETWHEELSCROLLCHARS:
2132 ret = get_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam );
2133 break;
2134 case SPI_SETWHEELSCROLLCHARS:
2135 ret = set_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam, fWinIni );
2136 break;
2138 WINE_SPI_FIXME(SPI_GETSHOWIMEUI); /* 110 _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2139 WINE_SPI_FIXME(SPI_SETSHOWIMEUI); /* 111 _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
2141 case SPI_GETMOUSESPEED:
2142 ret = get_entry( &entry_MOUSESPEED, uiParam, pvParam );
2143 break;
2144 case SPI_SETMOUSESPEED:
2145 ret = set_entry( &entry_MOUSESPEED, uiParam, pvParam, fWinIni );
2146 break;
2147 case SPI_GETSCREENSAVERRUNNING:
2148 ret = get_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam );
2149 break;
2150 case SPI_GETDESKWALLPAPER:
2151 ret = get_entry( &entry_DESKWALLPAPER, uiParam, pvParam );
2152 break;
2153 case SPI_GETACTIVEWINDOWTRACKING:
2154 ret = get_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam );
2155 break;
2156 case SPI_SETACTIVEWINDOWTRACKING:
2157 ret = set_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam, fWinIni );
2158 break;
2159 case SPI_GETMENUANIMATION:
2160 ret = get_entry( &entry_MENUANIMATION, uiParam, pvParam );
2161 break;
2162 case SPI_SETMENUANIMATION:
2163 ret = set_entry( &entry_MENUANIMATION, uiParam, pvParam, fWinIni );
2164 break;
2165 case SPI_GETCOMBOBOXANIMATION:
2166 ret = get_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam );
2167 break;
2168 case SPI_SETCOMBOBOXANIMATION:
2169 ret = set_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam, fWinIni );
2170 break;
2171 case SPI_GETLISTBOXSMOOTHSCROLLING:
2172 ret = get_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam );
2173 break;
2174 case SPI_SETLISTBOXSMOOTHSCROLLING:
2175 ret = set_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam, fWinIni );
2176 break;
2177 case SPI_GETGRADIENTCAPTIONS:
2178 ret = get_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam );
2179 break;
2180 case SPI_SETGRADIENTCAPTIONS:
2181 ret = set_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam, fWinIni );
2182 break;
2183 case SPI_GETKEYBOARDCUES:
2184 ret = get_entry( &entry_KEYBOARDCUES, uiParam, pvParam );
2185 break;
2186 case SPI_SETKEYBOARDCUES:
2187 ret = set_entry( &entry_KEYBOARDCUES, uiParam, pvParam, fWinIni );
2188 break;
2189 case SPI_GETACTIVEWNDTRKZORDER:
2190 ret = get_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam );
2191 break;
2192 case SPI_SETACTIVEWNDTRKZORDER:
2193 ret = set_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam, fWinIni );
2194 break;
2195 case SPI_GETHOTTRACKING:
2196 ret = get_entry( &entry_HOTTRACKING, uiParam, pvParam );
2197 break;
2198 case SPI_SETHOTTRACKING:
2199 ret = set_entry( &entry_HOTTRACKING, uiParam, pvParam, fWinIni );
2200 break;
2201 case SPI_GETMENUFADE:
2202 ret = get_entry( &entry_MENUFADE, uiParam, pvParam );
2203 break;
2204 case SPI_SETMENUFADE:
2205 ret = set_entry( &entry_MENUFADE, uiParam, pvParam, fWinIni );
2206 break;
2207 case SPI_GETSELECTIONFADE:
2208 ret = get_entry( &entry_SELECTIONFADE, uiParam, pvParam );
2209 break;
2210 case SPI_SETSELECTIONFADE:
2211 ret = set_entry( &entry_SELECTIONFADE, uiParam, pvParam, fWinIni );
2212 break;
2213 case SPI_GETTOOLTIPANIMATION:
2214 ret = get_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam );
2215 break;
2216 case SPI_SETTOOLTIPANIMATION:
2217 ret = set_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam, fWinIni );
2218 break;
2219 case SPI_GETTOOLTIPFADE:
2220 ret = get_entry( &entry_TOOLTIPFADE, uiParam, pvParam );
2221 break;
2222 case SPI_SETTOOLTIPFADE:
2223 ret = set_entry( &entry_TOOLTIPFADE, uiParam, pvParam, fWinIni );
2224 break;
2225 case SPI_GETCURSORSHADOW:
2226 ret = get_entry( &entry_CURSORSHADOW, uiParam, pvParam );
2227 break;
2228 case SPI_SETCURSORSHADOW:
2229 ret = set_entry( &entry_CURSORSHADOW, uiParam, pvParam, fWinIni );
2230 break;
2231 case SPI_GETMOUSESONAR:
2232 ret = get_entry( &entry_MOUSESONAR, uiParam, pvParam );
2233 break;
2234 case SPI_SETMOUSESONAR:
2235 ret = set_entry( &entry_MOUSESONAR, uiParam, pvParam, fWinIni );
2236 break;
2237 case SPI_GETMOUSECLICKLOCK:
2238 ret = get_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam );
2239 break;
2240 case SPI_SETMOUSECLICKLOCK:
2241 ret = set_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam, fWinIni );
2242 break;
2243 case SPI_GETMOUSEVANISH:
2244 ret = get_entry( &entry_MOUSEVANISH, uiParam, pvParam );
2245 break;
2246 case SPI_SETMOUSEVANISH:
2247 ret = set_entry( &entry_MOUSEVANISH, uiParam, pvParam, fWinIni );
2248 break;
2249 case SPI_GETFLATMENU:
2250 ret = get_entry( &entry_FLATMENU, uiParam, pvParam );
2251 break;
2252 case SPI_SETFLATMENU:
2253 ret = set_entry( &entry_FLATMENU, uiParam, pvParam, fWinIni );
2254 break;
2255 case SPI_GETDROPSHADOW:
2256 ret = get_entry( &entry_DROPSHADOW, uiParam, pvParam );
2257 break;
2258 case SPI_SETDROPSHADOW:
2259 ret = set_entry( &entry_DROPSHADOW, uiParam, pvParam, fWinIni );
2260 break;
2261 case SPI_GETBLOCKSENDINPUTRESETS:
2262 ret = get_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam );
2263 break;
2264 case SPI_SETBLOCKSENDINPUTRESETS:
2265 ret = set_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam, fWinIni );
2266 break;
2267 case SPI_GETUIEFFECTS:
2268 ret = get_entry( &entry_UIEFFECTS, uiParam, pvParam );
2269 break;
2270 case SPI_SETUIEFFECTS:
2271 /* FIXME: this probably should mask other UI effect values when unset */
2272 ret = set_entry( &entry_UIEFFECTS, uiParam, pvParam, fWinIni );
2273 break;
2274 case SPI_GETDISABLEOVERLAPPEDCONTENT:
2275 ret = get_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam );
2276 break;
2277 case SPI_SETDISABLEOVERLAPPEDCONTENT:
2278 ret = set_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam, fWinIni );
2279 break;
2280 case SPI_GETCLIENTAREAANIMATION:
2281 ret = get_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam );
2282 break;
2283 case SPI_SETCLIENTAREAANIMATION:
2284 ret = set_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam, fWinIni );
2285 break;
2286 case SPI_GETCLEARTYPE:
2287 ret = get_entry( &entry_CLEARTYPE, uiParam, pvParam );
2288 break;
2289 case SPI_SETCLEARTYPE:
2290 ret = set_entry( &entry_CLEARTYPE, uiParam, pvParam, fWinIni );
2291 break;
2292 case SPI_GETSPEECHRECOGNITION:
2293 ret = get_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam );
2294 break;
2295 case SPI_SETSPEECHRECOGNITION:
2296 ret = set_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam, fWinIni );
2297 break;
2298 case SPI_GETFOREGROUNDLOCKTIMEOUT:
2299 ret = get_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam );
2300 break;
2301 case SPI_SETFOREGROUNDLOCKTIMEOUT:
2302 /* FIXME: this should check that the calling thread
2303 * is able to change the foreground window */
2304 ret = set_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam, fWinIni );
2305 break;
2306 case SPI_GETACTIVEWNDTRKTIMEOUT:
2307 ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2308 break;
2309 case SPI_SETACTIVEWNDTRKTIMEOUT:
2310 ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2311 break;
2312 case SPI_GETFOREGROUNDFLASHCOUNT:
2313 ret = get_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam );
2314 break;
2315 case SPI_SETFOREGROUNDFLASHCOUNT:
2316 ret = set_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam, fWinIni );
2317 break;
2318 case SPI_GETCARETWIDTH:
2319 ret = get_entry( &entry_CARETWIDTH, uiParam, pvParam );
2320 break;
2321 case SPI_SETCARETWIDTH:
2322 ret = set_entry( &entry_CARETWIDTH, uiParam, pvParam, fWinIni );
2323 break;
2324 case SPI_GETMOUSECLICKLOCKTIME:
2325 ret = get_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam );
2326 break;
2327 case SPI_SETMOUSECLICKLOCKTIME:
2328 ret = set_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam, fWinIni );
2329 break;
2330 case SPI_GETFONTSMOOTHINGTYPE:
2331 ret = get_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam );
2332 break;
2333 case SPI_SETFONTSMOOTHINGTYPE:
2334 ret = set_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam, fWinIni );
2335 break;
2336 case SPI_GETFONTSMOOTHINGCONTRAST:
2337 ret = get_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam );
2338 break;
2339 case SPI_SETFONTSMOOTHINGCONTRAST:
2340 ret = set_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam, fWinIni );
2341 break;
2342 case SPI_GETFOCUSBORDERWIDTH:
2343 ret = get_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam );
2344 break;
2345 case SPI_GETFOCUSBORDERHEIGHT:
2346 ret = get_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam );
2347 break;
2348 case SPI_SETFOCUSBORDERWIDTH:
2349 ret = set_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam, fWinIni );
2350 break;
2351 case SPI_SETFOCUSBORDERHEIGHT:
2352 ret = set_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam, fWinIni );
2353 break;
2354 case SPI_GETFONTSMOOTHINGORIENTATION:
2355 ret = get_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam );
2356 break;
2357 case SPI_SETFONTSMOOTHINGORIENTATION:
2358 ret = set_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam, fWinIni );
2359 break;
2360 case SPI_GETAUDIODESCRIPTION:
2362 AUDIODESCRIPTION *audio = pvParam;
2363 if (audio && audio->cbSize == sizeof(AUDIODESCRIPTION) && uiParam == sizeof(AUDIODESCRIPTION) )
2365 ret = get_entry( &entry_AUDIODESC_ON, 0, &audio->Enabled ) &&
2366 get_entry( &entry_AUDIODESC_LOCALE, 0, &audio->Locale );
2368 break;
2370 case SPI_SETAUDIODESCRIPTION:
2372 AUDIODESCRIPTION *audio = pvParam;
2373 if (audio && audio->cbSize == sizeof(AUDIODESCRIPTION) && uiParam == sizeof(AUDIODESCRIPTION) )
2375 ret = set_entry( &entry_AUDIODESC_ON, 0, &audio->Enabled, fWinIni) &&
2376 set_entry( &entry_AUDIODESC_LOCALE, 0, &audio->Locale, fWinIni );
2378 break;
2380 default:
2381 FIXME( "Unknown action: %u\n", uiAction );
2382 SetLastError( ERROR_INVALID_SPI_VALUE );
2383 ret = FALSE;
2384 break;
2387 if (ret)
2388 SYSPARAMS_NotifyChange( uiAction, fWinIni );
2389 TRACE("(%u, %u, %p, %u) ret %d\n",
2390 uiAction, uiParam, pvParam, fWinIni, ret);
2391 return ret;
2393 #undef WINE_SPI_FIXME
2394 #undef WINE_SPI_WARN
2398 /***********************************************************************
2399 * SystemParametersInfoA (USER32.@)
2401 BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
2402 PVOID pvParam, UINT fuWinIni )
2404 BOOL ret;
2406 TRACE("(%u, %u, %p, %u)\n", uiAction, uiParam, pvParam, fuWinIni);
2408 switch (uiAction)
2410 case SPI_SETDESKWALLPAPER: /* 20 */
2411 case SPI_SETDESKPATTERN: /* 21 */
2413 WCHAR buffer[256];
2414 if (pvParam)
2415 if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer, ARRAY_SIZE( buffer )))
2416 buffer[ARRAY_SIZE(buffer)-1] = 0;
2417 ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni );
2418 break;
2421 case SPI_GETICONTITLELOGFONT: /* 31 */
2423 LOGFONTW tmp;
2424 ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? &tmp : NULL, fuWinIni );
2425 if (ret && pvParam)
2426 SYSPARAMS_LogFont32WTo32A( &tmp, pvParam );
2427 break;
2430 case SPI_GETNONCLIENTMETRICS: /* 41 WINVER >= 0x400 */
2432 NONCLIENTMETRICSW tmp;
2433 LPNONCLIENTMETRICSA lpnmA = pvParam;
2434 if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2435 lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2437 tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2438 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2439 if (ret)
2440 SYSPARAMS_NonClientMetrics32WTo32A( &tmp, lpnmA );
2442 else
2443 ret = FALSE;
2444 break;
2447 case SPI_SETNONCLIENTMETRICS: /* 42 WINVER >= 0x400 */
2449 NONCLIENTMETRICSW tmp;
2450 LPNONCLIENTMETRICSA lpnmA = pvParam;
2451 if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2452 lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2454 tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2455 SYSPARAMS_NonClientMetrics32ATo32W( lpnmA, &tmp );
2456 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2458 else
2459 ret = FALSE;
2460 break;
2463 case SPI_GETICONMETRICS: /* 45 WINVER >= 0x400 */
2465 ICONMETRICSW tmp;
2466 LPICONMETRICSA lpimA = pvParam;
2467 if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2469 tmp.cbSize = sizeof(ICONMETRICSW);
2470 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2471 if (ret)
2473 lpimA->iHorzSpacing = tmp.iHorzSpacing;
2474 lpimA->iVertSpacing = tmp.iVertSpacing;
2475 lpimA->iTitleWrap = tmp.iTitleWrap;
2476 SYSPARAMS_LogFont32WTo32A( &tmp.lfFont, &lpimA->lfFont );
2479 else
2480 ret = FALSE;
2481 break;
2484 case SPI_SETICONMETRICS: /* 46 WINVER >= 0x400 */
2486 ICONMETRICSW tmp;
2487 LPICONMETRICSA lpimA = pvParam;
2488 if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2490 tmp.cbSize = sizeof(ICONMETRICSW);
2491 tmp.iHorzSpacing = lpimA->iHorzSpacing;
2492 tmp.iVertSpacing = lpimA->iVertSpacing;
2493 tmp.iTitleWrap = lpimA->iTitleWrap;
2494 SYSPARAMS_LogFont32ATo32W( &lpimA->lfFont, &tmp.lfFont);
2495 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2497 else
2498 ret = FALSE;
2499 break;
2502 case SPI_GETHIGHCONTRAST: /* 66 WINVER >= 0x400 */
2504 HIGHCONTRASTW tmp;
2505 LPHIGHCONTRASTA lphcA = pvParam;
2506 if (lphcA && lphcA->cbSize == sizeof(HIGHCONTRASTA))
2508 tmp.cbSize = sizeof(HIGHCONTRASTW);
2509 ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2510 if (ret)
2512 lphcA->dwFlags = tmp.dwFlags;
2513 lphcA->lpszDefaultScheme = NULL; /* FIXME? */
2516 else
2517 ret = FALSE;
2518 break;
2521 case SPI_GETDESKWALLPAPER: /* 115 */
2523 WCHAR buffer[MAX_PATH];
2524 ret = (SystemParametersInfoW( SPI_GETDESKWALLPAPER, uiParam, buffer, fuWinIni ) &&
2525 WideCharToMultiByte(CP_ACP, 0, buffer, -1, pvParam, uiParam, NULL, NULL));
2526 break;
2529 default:
2530 ret = SystemParametersInfoW( uiAction, uiParam, pvParam, fuWinIni );
2531 break;
2533 return ret;
2537 /***********************************************************************
2538 * GetSystemMetrics (USER32.@)
2540 INT WINAPI GetSystemMetrics( INT index )
2542 struct monitor_info info;
2543 NONCLIENTMETRICSW ncm;
2544 MINIMIZEDMETRICS mm;
2545 ICONMETRICSW im;
2546 UINT ret;
2547 HDC hdc;
2549 /* some metrics are dynamic */
2550 switch (index)
2552 case SM_CXVSCROLL:
2553 case SM_CYHSCROLL:
2554 ncm.cbSize = sizeof(ncm);
2555 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2556 return ncm.iScrollWidth;
2557 case SM_CYCAPTION:
2558 ncm.cbSize = sizeof(ncm);
2559 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2560 return ncm.iCaptionHeight + 1;
2561 case SM_CXBORDER:
2562 case SM_CYBORDER:
2563 /* SM_C{X,Y}BORDER always returns 1 regardless of 'BorderWidth' value in registry */
2564 return 1;
2565 case SM_CXDLGFRAME:
2566 case SM_CYDLGFRAME:
2567 return 3;
2568 case SM_CYVTHUMB:
2569 case SM_CXHTHUMB:
2570 case SM_CYVSCROLL:
2571 case SM_CXHSCROLL:
2572 ncm.cbSize = sizeof(ncm);
2573 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2574 return ncm.iScrollHeight;
2575 case SM_CXICON:
2576 case SM_CYICON:
2577 return map_to_dpi( 32, GetDpiForSystem() );
2578 case SM_CXCURSOR:
2579 case SM_CYCURSOR:
2580 ret = map_to_dpi( 32, GetDpiForSystem() );
2581 if (ret >= 64) return 64;
2582 if (ret >= 48) return 48;
2583 return 32;
2584 case SM_CYMENU:
2585 ncm.cbSize = sizeof(ncm);
2586 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2587 return ncm.iMenuHeight + 1;
2588 case SM_CXFULLSCREEN:
2589 /* see the remark for SM_CXMAXIMIZED, at least this formulation is
2590 * correct */
2591 return GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME);
2592 case SM_CYFULLSCREEN:
2593 /* see the remark for SM_CYMAXIMIZED, at least this formulation is
2594 * correct */
2595 return GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN);
2596 case SM_CYKANJIWINDOW:
2597 return 0;
2598 case SM_MOUSEPRESENT:
2599 return 1;
2600 case SM_DEBUG:
2601 return 0;
2602 case SM_SWAPBUTTON:
2603 get_entry( &entry_MOUSEBUTTONSWAP, 0, &ret );
2604 return ret;
2605 case SM_RESERVED1:
2606 case SM_RESERVED2:
2607 case SM_RESERVED3:
2608 case SM_RESERVED4:
2609 return 0;
2610 case SM_CXMIN:
2611 ncm.cbSize = sizeof(ncm);
2612 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2613 hdc = get_display_dc();
2614 get_text_metr_size( hdc, &ncm.lfCaptionFont, NULL, &ret );
2615 release_display_dc( hdc );
2616 return 3 * ncm.iCaptionWidth + ncm.iCaptionHeight + 4 * ret + 2 * GetSystemMetrics(SM_CXFRAME) + 4;
2617 case SM_CYMIN:
2618 return GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME);
2619 case SM_CXSIZE:
2620 ncm.cbSize = sizeof(ncm);
2621 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2622 return ncm.iCaptionWidth;
2623 case SM_CYSIZE:
2624 ncm.cbSize = sizeof(ncm);
2625 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2626 return ncm.iCaptionHeight;
2627 case SM_CXFRAME:
2628 ncm.cbSize = sizeof(ncm);
2629 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2630 return GetSystemMetrics(SM_CXDLGFRAME) + ncm.iBorderWidth;
2631 case SM_CYFRAME:
2632 ncm.cbSize = sizeof(ncm);
2633 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2634 return GetSystemMetrics(SM_CYDLGFRAME) + ncm.iBorderWidth;
2635 case SM_CXMINTRACK:
2636 return GetSystemMetrics(SM_CXMIN);
2637 case SM_CYMINTRACK:
2638 return GetSystemMetrics(SM_CYMIN);
2639 case SM_CXDOUBLECLK:
2640 get_entry( &entry_DOUBLECLKWIDTH, 0, &ret );
2641 return ret;
2642 case SM_CYDOUBLECLK:
2643 get_entry( &entry_DOUBLECLKHEIGHT, 0, &ret );
2644 return ret;
2645 case SM_CXICONSPACING:
2646 im.cbSize = sizeof(im);
2647 SystemParametersInfoW( SPI_GETICONMETRICS, sizeof(im), &im, 0 );
2648 return im.iHorzSpacing;
2649 case SM_CYICONSPACING:
2650 im.cbSize = sizeof(im);
2651 SystemParametersInfoW( SPI_GETICONMETRICS, sizeof(im), &im, 0 );
2652 return im.iVertSpacing;
2653 case SM_MENUDROPALIGNMENT:
2654 SystemParametersInfoW( SPI_GETMENUDROPALIGNMENT, 0, &ret, 0 );
2655 return ret;
2656 case SM_PENWINDOWS:
2657 return 0;
2658 case SM_DBCSENABLED:
2660 CPINFO cpinfo;
2661 GetCPInfo( CP_ACP, &cpinfo );
2662 return (cpinfo.MaxCharSize > 1);
2664 case SM_CMOUSEBUTTONS:
2665 return 3;
2666 case SM_SECURE:
2667 return 0;
2668 case SM_CXEDGE:
2669 return GetSystemMetrics(SM_CXBORDER) + 1;
2670 case SM_CYEDGE:
2671 return GetSystemMetrics(SM_CYBORDER) + 1;
2672 case SM_CXMINSPACING:
2673 mm.cbSize = sizeof(mm);
2674 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2675 return GetSystemMetrics(SM_CXMINIMIZED) + mm.iHorzGap;
2676 case SM_CYMINSPACING:
2677 mm.cbSize = sizeof(mm);
2678 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2679 return GetSystemMetrics(SM_CYMINIMIZED) + mm.iVertGap;
2680 case SM_CXSMICON:
2681 case SM_CYSMICON:
2682 return map_to_dpi( 16, GetDpiForSystem() ) & ~1;
2683 case SM_CYSMCAPTION:
2684 ncm.cbSize = sizeof(ncm);
2685 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2686 return ncm.iSmCaptionHeight + 1;
2687 case SM_CXSMSIZE:
2688 ncm.cbSize = sizeof(ncm);
2689 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2690 return ncm.iSmCaptionWidth;
2691 case SM_CYSMSIZE:
2692 ncm.cbSize = sizeof(ncm);
2693 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2694 return ncm.iSmCaptionHeight;
2695 case SM_CXMENUSIZE:
2696 ncm.cbSize = sizeof(ncm);
2697 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2698 return ncm.iMenuWidth;
2699 case SM_CYMENUSIZE:
2700 ncm.cbSize = sizeof(ncm);
2701 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2702 return ncm.iMenuHeight;
2703 case SM_ARRANGE:
2704 mm.cbSize = sizeof(mm);
2705 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2706 return mm.iArrange;
2707 case SM_CXMINIMIZED:
2708 mm.cbSize = sizeof(mm);
2709 SystemParametersInfoW( SPI_GETMINIMIZEDMETRICS, sizeof(mm), &mm, 0 );
2710 return mm.iWidth + 6;
2711 case SM_CYMINIMIZED:
2712 ncm.cbSize = sizeof(ncm);
2713 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2714 return ncm.iCaptionHeight + 6;
2715 case SM_CXMAXTRACK:
2716 return GetSystemMetrics(SM_CXVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CXFRAME);
2717 case SM_CYMAXTRACK:
2718 return GetSystemMetrics(SM_CYVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CYFRAME);
2719 case SM_CXMAXIMIZED:
2720 /* FIXME: subtract the width of any vertical application toolbars*/
2721 return GetSystemMetrics(SM_CXSCREEN) + 2 * GetSystemMetrics(SM_CXFRAME);
2722 case SM_CYMAXIMIZED:
2723 /* FIXME: subtract the width of any horizontal application toolbars*/
2724 return GetSystemMetrics(SM_CYSCREEN) + 2 * GetSystemMetrics(SM_CYCAPTION);
2725 case SM_NETWORK:
2726 return 3; /* FIXME */
2727 case SM_CLEANBOOT:
2728 return 0; /* 0 = ok, 1 = failsafe, 2 = failsafe + network */
2729 case SM_CXDRAG:
2730 get_entry( &entry_DRAGWIDTH, 0, &ret );
2731 return ret;
2732 case SM_CYDRAG:
2733 get_entry( &entry_DRAGHEIGHT, 0, &ret );
2734 return ret;
2735 case SM_SHOWSOUNDS:
2736 get_entry( &entry_SHOWSOUNDS, 0, &ret );
2737 return ret;
2738 case SM_CXMENUCHECK:
2739 case SM_CYMENUCHECK:
2741 TEXTMETRICW tm;
2742 ncm.cbSize = sizeof(ncm);
2743 SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2744 hdc = get_display_dc();
2745 get_text_metr_size( hdc, &ncm.lfMenuFont, &tm, NULL);
2746 release_display_dc( hdc );
2747 return tm.tmHeight <= 0 ? 13 : ((tm.tmHeight + tm.tmExternalLeading + 1) / 2) * 2 - 1;
2749 case SM_SLOWMACHINE:
2750 return 0; /* Never true */
2751 case SM_MIDEASTENABLED:
2752 return 0; /* FIXME */
2753 case SM_MOUSEWHEELPRESENT:
2754 return 1;
2755 case SM_CXSCREEN:
2756 get_monitors_info( &info );
2757 return info.primary_rect.right - info.primary_rect.left;
2758 case SM_CYSCREEN:
2759 get_monitors_info( &info );
2760 return info.primary_rect.bottom - info.primary_rect.top;
2761 case SM_XVIRTUALSCREEN:
2762 get_monitors_info( &info );
2763 return info.virtual_rect.left;
2764 case SM_YVIRTUALSCREEN:
2765 get_monitors_info( &info );
2766 return info.virtual_rect.top;
2767 case SM_CXVIRTUALSCREEN:
2768 get_monitors_info( &info );
2769 return info.virtual_rect.right - info.virtual_rect.left;
2770 case SM_CYVIRTUALSCREEN:
2771 get_monitors_info( &info );
2772 return info.virtual_rect.bottom - info.virtual_rect.top;
2773 case SM_CMONITORS:
2774 get_monitors_info( &info );
2775 return info.count;
2776 case SM_SAMEDISPLAYFORMAT:
2777 return 1;
2778 case SM_IMMENABLED:
2779 return 0; /* FIXME */
2780 case SM_CXFOCUSBORDER:
2781 case SM_CYFOCUSBORDER:
2782 return 1;
2783 case SM_TABLETPC:
2784 case SM_MEDIACENTER:
2785 return 0;
2786 case SM_CMETRICS:
2787 return SM_CMETRICS;
2788 default:
2789 return 0;
2794 /***********************************************************************
2795 * GetSystemMetricsForDpi (USER32.@)
2797 INT WINAPI GetSystemMetricsForDpi( INT index, UINT dpi )
2799 NONCLIENTMETRICSW ncm;
2800 ICONMETRICSW im;
2801 UINT ret;
2802 HDC hdc;
2804 /* some metrics are dynamic */
2805 switch (index)
2807 case SM_CXVSCROLL:
2808 case SM_CYHSCROLL:
2809 ncm.cbSize = sizeof(ncm);
2810 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2811 return ncm.iScrollWidth;
2812 case SM_CYCAPTION:
2813 ncm.cbSize = sizeof(ncm);
2814 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2815 return ncm.iCaptionHeight + 1;
2816 case SM_CYVTHUMB:
2817 case SM_CXHTHUMB:
2818 case SM_CYVSCROLL:
2819 case SM_CXHSCROLL:
2820 ncm.cbSize = sizeof(ncm);
2821 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2822 return ncm.iScrollHeight;
2823 case SM_CXICON:
2824 case SM_CYICON:
2825 return map_to_dpi( 32, dpi );
2826 case SM_CXCURSOR:
2827 case SM_CYCURSOR:
2828 ret = map_to_dpi( 32, dpi );
2829 if (ret >= 64) return 64;
2830 if (ret >= 48) return 48;
2831 return 32;
2832 case SM_CYMENU:
2833 ncm.cbSize = sizeof(ncm);
2834 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2835 return ncm.iMenuHeight + 1;
2836 case SM_CXSIZE:
2837 ncm.cbSize = sizeof(ncm);
2838 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2839 return ncm.iCaptionWidth;
2840 case SM_CYSIZE:
2841 ncm.cbSize = sizeof(ncm);
2842 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2843 return ncm.iCaptionHeight;
2844 case SM_CXFRAME:
2845 ncm.cbSize = sizeof(ncm);
2846 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2847 return GetSystemMetricsForDpi( SM_CXDLGFRAME, dpi ) + ncm.iBorderWidth;
2848 case SM_CYFRAME:
2849 ncm.cbSize = sizeof(ncm);
2850 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2851 return GetSystemMetricsForDpi( SM_CYDLGFRAME, dpi ) + ncm.iBorderWidth;
2852 case SM_CXICONSPACING:
2853 im.cbSize = sizeof(im);
2854 SystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im), &im, 0, dpi );
2855 return im.iHorzSpacing;
2856 case SM_CYICONSPACING:
2857 im.cbSize = sizeof(im);
2858 SystemParametersInfoForDpi( SPI_GETICONMETRICS, sizeof(im), &im, 0, dpi );
2859 return im.iVertSpacing;
2860 case SM_CXSMICON:
2861 case SM_CYSMICON:
2862 return map_to_dpi( 16, dpi ) & ~1;
2863 case SM_CYSMCAPTION:
2864 ncm.cbSize = sizeof(ncm);
2865 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2866 return ncm.iSmCaptionHeight + 1;
2867 case SM_CXSMSIZE:
2868 ncm.cbSize = sizeof(ncm);
2869 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2870 return ncm.iSmCaptionWidth;
2871 case SM_CYSMSIZE:
2872 ncm.cbSize = sizeof(ncm);
2873 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2874 return ncm.iSmCaptionHeight;
2875 case SM_CXMENUSIZE:
2876 ncm.cbSize = sizeof(ncm);
2877 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2878 return ncm.iMenuWidth;
2879 case SM_CYMENUSIZE:
2880 ncm.cbSize = sizeof(ncm);
2881 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2882 return ncm.iMenuHeight;
2883 case SM_CXMENUCHECK:
2884 case SM_CYMENUCHECK:
2886 TEXTMETRICW tm;
2887 ncm.cbSize = sizeof(ncm);
2888 SystemParametersInfoForDpi( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0, dpi );
2889 hdc = get_display_dc();
2890 get_text_metr_size( hdc, &ncm.lfMenuFont, &tm, NULL);
2891 release_display_dc( hdc );
2892 return tm.tmHeight <= 0 ? 13 : ((tm.tmHeight + tm.tmExternalLeading - 1) | 1);
2894 default:
2895 return GetSystemMetrics( index );
2900 /***********************************************************************
2901 * SwapMouseButton (USER32.@)
2902 * Reverse or restore the meaning of the left and right mouse buttons
2903 * fSwap [I ] TRUE - reverse, FALSE - original
2904 * RETURN
2905 * previous state
2907 BOOL WINAPI SwapMouseButton( BOOL fSwap )
2909 BOOL prev = GetSystemMetrics(SM_SWAPBUTTON);
2910 SystemParametersInfoW(SPI_SETMOUSEBUTTONSWAP, fSwap, 0, 0);
2911 return prev;
2915 /**********************************************************************
2916 * SetDoubleClickTime (USER32.@)
2918 BOOL WINAPI SetDoubleClickTime( UINT interval )
2920 return SystemParametersInfoW(SPI_SETDOUBLECLICKTIME, interval, 0, 0);
2924 /**********************************************************************
2925 * GetDoubleClickTime (USER32.@)
2927 UINT WINAPI GetDoubleClickTime(void)
2929 UINT time = 0;
2931 get_entry( &entry_DOUBLECLICKTIME, 0, &time );
2932 if (!time) time = 500;
2933 return time;
2937 /*************************************************************************
2938 * GetSysColor (USER32.@)
2940 COLORREF WINAPI DECLSPEC_HOTPATCH GetSysColor( INT nIndex )
2942 COLORREF ret = 0;
2944 if (nIndex >= 0 && nIndex < ARRAY_SIZE( system_colors ))
2945 get_entry( &system_colors[nIndex], 0, &ret );
2946 return ret;
2950 /*************************************************************************
2951 * SetSysColors (USER32.@)
2953 BOOL WINAPI SetSysColors( INT count, const INT *colors, const COLORREF *values )
2955 int i;
2957 if (IS_INTRESOURCE(colors)) return FALSE; /* stupid app passes a color instead of an array */
2959 for (i = 0; i < count; i++)
2960 if (colors[i] >= 0 && colors[i] <= ARRAY_SIZE( system_colors ))
2961 set_entry( &system_colors[colors[i]], values[i], 0, 0 );
2963 /* Send WM_SYSCOLORCHANGE message to all windows */
2965 SendMessageTimeoutW( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0, SMTO_ABORTIFHUNG, 2000, NULL );
2967 /* Repaint affected portions of all visible windows */
2969 RedrawWindow( 0, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
2970 return TRUE;
2974 /*************************************************************************
2975 * SetSysColorsTemp (USER32.@)
2977 DWORD_PTR WINAPI SetSysColorsTemp( const COLORREF *pPens, const HBRUSH *pBrushes, DWORD_PTR n)
2979 FIXME( "no longer supported\n" );
2980 return FALSE;
2984 /***********************************************************************
2985 * GetSysColorBrush (USER32.@)
2987 HBRUSH WINAPI DECLSPEC_HOTPATCH GetSysColorBrush( INT index )
2989 if (index < 0 || index >= ARRAY_SIZE( system_colors )) return 0;
2991 if (!system_colors[index].brush)
2993 HBRUSH brush = CreateSolidBrush( GetSysColor( index ));
2994 __wine_make_gdi_object_system( brush, TRUE );
2995 if (InterlockedCompareExchangePointer( (void **)&system_colors[index].brush, brush, 0 ))
2997 __wine_make_gdi_object_system( brush, FALSE );
2998 DeleteObject( brush );
3001 return system_colors[index].brush;
3005 /***********************************************************************
3006 * SYSCOLOR_GetPen
3008 HPEN SYSCOLOR_GetPen( INT index )
3010 /* We can assert here, because this function is internal to Wine */
3011 assert (0 <= index && index < ARRAY_SIZE( system_colors ));
3013 if (!system_colors[index].pen)
3015 HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( index ));
3016 __wine_make_gdi_object_system( pen, TRUE );
3017 if (InterlockedCompareExchangePointer( (void **)&system_colors[index].pen, pen, 0 ))
3019 __wine_make_gdi_object_system( pen, FALSE );
3020 DeleteObject( pen );
3023 return system_colors[index].pen;
3027 /***********************************************************************
3028 * SYSCOLOR_Get55AABrush
3030 HBRUSH SYSCOLOR_Get55AABrush(void)
3032 static const WORD pattern[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
3033 static HBRUSH brush_55aa;
3035 if (!brush_55aa)
3037 HBITMAP bitmap = CreateBitmap( 8, 8, 1, 1, pattern );
3038 HBRUSH brush = CreatePatternBrush( bitmap );
3039 DeleteObject( bitmap );
3040 __wine_make_gdi_object_system( brush, TRUE );
3041 if (InterlockedCompareExchangePointer( (void **)&brush_55aa, brush, 0 ))
3043 __wine_make_gdi_object_system( brush, FALSE );
3044 DeleteObject( brush );
3047 return brush_55aa;
3050 /***********************************************************************
3051 * ChangeDisplaySettingsA (USER32.@)
3053 LONG WINAPI ChangeDisplaySettingsA( LPDEVMODEA devmode, DWORD flags )
3055 if (devmode) devmode->dmDriverExtra = 0;
3057 return ChangeDisplaySettingsExA(NULL,devmode,NULL,flags,NULL);
3061 /***********************************************************************
3062 * ChangeDisplaySettingsW (USER32.@)
3064 LONG WINAPI ChangeDisplaySettingsW( LPDEVMODEW devmode, DWORD flags )
3066 if (devmode) devmode->dmDriverExtra = 0;
3068 return ChangeDisplaySettingsExW(NULL,devmode,NULL,flags,NULL);
3072 /***********************************************************************
3073 * ChangeDisplaySettingsExA (USER32.@)
3075 LONG WINAPI ChangeDisplaySettingsExA( LPCSTR devname, LPDEVMODEA devmode, HWND hwnd,
3076 DWORD flags, LPVOID lparam )
3078 LONG ret;
3079 UNICODE_STRING nameW;
3081 if (devname) RtlCreateUnicodeStringFromAsciiz(&nameW, devname);
3082 else nameW.Buffer = NULL;
3084 if (devmode)
3086 DEVMODEW *devmodeW;
3088 devmodeW = GdiConvertToDevmodeW(devmode);
3089 if (devmodeW)
3091 ret = ChangeDisplaySettingsExW(nameW.Buffer, devmodeW, hwnd, flags, lparam);
3092 HeapFree(GetProcessHeap(), 0, devmodeW);
3094 else
3095 ret = DISP_CHANGE_SUCCESSFUL;
3097 else
3099 ret = ChangeDisplaySettingsExW(nameW.Buffer, NULL, hwnd, flags, lparam);
3102 if (devname) RtlFreeUnicodeString(&nameW);
3103 return ret;
3107 /***********************************************************************
3108 * ChangeDisplaySettingsExW (USER32.@)
3110 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
3111 DWORD flags, LPVOID lparam )
3113 return USER_Driver->pChangeDisplaySettingsEx( devname, devmode, hwnd, flags, lparam );
3117 /***********************************************************************
3118 * DisplayConfigGetDeviceInfo (USER32.@)
3120 LONG WINAPI DisplayConfigGetDeviceInfo(DISPLAYCONFIG_DEVICE_INFO_HEADER *packet)
3122 FIXME("stub: %p\n", packet);
3123 return ERROR_NOT_SUPPORTED;
3126 /***********************************************************************
3127 * EnumDisplaySettingsW (USER32.@)
3129 * RETURNS
3130 * TRUE if nth setting exists found (described in the LPDEVMODEW struct)
3131 * FALSE if we do not have the nth setting
3133 BOOL WINAPI EnumDisplaySettingsW( LPCWSTR name, DWORD n, LPDEVMODEW devmode )
3135 return EnumDisplaySettingsExW(name, n, devmode, 0);
3139 /***********************************************************************
3140 * EnumDisplaySettingsA (USER32.@)
3142 BOOL WINAPI EnumDisplaySettingsA(LPCSTR name,DWORD n,LPDEVMODEA devmode)
3144 return EnumDisplaySettingsExA(name, n, devmode, 0);
3148 /***********************************************************************
3149 * EnumDisplaySettingsExA (USER32.@)
3151 BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum,
3152 LPDEVMODEA lpDevMode, DWORD dwFlags)
3154 DEVMODEW devmodeW;
3155 BOOL ret;
3156 UNICODE_STRING nameW;
3158 if (lpszDeviceName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszDeviceName);
3159 else nameW.Buffer = NULL;
3161 ret = EnumDisplaySettingsExW(nameW.Buffer,iModeNum,&devmodeW,dwFlags);
3162 if (ret)
3164 lpDevMode->dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod);
3165 lpDevMode->dmSpecVersion = devmodeW.dmSpecVersion;
3166 lpDevMode->dmDriverVersion = devmodeW.dmDriverVersion;
3167 WideCharToMultiByte(CP_ACP, 0, devmodeW.dmDeviceName, -1,
3168 (LPSTR)lpDevMode->dmDeviceName, CCHDEVICENAME, NULL, NULL);
3169 lpDevMode->dmDriverExtra = 0; /* FIXME */
3170 lpDevMode->dmBitsPerPel = devmodeW.dmBitsPerPel;
3171 lpDevMode->dmPelsHeight = devmodeW.dmPelsHeight;
3172 lpDevMode->dmPelsWidth = devmodeW.dmPelsWidth;
3173 lpDevMode->u2.dmDisplayFlags = devmodeW.u2.dmDisplayFlags;
3174 lpDevMode->dmDisplayFrequency = devmodeW.dmDisplayFrequency;
3175 lpDevMode->dmFields = devmodeW.dmFields;
3177 lpDevMode->u1.s2.dmPosition.x = devmodeW.u1.s2.dmPosition.x;
3178 lpDevMode->u1.s2.dmPosition.y = devmodeW.u1.s2.dmPosition.y;
3179 lpDevMode->u1.s2.dmDisplayOrientation = devmodeW.u1.s2.dmDisplayOrientation;
3180 lpDevMode->u1.s2.dmDisplayFixedOutput = devmodeW.u1.s2.dmDisplayFixedOutput;
3182 if (lpszDeviceName) RtlFreeUnicodeString(&nameW);
3183 return ret;
3187 /***********************************************************************
3188 * EnumDisplaySettingsExW (USER32.@)
3190 BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
3191 LPDEVMODEW lpDevMode, DWORD dwFlags)
3193 return USER_Driver->pEnumDisplaySettingsEx(lpszDeviceName, iModeNum, lpDevMode, dwFlags);
3197 /**********************************************************************
3198 * get_monitor_dpi
3200 UINT get_monitor_dpi( HMONITOR monitor )
3202 /* FIXME: use the monitor DPI instead */
3203 return system_dpi;
3206 /**********************************************************************
3207 * get_win_monitor_dpi
3209 UINT get_win_monitor_dpi( HWND hwnd )
3211 /* FIXME: use the monitor DPI instead */
3212 return system_dpi;
3215 /**********************************************************************
3216 * get_thread_dpi
3218 UINT get_thread_dpi(void)
3220 switch (GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ))
3222 case DPI_AWARENESS_UNAWARE: return USER_DEFAULT_SCREEN_DPI;
3223 case DPI_AWARENESS_SYSTEM_AWARE: return system_dpi;
3224 default: return 0; /* no scaling */
3228 /**********************************************************************
3229 * map_dpi_point
3231 POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to )
3233 if (dpi_from && dpi_to && dpi_from != dpi_to)
3235 pt.x = MulDiv( pt.x, dpi_to, dpi_from );
3236 pt.y = MulDiv( pt.y, dpi_to, dpi_from );
3238 return pt;
3241 /**********************************************************************
3242 * point_win_to_phys_dpi
3244 POINT point_win_to_phys_dpi( HWND hwnd, POINT pt )
3246 return map_dpi_point( pt, GetDpiForWindow( hwnd ), get_win_monitor_dpi( hwnd ) );
3249 /**********************************************************************
3250 * point_phys_to_win_dpi
3252 POINT point_phys_to_win_dpi( HWND hwnd, POINT pt )
3254 return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd ));
3257 /**********************************************************************
3258 * point_win_to_thread_dpi
3260 POINT point_win_to_thread_dpi( HWND hwnd, POINT pt )
3262 UINT dpi = get_thread_dpi();
3263 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3264 return map_dpi_point( pt, GetDpiForWindow( hwnd ), dpi );
3267 /**********************************************************************
3268 * point_thread_to_win_dpi
3270 POINT point_thread_to_win_dpi( HWND hwnd, POINT pt )
3272 UINT dpi = get_thread_dpi();
3273 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3274 return map_dpi_point( pt, dpi, GetDpiForWindow( hwnd ));
3277 /**********************************************************************
3278 * map_dpi_rect
3280 RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to )
3282 if (dpi_from && dpi_to && dpi_from != dpi_to)
3284 rect.left = MulDiv( rect.left, dpi_to, dpi_from );
3285 rect.top = MulDiv( rect.top, dpi_to, dpi_from );
3286 rect.right = MulDiv( rect.right, dpi_to, dpi_from );
3287 rect.bottom = MulDiv( rect.bottom, dpi_to, dpi_from );
3289 return rect;
3292 /**********************************************************************
3293 * rect_win_to_thread_dpi
3295 RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect )
3297 UINT dpi = get_thread_dpi();
3298 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3299 return map_dpi_rect( rect, GetDpiForWindow( hwnd ), dpi );
3302 /**********************************************************************
3303 * rect_thread_to_win_dpi
3305 RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect )
3307 UINT dpi = get_thread_dpi();
3308 if (!dpi) dpi = get_win_monitor_dpi( hwnd );
3309 return map_dpi_rect( rect, dpi, GetDpiForWindow( hwnd ) );
3312 /**********************************************************************
3313 * SetProcessDpiAwarenessContext (USER32.@)
3315 BOOL WINAPI SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3317 DPI_AWARENESS val = GetAwarenessFromDpiAwarenessContext( context );
3319 if (val == DPI_AWARENESS_INVALID)
3321 SetLastError( ERROR_INVALID_PARAMETER );
3322 return FALSE;
3324 val |= 0x10; /* avoid 0 value */
3325 if (InterlockedCompareExchange( &dpi_awareness, val, 0 ))
3327 SetLastError( ERROR_ACCESS_DENIED );
3328 return FALSE;
3330 TRACE( "set to %p\n", context );
3331 return TRUE;
3334 /**********************************************************************
3335 * GetProcessDpiAwarenessInternal (USER32.@)
3337 BOOL WINAPI GetProcessDpiAwarenessInternal( HANDLE process, DPI_AWARENESS *awareness )
3339 if (process && process != GetCurrentProcess())
3341 WARN( "not supported on other process %p\n", process );
3342 *awareness = DPI_AWARENESS_UNAWARE;
3344 else *awareness = dpi_awareness & 3;
3345 return TRUE;
3348 /**********************************************************************
3349 * SetProcessDpiAwarenessInternal (USER32.@)
3351 BOOL WINAPI SetProcessDpiAwarenessInternal( DPI_AWARENESS awareness )
3353 static const DPI_AWARENESS_CONTEXT contexts[3] = { DPI_AWARENESS_CONTEXT_UNAWARE,
3354 DPI_AWARENESS_CONTEXT_SYSTEM_AWARE,
3355 DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE };
3357 if (awareness < DPI_AWARENESS_UNAWARE || awareness > DPI_AWARENESS_PER_MONITOR_AWARE)
3359 SetLastError( ERROR_INVALID_PARAMETER );
3360 return FALSE;
3362 return SetProcessDpiAwarenessContext( contexts[awareness] );
3365 /***********************************************************************
3366 * AreDpiAwarenessContextsEqual (USER32.@)
3368 BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWARENESS_CONTEXT ctx2 )
3370 DPI_AWARENESS aware1 = GetAwarenessFromDpiAwarenessContext( ctx1 );
3371 DPI_AWARENESS aware2 = GetAwarenessFromDpiAwarenessContext( ctx2 );
3372 return aware1 != DPI_AWARENESS_INVALID && aware1 == aware2;
3375 /***********************************************************************
3376 * GetAwarenessFromDpiAwarenessContext (USER32.@)
3378 DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3380 switch ((ULONG_PTR)context)
3382 case 0x10:
3383 case 0x11:
3384 case 0x12:
3385 case 0x80000010:
3386 case 0x80000011:
3387 case 0x80000012:
3388 return (ULONG_PTR)context & 3;
3389 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE:
3390 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE:
3391 case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE:
3392 return ~(ULONG_PTR)context;
3393 default:
3394 return DPI_AWARENESS_INVALID;
3398 /***********************************************************************
3399 * IsValidDpiAwarenessContext (USER32.@)
3401 BOOL WINAPI IsValidDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3403 return GetAwarenessFromDpiAwarenessContext( context ) != DPI_AWARENESS_INVALID;
3406 /***********************************************************************
3407 * SetProcessDPIAware (USER32.@)
3409 BOOL WINAPI SetProcessDPIAware(void)
3411 TRACE("\n");
3412 InterlockedCompareExchange( &dpi_awareness, 0x11, 0 );
3413 return TRUE;
3416 /***********************************************************************
3417 * IsProcessDPIAware (USER32.@)
3419 BOOL WINAPI IsProcessDPIAware(void)
3421 return GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ) != DPI_AWARENESS_UNAWARE;
3424 /***********************************************************************
3425 * GetDpiForSystem (USER32.@)
3427 UINT WINAPI GetDpiForSystem(void)
3429 if (!IsProcessDPIAware()) return USER_DEFAULT_SCREEN_DPI;
3430 return system_dpi;
3433 /***********************************************************************
3434 * GetDpiForMonitorInternal (USER32.@)
3436 BOOL WINAPI GetDpiForMonitorInternal( HMONITOR monitor, UINT type, UINT *x, UINT *y )
3438 if (type > 2)
3440 SetLastError( ERROR_BAD_ARGUMENTS );
3441 return FALSE;
3443 if (!x || !y)
3445 SetLastError( ERROR_INVALID_ADDRESS );
3446 return FALSE;
3448 switch (GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ))
3450 case DPI_AWARENESS_UNAWARE: *x = *y = USER_DEFAULT_SCREEN_DPI; break;
3451 case DPI_AWARENESS_SYSTEM_AWARE: *x = *y = system_dpi; break;
3452 default: *x = *y = get_monitor_dpi( monitor ); break;
3454 return TRUE;
3457 /**********************************************************************
3458 * GetThreadDpiAwarenessContext (USER32.@)
3460 DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
3462 struct user_thread_info *info = get_user_thread_info();
3464 if (info->dpi_awareness) return ULongToHandle( info->dpi_awareness );
3465 if (dpi_awareness) return ULongToHandle( dpi_awareness );
3466 return ULongToHandle( 0x10 | default_awareness );
3469 /**********************************************************************
3470 * SetThreadDpiAwarenessContext (USER32.@)
3472 DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
3474 struct user_thread_info *info = get_user_thread_info();
3475 DPI_AWARENESS prev, val = GetAwarenessFromDpiAwarenessContext( context );
3477 if (val == DPI_AWARENESS_INVALID)
3479 SetLastError( ERROR_INVALID_PARAMETER );
3480 return 0;
3482 if (!(prev = info->dpi_awareness))
3484 prev = dpi_awareness;
3485 if (!prev) prev = 0x10 | DPI_AWARENESS_UNAWARE;
3486 prev |= 0x80000000; /* restore to process default */
3488 if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0;
3489 else info->dpi_awareness = val | 0x10;
3490 return ULongToHandle( prev );
3493 /**********************************************************************
3494 * LogicalToPhysicalPointForPerMonitorDPI (USER32.@)
3496 BOOL WINAPI LogicalToPhysicalPointForPerMonitorDPI( HWND hwnd, POINT *pt )
3498 RECT rect;
3500 if (!GetWindowRect( hwnd, &rect )) return FALSE;
3501 if (pt->x < rect.left || pt->y < rect.top || pt->x > rect.right || pt->y > rect.bottom) return FALSE;
3502 *pt = point_win_to_phys_dpi( hwnd, *pt );
3503 return TRUE;
3506 /**********************************************************************
3507 * PhysicalToLogicalPointForPerMonitorDPI (USER32.@)
3509 BOOL WINAPI PhysicalToLogicalPointForPerMonitorDPI( HWND hwnd, POINT *pt )
3511 DPI_AWARENESS_CONTEXT context;
3512 RECT rect;
3513 BOOL ret = FALSE;
3515 context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
3516 if (GetWindowRect( hwnd, &rect ) &&
3517 pt->x >= rect.left && pt->y >= rect.top && pt->x <= rect.right && pt->y <= rect.bottom)
3519 *pt = point_phys_to_win_dpi( hwnd, *pt );
3520 ret = TRUE;
3522 SetThreadDpiAwarenessContext( context );
3523 return ret;
3526 struct monitor_enum_info
3528 RECT rect;
3529 UINT max_area;
3530 UINT min_distance;
3531 HMONITOR primary;
3532 HMONITOR nearest;
3533 HMONITOR ret;
3536 /* helper callback for MonitorFromRect */
3537 static BOOL CALLBACK monitor_enum( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
3539 struct monitor_enum_info *info = (struct monitor_enum_info *)lp;
3540 RECT intersect;
3542 if (IntersectRect( &intersect, rect, &info->rect ))
3544 /* check for larger intersecting area */
3545 UINT area = (intersect.right - intersect.left) * (intersect.bottom - intersect.top);
3546 if (area > info->max_area)
3548 info->max_area = area;
3549 info->ret = monitor;
3552 else if (!info->max_area) /* if not intersecting, check for min distance */
3554 UINT distance;
3555 UINT x, y;
3557 if (info->rect.right <= rect->left) x = rect->left - info->rect.right;
3558 else if (rect->right <= info->rect.left) x = info->rect.left - rect->right;
3559 else x = 0;
3560 if (info->rect.bottom <= rect->top) y = rect->top - info->rect.bottom;
3561 else if (rect->bottom <= info->rect.top) y = info->rect.top - rect->bottom;
3562 else y = 0;
3563 distance = x * x + y * y;
3564 if (distance < info->min_distance)
3566 info->min_distance = distance;
3567 info->nearest = monitor;
3570 if (!info->primary)
3572 MONITORINFO mon_info;
3573 mon_info.cbSize = sizeof(mon_info);
3574 GetMonitorInfoW( monitor, &mon_info );
3575 if (mon_info.dwFlags & MONITORINFOF_PRIMARY) info->primary = monitor;
3577 return TRUE;
3580 /***********************************************************************
3581 * MonitorFromRect (USER32.@)
3583 HMONITOR WINAPI MonitorFromRect( const RECT *rect, DWORD flags )
3585 struct monitor_enum_info info;
3587 info.rect = *rect;
3588 info.max_area = 0;
3589 info.min_distance = ~0u;
3590 info.primary = 0;
3591 info.nearest = 0;
3592 info.ret = 0;
3594 if (IsRectEmpty(&info.rect))
3596 info.rect.right = info.rect.left + 1;
3597 info.rect.bottom = info.rect.top + 1;
3600 if (!EnumDisplayMonitors( 0, NULL, monitor_enum, (LPARAM)&info )) return 0;
3601 if (!info.ret)
3603 if (flags & MONITOR_DEFAULTTOPRIMARY) info.ret = info.primary;
3604 else if (flags & MONITOR_DEFAULTTONEAREST) info.ret = info.nearest;
3607 TRACE( "%s flags %x returning %p\n", wine_dbgstr_rect(rect), flags, info.ret );
3608 return info.ret;
3611 /***********************************************************************
3612 * MonitorFromPoint (USER32.@)
3614 HMONITOR WINAPI MonitorFromPoint( POINT pt, DWORD flags )
3616 RECT rect;
3618 SetRect( &rect, pt.x, pt.y, pt.x + 1, pt.y + 1 );
3619 return MonitorFromRect( &rect, flags );
3622 /***********************************************************************
3623 * MonitorFromWindow (USER32.@)
3625 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
3627 RECT rect;
3628 WINDOWPLACEMENT wp;
3630 TRACE("(%p, 0x%08x)\n", hWnd, dwFlags);
3632 wp.length = sizeof(wp);
3633 if (IsIconic(hWnd) && GetWindowPlacement(hWnd, &wp))
3634 return MonitorFromRect( &wp.rcNormalPosition, dwFlags );
3636 if (GetWindowRect( hWnd, &rect ))
3637 return MonitorFromRect( &rect, dwFlags );
3639 if (!(dwFlags & (MONITOR_DEFAULTTOPRIMARY|MONITOR_DEFAULTTONEAREST))) return 0;
3640 /* retrieve the primary */
3641 SetRect( &rect, 0, 0, 1, 1 );
3642 return MonitorFromRect( &rect, dwFlags );
3645 /***********************************************************************
3646 * GetMonitorInfoA (USER32.@)
3648 BOOL WINAPI GetMonitorInfoA( HMONITOR monitor, LPMONITORINFO info )
3650 MONITORINFOEXW miW;
3651 BOOL ret;
3653 if (info->cbSize == sizeof(MONITORINFO)) return GetMonitorInfoW( monitor, info );
3654 if (info->cbSize != sizeof(MONITORINFOEXA)) return FALSE;
3656 miW.cbSize = sizeof(miW);
3657 ret = GetMonitorInfoW( monitor, (MONITORINFO *)&miW );
3658 if (ret)
3660 MONITORINFOEXA *miA = (MONITORINFOEXA *)info;
3661 miA->rcMonitor = miW.rcMonitor;
3662 miA->rcWork = miW.rcWork;
3663 miA->dwFlags = miW.dwFlags;
3664 WideCharToMultiByte(CP_ACP, 0, miW.szDevice, -1, miA->szDevice, sizeof(miA->szDevice), NULL, NULL);
3666 return ret;
3669 /***********************************************************************
3670 * GetMonitorInfoW (USER32.@)
3672 BOOL WINAPI GetMonitorInfoW( HMONITOR monitor, LPMONITORINFO info )
3674 BOOL ret;
3675 UINT dpi_from, dpi_to;
3677 if (info->cbSize != sizeof(MONITORINFOEXW) && info->cbSize != sizeof(MONITORINFO)) return FALSE;
3679 ret = USER_Driver->pGetMonitorInfo( monitor, info );
3680 if (ret)
3682 if ((dpi_to = get_thread_dpi()))
3684 dpi_from = get_monitor_dpi( monitor );
3685 info->rcMonitor = map_dpi_rect( info->rcMonitor, dpi_from, dpi_to );
3686 info->rcWork = map_dpi_rect( info->rcWork, dpi_from, dpi_to );
3688 TRACE( "flags %04x, monitor %s, work %s\n", info->dwFlags,
3689 wine_dbgstr_rect(&info->rcMonitor), wine_dbgstr_rect(&info->rcWork));
3691 return ret;
3694 struct enum_mon_data
3696 MONITORENUMPROC proc;
3697 LPARAM lparam;
3698 HDC hdc;
3699 POINT origin;
3700 RECT limit;
3703 #ifdef __i386__
3704 /* Some apps pass a non-stdcall callback to EnumDisplayMonitors,
3705 * so we need a small assembly wrapper to call it.
3706 * MJ's Help Diagnostic expects that %ecx contains the address to the rect.
3708 extern BOOL enum_mon_callback_wrapper( HMONITOR monitor, LPRECT rect, struct enum_mon_data *data );
3709 __ASM_GLOBAL_FUNC( enum_mon_callback_wrapper,
3710 "pushl %ebp\n\t"
3711 __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
3712 __ASM_CFI(".cfi_rel_offset %ebp,0\n\t")
3713 "movl %esp,%ebp\n\t"
3714 __ASM_CFI(".cfi_def_cfa_register %ebp\n\t")
3715 "subl $8,%esp\n\t"
3716 "movl 16(%ebp),%eax\n\t" /* data */
3717 "movl 12(%ebp),%ecx\n\t" /* rect */
3718 "pushl 4(%eax)\n\t" /* data->lparam */
3719 "pushl %ecx\n\t" /* rect */
3720 "pushl 8(%eax)\n\t" /* data->hdc */
3721 "pushl 8(%ebp)\n\t" /* monitor */
3722 "call *(%eax)\n\t" /* data->proc */
3723 "leave\n\t"
3724 __ASM_CFI(".cfi_def_cfa %esp,4\n\t")
3725 __ASM_CFI(".cfi_same_value %ebp\n\t")
3726 "ret" )
3727 #endif /* __i386__ */
3729 static BOOL CALLBACK enum_mon_callback( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
3731 struct enum_mon_data *data = (struct enum_mon_data *)lp;
3732 RECT monrect = map_dpi_rect( *rect, get_monitor_dpi( monitor ), get_thread_dpi() );
3734 OffsetRect( &monrect, -data->origin.x, -data->origin.y );
3735 if (!IntersectRect( &monrect, &monrect, &data->limit )) return TRUE;
3736 #ifdef __i386__
3737 return enum_mon_callback_wrapper( monitor, &monrect, data );
3738 #else
3739 return data->proc( monitor, data->hdc, &monrect, data->lparam );
3740 #endif
3743 /***********************************************************************
3744 * EnumDisplayMonitors (USER32.@)
3746 BOOL WINAPI EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
3748 struct enum_mon_data data;
3750 data.proc = proc;
3751 data.lparam = lp;
3752 data.hdc = hdc;
3754 if (hdc)
3756 if (!GetDCOrgEx( hdc, &data.origin )) return FALSE;
3757 if (GetClipBox( hdc, &data.limit ) == ERROR) return FALSE;
3759 else
3761 data.origin.x = data.origin.y = 0;
3762 data.limit.left = data.limit.top = INT_MIN;
3763 data.limit.right = data.limit.bottom = INT_MAX;
3765 if (rect && !IntersectRect( &data.limit, &data.limit, rect )) return TRUE;
3766 return USER_Driver->pEnumDisplayMonitors( 0, NULL, enum_mon_callback, (LPARAM)&data );
3770 /**********************************************************************
3771 * GetAutoRotationState [USER32.@]
3773 BOOL WINAPI GetAutoRotationState( AR_STATE *state )
3775 TRACE("(%p)\n", state);
3777 if (!state)
3779 SetLastError(ERROR_INVALID_PARAMETER);
3780 return FALSE;
3783 *state = AR_NOSENSOR;
3784 return TRUE;
3787 /**********************************************************************
3788 * GetDisplayAutoRotationPreferences [USER32.@]
3790 BOOL WINAPI GetDisplayAutoRotationPreferences( ORIENTATION_PREFERENCE *orientation )
3792 FIXME("(%p): stub\n", orientation);
3793 *orientation = ORIENTATION_PREFERENCE_NONE;
3794 return TRUE;
3797 /* physical<->logical mapping functions from win8 that are nops in later versions */
3799 /***********************************************************************
3800 * GetPhysicalCursorPos (USER32.@)
3802 BOOL WINAPI GetPhysicalCursorPos( POINT *point )
3804 return GetCursorPos( point );
3807 /***********************************************************************
3808 * SetPhysicalCursorPos (USER32.@)
3810 BOOL WINAPI SetPhysicalCursorPos( INT x, INT y )
3812 return SetCursorPos( x, y );
3815 /***********************************************************************
3816 * LogicalToPhysicalPoint (USER32.@)
3818 BOOL WINAPI LogicalToPhysicalPoint( HWND hwnd, POINT *point )
3820 return TRUE;
3823 /***********************************************************************
3824 * PhysicalToLogicalPoint (USER32.@)
3826 BOOL WINAPI PhysicalToLogicalPoint( HWND hwnd, POINT *point )
3828 return TRUE;