user32: Initialize cbSize of NONCLIENTMETRICSW struct in GetSystemMetrics.
[wine] / dlls / user32 / sysparams.c
1 /*
2  * System parameters functions
3  *
4  * Copyright 1994 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22
23 #include <assert.h>
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28
29 #define NONAMELESSUNION
30 #define NONAMELESSSTRUCT
31
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winnls.h"
35 #include "wingdi.h"
36 #include "winreg.h"
37 #include "wine/wingdi16.h"
38 #include "winerror.h"
39
40 #include "controls.h"
41 #include "user_private.h"
42 #include "wine/gdi_driver.h"
43 #include "wine/unicode.h"
44 #include "wine/debug.h"
45
46 WINE_DEFAULT_DEBUG_CHANNEL(system);
47
48 /* System parameter indexes */
49 enum spi_index
50 {
51     SPI_SETWORKAREA_IDX,
52     SPI_INDEX_COUNT
53 };
54
55 /**
56  * Names of the registry subkeys of HKEY_CURRENT_USER key and value names
57  * for the system parameters.
58  */
59
60 /* the various registry keys that are used to store parameters */
61 enum parameter_key
62 {
63     COLORS_KEY,
64     DESKTOP_KEY,
65     KEYBOARD_KEY,
66     MOUSE_KEY,
67     METRICS_KEY,
68     SOUND_KEY,
69     VERSION_KEY,
70     SHOWSOUNDS_KEY,
71     KEYBOARDPREF_KEY,
72     SCREENREADER_KEY,
73     NB_PARAM_KEYS
74 };
75
76 static const WCHAR COLORS_REGKEY[] =   {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','C','o','l','o','r','s',0};
77 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};
78 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};
79 static const WCHAR MOUSE_REGKEY[] =    {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','M','o','u','s','e',0};
80 static const WCHAR METRICS_REGKEY[] =  {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\\',
81                                         'W','i','n','d','o','w','M','e','t','r','i','c','s',0};
82 static const WCHAR SOUND_REGKEY[]=     {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','S','o','u','n','d',0};
83 static const WCHAR VERSION_REGKEY[] =  {'S','o','f','t','w','a','r','e','\\',
84                                         'M','i','c','r','o','s','o','f','t','\\',
85                                         'W','i','n','d','o','w','s',' ','N','T','\\',
86                                         'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
87                                         'W','i','n','d','o','w','s',0};
88 static const WCHAR SHOWSOUNDS_REGKEY[] =   {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
89                                             'A','c','c','e','s','s','i','b','i','l','i','t','y','\\',
90                                             'S','h','o','w','S','o','u','n','d','s',0};
91 static const WCHAR KEYBOARDPREF_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                                             'K','e','y','b','o','a','r','d',' ','P','r','e','f','e','r','e','n','c','e',0};
94 static const WCHAR SCREENREADER_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                                             'B','l','i','n','d',' ','A','c','c','e','s','s',0};
97
98 static const WCHAR *parameter_key_names[NB_PARAM_KEYS] =
99 {
100     COLORS_REGKEY,
101     DESKTOP_REGKEY,
102     KEYBOARD_REGKEY,
103     MOUSE_REGKEY,
104     METRICS_REGKEY,
105     SOUND_REGKEY,
106     VERSION_REGKEY,
107     SHOWSOUNDS_REGKEY,
108     KEYBOARDPREF_REGKEY,
109     SCREENREADER_REGKEY,
110 };
111
112 /* parameter key values; the first char is actually an enum parameter_key to specify the key */
113 static const WCHAR BEEP_VALNAME[]=                     {SOUND_KEY,'B','e','e','p',0};
114 static const WCHAR MOUSETHRESHOLD1_VALNAME[]=          {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','1',0};
115 static const WCHAR MOUSETHRESHOLD2_VALNAME[]=          {MOUSE_KEY,'M','o','u','s','e','T','h','r','e','s','h','o','l','d','2',0};
116 static const WCHAR MOUSEACCELERATION_VALNAME[]=        {MOUSE_KEY,'M','o','u','s','e','S','p','e','e','d',0};
117 static const WCHAR BORDER_VALNAME[]=                   {METRICS_KEY,'B','o','r','d','e','r','W','i','d','t','h',0};
118 static const WCHAR KEYBOARDSPEED_VALNAME[]=            {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','S','p','e','e','d',0};
119 static const WCHAR ICONHORIZONTALSPACING_VALNAME[]=    {METRICS_KEY,'I','c','o','n','S','p','a','c','i','n','g',0};
120 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};
121 static const WCHAR SCREENSAVEACTIVE_VALNAME[]=         {DESKTOP_KEY,'S','c','r','e','e','n','S','a','v','e','A','c','t','i','v','e',0};
122 static const WCHAR GRIDGRANULARITY_VALNAME[]=          {DESKTOP_KEY,'G','r','i','d','G','r','a','n','u','l','a','r','i','t','y',0};
123 static const WCHAR KEYBOARDDELAY_VALNAME[]=            {KEYBOARD_KEY,'K','e','y','b','o','a','r','d','D','e','l','a','y',0};
124 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};
125 static const WCHAR ICONTITLEWRAP_VALNAME[]=            {DESKTOP_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
126 static const WCHAR ICONTITLEWRAP_MIRROR[]=             {METRICS_KEY,'I','c','o','n','T','i','t','l','e','W','r','a','p',0};
127 static const WCHAR ICONTITLELOGFONT_VALNAME[]=         {METRICS_KEY,'I','c','o','n','F','o','n','t',0};
128 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};
129 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};
130 static const WCHAR MOUSETRAILS_VALNAME[]=              {MOUSE_KEY,'M','o','u','s','e','T','r','a','i','l','s',0};
131 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};
132 static const WCHAR DOUBLECLKWIDTH_VALNAME[]=           {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
133 static const WCHAR DOUBLECLKWIDTH_MIRROR[]=            {DESKTOP_KEY,'D','o','u','b','l','e','C','l','i','c','k','W','i','d','t','h',0};
134 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};
135 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};
136 static const WCHAR DOUBLECLICKTIME_VALNAME[]=          {MOUSE_KEY,'D','o','u','b','l','e','C','l','i','c','k','S','p','e','e','d',0};
137 static const WCHAR MOUSEBUTTONSWAP_VALNAME[]=          {MOUSE_KEY,'S','w','a','p','M','o','u','s','e','B','u','t','t','o','n','s',0};
138 static const WCHAR DRAGFULLWINDOWS_VALNAME[]=          {DESKTOP_KEY,'D','r','a','g','F','u','l','l','W','i','n','d','o','w','s',0};
139 static const WCHAR SHOWSOUNDS_VALNAME[]=               {SHOWSOUNDS_KEY,'O','n',0};
140 static const WCHAR KEYBOARDPREF_VALNAME[]=             {KEYBOARDPREF_KEY,'O','n',0};
141 static const WCHAR SCREENREADER_VALNAME[]=             {SCREENREADER_KEY,'O','n',0};
142 static const WCHAR DESKWALLPAPER_VALNAME[]=            {DESKTOP_KEY,'W','a','l','l','p','a','p','e','r',0};
143 static const WCHAR DESKPATTERN_VALNAME[]=              {DESKTOP_KEY,'P','a','t','t','e','r','n',0};
144 static const WCHAR FONTSMOOTHING_VALNAME[]=            {DESKTOP_KEY,'F','o','n','t','S','m','o','o','t','h','i','n','g',0};
145 static const WCHAR DRAGWIDTH_VALNAME[]=                {DESKTOP_KEY,'D','r','a','g','W','i','d','t','h',0};
146 static const WCHAR DRAGHEIGHT_VALNAME[]=               {DESKTOP_KEY,'D','r','a','g','H','e','i','g','h','t',0};
147 static const WCHAR LOWPOWERACTIVE_VALNAME[]=           {DESKTOP_KEY,'L','o','w','P','o','w','e','r','A','c','t','i','v','e',0};
148 static const WCHAR POWEROFFACTIVE_VALNAME[]=           {DESKTOP_KEY,'P','o','w','e','r','O','f','f','A','c','t','i','v','e',0};
149 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};
150 static const WCHAR MOUSEHOVERWIDTH_VALNAME[]=          {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','W','i','d','t','h',0};
151 static const WCHAR MOUSEHOVERHEIGHT_VALNAME[]=         {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','H','e','i','g','h','t',0};
152 static const WCHAR MOUSEHOVERTIME_VALNAME[]=           {MOUSE_KEY,'M','o','u','s','e','H','o','v','e','r','T','i','m','e',0};
153 static const WCHAR WHEELSCROLLCHARS_VALNAME[]=         {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','C','h','a','r','s',0};
154 static const WCHAR WHEELSCROLLLINES_VALNAME[]=         {DESKTOP_KEY,'W','h','e','e','l','S','c','r','o','l','l','L','i','n','e','s',0};
155 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};
156 static const WCHAR MENUSHOWDELAY_VALNAME[]=            {DESKTOP_KEY,'M','e','n','u','S','h','o','w','D','e','l','a','y',0};
157 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};
158 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};
159 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};
160 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};
161 static const WCHAR CARETWIDTH_VALNAME[]=               {DESKTOP_KEY,'C','a','r','e','t','W','i','d','t','h',0};
162 static const WCHAR MOUSECLICKLOCKTIME_VALNAME[]=       {DESKTOP_KEY,'C','l','i','c','k','L','o','c','k','T','i','m','e',0};
163 static const WCHAR MOUSESPEED_VALNAME[]=               {MOUSE_KEY,'M','o','u','s','e','S','e','n','s','i','t','i','v','i','t','y',0};
164 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};
165 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};
166 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};
167 static const WCHAR FOCUSBORDERWIDTH_VALNAME[]=         {DESKTOP_KEY,'F','o','c','u','s','B','o','r','d','e','r','W','i','d','t','h',0};
168 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};
169 static const WCHAR SCROLLWIDTH_VALNAME[]=              {METRICS_KEY,'S','c','r','o','l','l','W','i','d','t','h',0};
170 static const WCHAR SCROLLHEIGHT_VALNAME[]=             {METRICS_KEY,'S','c','r','o','l','l','H','e','i','g','h','t',0};
171 static const WCHAR CAPTIONWIDTH_VALNAME[]=             {METRICS_KEY,'C','a','p','t','i','o','n','W','i','d','t','h',0};
172 static const WCHAR CAPTIONHEIGHT_VALNAME[]=            {METRICS_KEY,'C','a','p','t','i','o','n','H','e','i','g','h','t',0};
173 static const WCHAR SMCAPTIONWIDTH_VALNAME[]=           {METRICS_KEY,'S','m','C','a','p','t','i','o','n','W','i','d','t','h',0};
174 static const WCHAR SMCAPTIONHEIGHT_VALNAME[]=          {METRICS_KEY,'S','m','C','a','p','t','i','o','n','H','e','i','g','h','t',0};
175 static const WCHAR MENUWIDTH_VALNAME[]=                {METRICS_KEY,'M','e','n','u','W','i','d','t','h',0};
176 static const WCHAR MENUHEIGHT_VALNAME[]=               {METRICS_KEY,'M','e','n','u','H','e','i','g','h','t',0};
177 static const WCHAR ICONSIZE_VALNAME[]=                 {METRICS_KEY,'S','h','e','l','l',' ','I','c','o','n',' ','S','i','z','e',0};
178 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};
179 static const WCHAR CAPTIONLOGFONT_VALNAME[]=           {METRICS_KEY,'C','a','p','t','i','o','n','F','o','n','t',0};
180 static const WCHAR SMCAPTIONLOGFONT_VALNAME[]=         {METRICS_KEY,'S','m','C','a','p','t','i','o','n','F','o','n','t',0};
181 static const WCHAR MENULOGFONT_VALNAME[]=              {METRICS_KEY,'M','e','n','u','F','o','n','t',0};
182 static const WCHAR MESSAGELOGFONT_VALNAME[]=           {METRICS_KEY,'M','e','s','s','a','g','e','F','o','n','t',0};
183 static const WCHAR STATUSLOGFONT_VALNAME[]=            {METRICS_KEY,'S','t','a','t','u','s','F','o','n','t',0};
184 static const WCHAR MINWIDTH_VALNAME[] =                {METRICS_KEY,'M','i','n','W','i','d','t','h',0};
185 static const WCHAR MINHORZGAP_VALNAME[] =              {METRICS_KEY,'M','i','n','H','o','r','z','G','a','p',0};
186 static const WCHAR MINVERTGAP_VALNAME[] =              {METRICS_KEY,'M','i','n','V','e','r','t','G','a','p',0};
187 static const WCHAR MINARRANGE_VALNAME[] =              {METRICS_KEY,'M','i','n','A','r','r','a','n','g','e',0};
188 static const WCHAR COLOR_SCROLLBAR_VALNAME[] =         {COLORS_KEY,'S','c','r','o','l','l','b','a','r',0};
189 static const WCHAR COLOR_BACKGROUND_VALNAME[] =        {COLORS_KEY,'B','a','c','k','g','r','o','u','n','d',0};
190 static const WCHAR COLOR_ACTIVECAPTION_VALNAME[] =     {COLORS_KEY,'A','c','t','i','v','e','T','i','t','l','e',0};
191 static const WCHAR COLOR_INACTIVECAPTION_VALNAME[] =   {COLORS_KEY,'I','n','a','c','t','i','v','e','T','i','t','l','e',0};
192 static const WCHAR COLOR_MENU_VALNAME[] =              {COLORS_KEY,'M','e','n','u',0};
193 static const WCHAR COLOR_WINDOW_VALNAME[] =            {COLORS_KEY,'W','i','n','d','o','w',0};
194 static const WCHAR COLOR_WINDOWFRAME_VALNAME[] =       {COLORS_KEY,'W','i','n','d','o','w','F','r','a','m','e',0};
195 static const WCHAR COLOR_MENUTEXT_VALNAME[] =          {COLORS_KEY,'M','e','n','u','T','e','x','t',0};
196 static const WCHAR COLOR_WINDOWTEXT_VALNAME[] =        {COLORS_KEY,'W','i','n','d','o','w','T','e','x','t',0};
197 static const WCHAR COLOR_CAPTIONTEXT_VALNAME[] =       {COLORS_KEY,'T','i','t','l','e','T','e','x','t',0};
198 static const WCHAR COLOR_ACTIVEBORDER_VALNAME[] =      {COLORS_KEY,'A','c','t','i','v','e','B','o','r','d','e','r',0};
199 static const WCHAR COLOR_INACTIVEBORDER_VALNAME[] =    {COLORS_KEY,'I','n','a','c','t','i','v','e','B','o','r','d','e','r',0};
200 static const WCHAR COLOR_APPWORKSPACE_VALNAME[] =      {COLORS_KEY,'A','p','p','W','o','r','k','S','p','a','c','e',0};
201 static const WCHAR COLOR_HIGHLIGHT_VALNAME[] =         {COLORS_KEY,'H','i','l','i','g','h','t',0};
202 static const WCHAR COLOR_HIGHLIGHTTEXT_VALNAME[] =     {COLORS_KEY,'H','i','l','i','g','h','t','T','e','x','t',0};
203 static const WCHAR COLOR_BTNFACE_VALNAME[] =           {COLORS_KEY,'B','u','t','t','o','n','F','a','c','e',0};
204 static const WCHAR COLOR_BTNSHADOW_VALNAME[] =         {COLORS_KEY,'B','u','t','t','o','n','S','h','a','d','o','w',0};
205 static const WCHAR COLOR_GRAYTEXT_VALNAME[] =          {COLORS_KEY,'G','r','a','y','T','e','x','t',0};
206 static const WCHAR COLOR_BTNTEXT_VALNAME[] =           {COLORS_KEY,'B','u','t','t','o','n','T','e','x','t',0};
207 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};
208 static const WCHAR COLOR_BTNHIGHLIGHT_VALNAME[] =      {COLORS_KEY,'B','u','t','t','o','n','H','i','l','i','g','h','t',0};
209 static const WCHAR COLOR_3DDKSHADOW_VALNAME[] =        {COLORS_KEY,'B','u','t','t','o','n','D','k','S','h','a','d','o','w',0};
210 static const WCHAR COLOR_3DLIGHT_VALNAME[] =           {COLORS_KEY,'B','u','t','t','o','n','L','i','g','h','t',0};
211 static const WCHAR COLOR_INFOTEXT_VALNAME[] =          {COLORS_KEY,'I','n','f','o','T','e','x','t',0};
212 static const WCHAR COLOR_INFOBK_VALNAME[] =            {COLORS_KEY,'I','n','f','o','W','i','n','d','o','w',0};
213 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};
214 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};
215 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};
216 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};
217 static const WCHAR COLOR_MENUHILIGHT_VALNAME[] =       {COLORS_KEY,'M','e','n','u','H','i','l','i','g','h','t',0};
218 static const WCHAR COLOR_MENUBAR_VALNAME[] =           {COLORS_KEY,'M','e','n','u','B','a','r',0};
219
220 /* FIXME - real value */
221 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};
222
223 static const WCHAR WINE_CURRENT_USER_REGKEY[] = {'S','o','f','t','w','a','r','e','\\',
224                                                  'W','i','n','e',0};
225
226 /* volatile registry branch under WINE_CURRENT_USER_REGKEY for temporary values storage */
227 static const WCHAR WINE_CURRENT_USER_REGKEY_TEMP_PARAMS[] = {'T','e','m','p','o','r','a','r','y',' ',
228                                                              'S','y','s','t','e','m',' ',
229                                                              'P','a','r','a','m','e','t','e','r','s',0};
230
231 static const WCHAR Yes[] =   {'Y','e','s',0};
232 static const WCHAR No[] =    {'N','o',0};
233 static const WCHAR CSu[] =   {'%','u',0};
234 static const WCHAR CSd[] =   {'%','d',0};
235 static const WCHAR CSrgb[] = {'%','u',' ','%','u',' ','%','u',0};
236
237 /* Indicators whether system parameter value is loaded */
238 static char spi_loaded[SPI_INDEX_COUNT];
239
240 static BOOL notify_change = TRUE;
241
242 /* System parameters storage */
243 static RECT work_area;
244
245 static const WORD wPattern55AA[] = { 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa, 0x5555, 0xaaaa };
246
247 static HKEY volatile_base_key;
248
249 HBRUSH SYSCOLOR_55AABrush = 0;
250
251 union sysparam_all_entry;
252
253 struct sysparam_entry
254 {
255     BOOL       (*get)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param );
256     BOOL       (*set)( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags );
257     BOOL       (*init)( union sysparam_all_entry *entry );
258     const WCHAR *regval;
259     const WCHAR *mirror;
260     BOOL         loaded;
261 };
262
263 struct sysparam_uint_entry
264 {
265     struct sysparam_entry hdr;
266     UINT                  val;
267 };
268
269 struct sysparam_bool_entry
270 {
271     struct sysparam_entry hdr;
272     BOOL                  val;
273 };
274
275 struct sysparam_dword_entry
276 {
277     struct sysparam_entry hdr;
278     DWORD                 val;
279 };
280
281 struct sysparam_rgb_entry
282 {
283     struct sysparam_entry hdr;
284     COLORREF              val;
285     HBRUSH                brush;
286     HPEN                  pen;
287 };
288
289 struct sysparam_binary_entry
290 {
291     struct sysparam_entry hdr;
292     void                 *ptr;
293     size_t                size;
294 };
295
296 struct sysparam_path_entry
297 {
298     struct sysparam_entry hdr;
299     WCHAR                 path[MAX_PATH];
300 };
301
302 struct sysparam_font_entry
303 {
304     struct sysparam_entry hdr;
305     UINT                  weight;
306     LOGFONTW              val;
307 };
308
309 struct sysparam_pref_entry
310 {
311     struct sysparam_entry hdr;
312     struct sysparam_binary_entry *parent;
313     UINT                  offset;
314     UINT                  mask;
315 };
316
317 union sysparam_all_entry
318 {
319     struct sysparam_entry        hdr;
320     struct sysparam_uint_entry   uint;
321     struct sysparam_bool_entry   bool;
322     struct sysparam_dword_entry  dword;
323     struct sysparam_rgb_entry    rgb;
324     struct sysparam_binary_entry bin;
325     struct sysparam_path_entry   path;
326     struct sysparam_font_entry   font;
327     struct sysparam_pref_entry   pref;
328 };
329
330 static void SYSPARAMS_LogFont16To32W( const LOGFONT16 *font16, LPLOGFONTW font32 )
331 {
332     font32->lfHeight = font16->lfHeight;
333     font32->lfWidth = font16->lfWidth;
334     font32->lfEscapement = font16->lfEscapement;
335     font32->lfOrientation = font16->lfOrientation;
336     font32->lfWeight = font16->lfWeight;
337     font32->lfItalic = font16->lfItalic;
338     font32->lfUnderline = font16->lfUnderline;
339     font32->lfStrikeOut = font16->lfStrikeOut;
340     font32->lfCharSet = font16->lfCharSet;
341     font32->lfOutPrecision = font16->lfOutPrecision;
342     font32->lfClipPrecision = font16->lfClipPrecision;
343     font32->lfQuality = font16->lfQuality;
344     font32->lfPitchAndFamily = font16->lfPitchAndFamily;
345     MultiByteToWideChar( CP_ACP, 0, font16->lfFaceName, -1, font32->lfFaceName, LF_FACESIZE );
346     font32->lfFaceName[LF_FACESIZE-1] = 0;
347 }
348
349 static void SYSPARAMS_LogFont32WTo32A( const LOGFONTW* font32W, LPLOGFONTA font32A )
350 {
351     font32A->lfHeight = font32W->lfHeight;
352     font32A->lfWidth = font32W->lfWidth;
353     font32A->lfEscapement = font32W->lfEscapement;
354     font32A->lfOrientation = font32W->lfOrientation;
355     font32A->lfWeight = font32W->lfWeight;
356     font32A->lfItalic = font32W->lfItalic;
357     font32A->lfUnderline = font32W->lfUnderline;
358     font32A->lfStrikeOut = font32W->lfStrikeOut;
359     font32A->lfCharSet = font32W->lfCharSet;
360     font32A->lfOutPrecision = font32W->lfOutPrecision;
361     font32A->lfClipPrecision = font32W->lfClipPrecision;
362     font32A->lfQuality = font32W->lfQuality;
363     font32A->lfPitchAndFamily = font32W->lfPitchAndFamily;
364     WideCharToMultiByte( CP_ACP, 0, font32W->lfFaceName, -1, font32A->lfFaceName, LF_FACESIZE, NULL, NULL );
365     font32A->lfFaceName[LF_FACESIZE-1] = 0;
366 }
367
368 static void SYSPARAMS_LogFont32ATo32W( const LOGFONTA* font32A, LPLOGFONTW font32W )
369 {
370     font32W->lfHeight = font32A->lfHeight;
371     font32W->lfWidth = font32A->lfWidth;
372     font32W->lfEscapement = font32A->lfEscapement;
373     font32W->lfOrientation = font32A->lfOrientation;
374     font32W->lfWeight = font32A->lfWeight;
375     font32W->lfItalic = font32A->lfItalic;
376     font32W->lfUnderline = font32A->lfUnderline;
377     font32W->lfStrikeOut = font32A->lfStrikeOut;
378     font32W->lfCharSet = font32A->lfCharSet;
379     font32W->lfOutPrecision = font32A->lfOutPrecision;
380     font32W->lfClipPrecision = font32A->lfClipPrecision;
381     font32W->lfQuality = font32A->lfQuality;
382     font32W->lfPitchAndFamily = font32A->lfPitchAndFamily;
383     MultiByteToWideChar( CP_ACP, 0, font32A->lfFaceName, -1, font32W->lfFaceName, LF_FACESIZE );
384     font32W->lfFaceName[LF_FACESIZE-1] = 0;
385 }
386
387 static void SYSPARAMS_NonClientMetrics32WTo32A( const NONCLIENTMETRICSW* lpnm32W, LPNONCLIENTMETRICSA lpnm32A )
388 {
389     lpnm32A->iBorderWidth       = lpnm32W->iBorderWidth;
390     lpnm32A->iScrollWidth       = lpnm32W->iScrollWidth;
391     lpnm32A->iScrollHeight      = lpnm32W->iScrollHeight;
392     lpnm32A->iCaptionWidth      = lpnm32W->iCaptionWidth;
393     lpnm32A->iCaptionHeight     = lpnm32W->iCaptionHeight;
394     SYSPARAMS_LogFont32WTo32A(  &lpnm32W->lfCaptionFont,        &lpnm32A->lfCaptionFont );
395     lpnm32A->iSmCaptionWidth    = lpnm32W->iSmCaptionWidth;
396     lpnm32A->iSmCaptionHeight   = lpnm32W->iSmCaptionHeight;
397     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfSmCaptionFont,       &lpnm32A->lfSmCaptionFont );
398     lpnm32A->iMenuWidth         = lpnm32W->iMenuWidth;
399     lpnm32A->iMenuHeight        = lpnm32W->iMenuHeight;
400     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMenuFont,            &lpnm32A->lfMenuFont );
401     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfStatusFont,          &lpnm32A->lfStatusFont );
402     SYSPARAMS_LogFont32WTo32A( &lpnm32W->lfMessageFont,         &lpnm32A->lfMessageFont );
403     if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
404     {
405         if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
406             lpnm32A->iPaddedBorderWidth = lpnm32W->iPaddedBorderWidth;
407         else
408             lpnm32A->iPaddedBorderWidth = 0;
409     }
410 }
411
412 static void SYSPARAMS_NonClientMetrics32ATo32W( const NONCLIENTMETRICSA* lpnm32A, LPNONCLIENTMETRICSW lpnm32W )
413 {
414     lpnm32W->iBorderWidth       = lpnm32A->iBorderWidth;
415     lpnm32W->iScrollWidth       = lpnm32A->iScrollWidth;
416     lpnm32W->iScrollHeight      = lpnm32A->iScrollHeight;
417     lpnm32W->iCaptionWidth      = lpnm32A->iCaptionWidth;
418     lpnm32W->iCaptionHeight     = lpnm32A->iCaptionHeight;
419     SYSPARAMS_LogFont32ATo32W(  &lpnm32A->lfCaptionFont,        &lpnm32W->lfCaptionFont );
420     lpnm32W->iSmCaptionWidth    = lpnm32A->iSmCaptionWidth;
421     lpnm32W->iSmCaptionHeight   = lpnm32A->iSmCaptionHeight;
422     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfSmCaptionFont,       &lpnm32W->lfSmCaptionFont );
423     lpnm32W->iMenuWidth         = lpnm32A->iMenuWidth;
424     lpnm32W->iMenuHeight        = lpnm32A->iMenuHeight;
425     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMenuFont,            &lpnm32W->lfMenuFont );
426     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfStatusFont,          &lpnm32W->lfStatusFont );
427     SYSPARAMS_LogFont32ATo32W( &lpnm32A->lfMessageFont,         &lpnm32W->lfMessageFont );
428     if (lpnm32W->cbSize > FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth))
429     {
430         if (lpnm32A->cbSize > FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth))
431             lpnm32W->iPaddedBorderWidth = lpnm32A->iPaddedBorderWidth;
432         else
433             lpnm32W->iPaddedBorderWidth = 0;
434     }
435 }
436
437
438 /* Helper functions to retrieve monitors info */
439
440 struct monitor_info
441 {
442     int count;
443     RECT virtual_rect;
444 };
445
446 static BOOL CALLBACK monitor_info_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
447 {
448     struct monitor_info *info = (struct monitor_info *)lp;
449     info->count++;
450     UnionRect( &info->virtual_rect, &info->virtual_rect, rect );
451     return TRUE;
452 }
453
454 static void get_monitors_info( struct monitor_info *info )
455 {
456     info->count = 0;
457     SetRectEmpty( &info->virtual_rect );
458     EnumDisplayMonitors( 0, NULL, monitor_info_proc, (LPARAM)info );
459 }
460
461 RECT get_virtual_screen_rect(void)
462 {
463     struct monitor_info info;
464     get_monitors_info( &info );
465     return info.virtual_rect;
466 }
467
468 /* get text metrics and/or "average" char width of the specified logfont 
469  * for the specified dc */
470 static void get_text_metr_size( HDC hdc, LOGFONTW *plf, TEXTMETRICW * ptm, UINT *psz)
471 {
472     HFONT hfont, hfontsav;
473     TEXTMETRICW tm;
474     if( !ptm) ptm = &tm;
475     hfont = CreateFontIndirectW( plf);
476     if( !hfont || ( hfontsav = SelectObject( hdc, hfont)) == NULL ) {
477         ptm->tmHeight = -1;
478         if( psz) *psz = 10;
479         if( hfont) DeleteObject( hfont);
480         return;
481     }
482     GetTextMetricsW( hdc, ptm);
483     if( psz)
484         if( !(*psz = GdiGetCharDimensions( hdc, ptm, NULL)))
485             *psz = 10;
486     SelectObject( hdc, hfontsav);
487     DeleteObject( hfont);
488 }
489
490 /***********************************************************************
491  *           SYSPARAMS_NotifyChange
492  *
493  * Sends notification about system parameter update.
494  */
495 static void SYSPARAMS_NotifyChange( UINT uiAction, UINT fWinIni )
496 {
497     static const WCHAR emptyW[1];
498
499     if (notify_change)
500     {
501         if (fWinIni & SPIF_UPDATEINIFILE)
502         {
503             if (fWinIni & (SPIF_SENDWININICHANGE | SPIF_SENDCHANGE))
504                 SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE,
505                                     uiAction, (LPARAM) emptyW,
506                                     SMTO_ABORTIFHUNG, 2000, NULL );
507         }
508         else
509         {
510             /* FIXME notify other wine processes with internal message */
511         }
512     }
513 }
514
515 /* retrieve the cached base keys for a given entry */
516 static BOOL get_base_keys( enum parameter_key index, HKEY *base_key, HKEY *volatile_key )
517 {
518     static HKEY base_keys[NB_PARAM_KEYS];
519     static HKEY volatile_keys[NB_PARAM_KEYS];
520     HKEY key;
521
522     if (!base_keys[index] && base_key)
523     {
524         if (RegCreateKeyW( HKEY_CURRENT_USER, parameter_key_names[index], &key )) return FALSE;
525         if (InterlockedCompareExchangePointer( (void **)&base_keys[index], key, 0 ))
526             RegCloseKey( key );
527     }
528     if (!volatile_keys[index] && volatile_key)
529     {
530         if (RegCreateKeyExW( volatile_base_key, parameter_key_names[index],
531                              0, 0, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, &key, 0 )) return FALSE;
532         if (InterlockedCompareExchangePointer( (void **)&volatile_keys[index], key, 0 ))
533             RegCloseKey( key );
534     }
535     if (base_key) *base_key = base_keys[index];
536     if (volatile_key) *volatile_key = volatile_keys[index];
537     return TRUE;
538 }
539
540 /* load a value to a registry entry */
541 static DWORD load_entry( struct sysparam_entry *entry, void *data, DWORD size )
542 {
543     DWORD type, count = 0;
544     HKEY base_key, volatile_key;
545
546     if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
547
548     count = size;
549     if (RegQueryValueExW( volatile_key, entry->regval + 1, NULL, &type, data, &count ))
550     {
551         count = size;
552         if (RegQueryValueExW( base_key, entry->regval + 1, NULL, &type, data, &count )) count = 0;
553     }
554     /* make sure strings are null-terminated */
555     if (size && count == size && type == REG_SZ) ((WCHAR *)data)[count - 1] = 0;
556     entry->loaded = TRUE;
557     return count;
558 }
559
560 /* save a value to a registry entry */
561 static BOOL save_entry( const struct sysparam_entry *entry, const void *data, DWORD size,
562                         DWORD type, UINT flags )
563 {
564     HKEY base_key, volatile_key;
565
566     if (flags & SPIF_UPDATEINIFILE)
567     {
568         if (!get_base_keys( entry->regval[0], &base_key, &volatile_key )) return FALSE;
569         if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
570         RegDeleteValueW( volatile_key, entry->regval + 1 );
571
572         if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
573             RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
574     }
575     else
576     {
577         if (!get_base_keys( entry->regval[0], NULL, &volatile_key )) return FALSE;
578         if (RegSetValueExW( volatile_key, entry->regval + 1, 0, type, data, size )) return FALSE;
579     }
580     return TRUE;
581 }
582
583 /* save a string value to a registry entry */
584 static BOOL save_entry_string( const struct sysparam_entry *entry, const WCHAR *str, UINT flags )
585 {
586     return save_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ, flags );
587 }
588
589 /* initialize an entry in the registry if missing */
590 static BOOL init_entry( struct sysparam_entry *entry, const void *data, DWORD size, DWORD type )
591 {
592     HKEY base_key;
593
594     if (!get_base_keys( entry->regval[0], &base_key, NULL )) return FALSE;
595     if (!RegQueryValueExW( base_key, entry->regval + 1, NULL, NULL, NULL, NULL )) return TRUE;
596     if (RegSetValueExW( base_key, entry->regval + 1, 0, type, data, size )) return FALSE;
597     if (entry->mirror && get_base_keys( entry->mirror[0], &base_key, NULL ))
598         RegSetValueExW( base_key, entry->mirror + 1, 0, type, data, size );
599     entry->loaded = TRUE;
600     return TRUE;
601 }
602
603 /* initialize a string value in the registry if missing */
604 static BOOL init_entry_string( struct sysparam_entry *entry, const WCHAR *str )
605 {
606     return init_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ );
607 }
608
609 static inline HDC get_display_dc(void)
610 {
611     static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
612     static HDC display_dc;
613     if (!display_dc)
614     {
615         display_dc = CreateICW( DISPLAY, NULL, NULL, NULL );
616         __wine_make_gdi_object_system( display_dc, TRUE );
617     }
618     return display_dc;
619 }
620
621 static inline int get_display_dpi(void)
622 {
623     static int display_dpi;
624     if (!display_dpi) display_dpi = GetDeviceCaps( get_display_dc(), LOGPIXELSY );
625     return display_dpi;
626 }
627
628 /* adjust some of the raw values found in the registry */
629 static void normalize_nonclientmetrics( NONCLIENTMETRICSW *pncm)
630 {
631     TEXTMETRICW tm;
632     if( pncm->iBorderWidth < 1) pncm->iBorderWidth = 1;
633     if( pncm->iCaptionWidth < 8) pncm->iCaptionWidth = 8;
634     if( pncm->iScrollWidth < 8) pncm->iScrollWidth = 8;
635     if( pncm->iScrollHeight < 8) pncm->iScrollHeight = 8;
636
637     /* adjust some heights to the corresponding font */
638     get_text_metr_size( get_display_dc(), &pncm->lfMenuFont, &tm, NULL);
639     pncm->iMenuHeight = max( pncm->iMenuHeight, 2 + tm.tmHeight + tm.tmExternalLeading );
640     get_text_metr_size( get_display_dc(), &pncm->lfCaptionFont, &tm, NULL);
641     pncm->iCaptionHeight = max( pncm->iCaptionHeight, 2 + tm.tmHeight);
642     get_text_metr_size( get_display_dc(), &pncm->lfSmCaptionFont, &tm, NULL);
643     pncm->iSmCaptionHeight = max( pncm->iSmCaptionHeight, 2 + tm.tmHeight);
644 }
645
646 static BOOL CALLBACK enum_monitors( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
647 {
648     MONITORINFO mi;
649
650     mi.cbSize = sizeof(mi);
651     if (GetMonitorInfoW( monitor, &mi ) && (mi.dwFlags & MONITORINFOF_PRIMARY))
652     {
653         LPRECT work = (LPRECT)lp;
654         *work = mi.rcWork;
655         return FALSE;
656     }
657     return TRUE;
658 }
659
660 /* load a uint parameter from the registry */
661 static BOOL get_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
662 {
663     if (!ptr_param) return FALSE;
664
665     if (!entry->hdr.loaded)
666     {
667         WCHAR buf[32];
668
669         if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->uint.val = atoiW( buf );
670     }
671     *(UINT *)ptr_param = entry->uint.val;
672     return TRUE;
673 }
674
675 /* set a uint parameter in the registry */
676 static BOOL set_uint_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
677 {
678     WCHAR buf[32];
679
680     wsprintfW( buf, CSu, int_param );
681     if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
682     entry->uint.val = int_param;
683     entry->hdr.loaded = TRUE;
684     return TRUE;
685 }
686
687 /* initialize a uint parameter */
688 static BOOL init_uint_entry( union sysparam_all_entry *entry )
689 {
690     WCHAR buf[32];
691
692     wsprintfW( buf, CSu, entry->uint.val );
693     return init_entry_string( &entry->hdr, buf );
694 }
695
696 /* set an int parameter in the registry */
697 static BOOL set_int_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
698 {
699     WCHAR buf[32];
700
701     wsprintfW( buf, CSd, int_param );
702     if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
703     entry->uint.val = int_param;
704     entry->hdr.loaded = TRUE;
705     return TRUE;
706 }
707
708 /* initialize an int parameter */
709 static BOOL init_int_entry( union sysparam_all_entry *entry )
710 {
711     WCHAR buf[32];
712
713     wsprintfW( buf, CSd, entry->uint.val );
714     return init_entry_string( &entry->hdr, buf );
715 }
716
717 /* load a twips parameter from the registry */
718 static BOOL get_twips_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
719 {
720     if (!ptr_param) return FALSE;
721
722     if (!entry->hdr.loaded)
723     {
724         WCHAR buf[32];
725
726         if (load_entry( &entry->hdr, buf, sizeof(buf) ))
727         {
728             int val = atoiW( buf );
729             /* Dimension are quoted as being "twips" values if negative and pixels if positive.
730              * One inch is 1440 twips.
731              * See for example
732              *       Technical Reference to the Windows 2000 Registry ->
733              *       HKEY_CURRENT_USER -> Control Panel -> Desktop -> WindowMetrics
734              */
735             if (val < 0) val = (-val * get_display_dpi() + 720) / 1440;
736             entry->uint.val = val;
737         }
738     }
739     *(UINT *)ptr_param = entry->uint.val;
740     return TRUE;
741 }
742
743 /* load a bool parameter from the registry */
744 static BOOL get_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
745 {
746     if (!ptr_param) return FALSE;
747
748     if (!entry->hdr.loaded)
749     {
750         WCHAR buf[32];
751
752         if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = atoiW( buf ) != 0;
753     }
754     *(UINT *)ptr_param = entry->bool.val;
755     return TRUE;
756 }
757
758 /* set a bool parameter in the registry */
759 static BOOL set_bool_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
760 {
761     WCHAR buf[32];
762
763     wsprintfW( buf, CSu, int_param != 0 );
764     if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
765     entry->bool.val = int_param != 0;
766     entry->hdr.loaded = TRUE;
767     return TRUE;
768 }
769
770 /* initialize a bool parameter */
771 static BOOL init_bool_entry( union sysparam_all_entry *entry )
772 {
773     WCHAR buf[32];
774
775     wsprintfW( buf, CSu, entry->bool.val != 0 );
776     return init_entry_string( &entry->hdr, buf );
777 }
778
779 /* load a bool parameter using Yes/No strings from the registry */
780 static BOOL get_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
781 {
782     if (!ptr_param) return FALSE;
783
784     if (!entry->hdr.loaded)
785     {
786         WCHAR buf[32];
787
788         if (load_entry( &entry->hdr, buf, sizeof(buf) )) entry->bool.val = !lstrcmpiW( Yes, buf );
789     }
790     *(UINT *)ptr_param = entry->bool.val;
791     return TRUE;
792 }
793
794 /* set a bool parameter using Yes/No strings from the registry */
795 static BOOL set_yesno_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
796 {
797     const WCHAR *str = int_param ? Yes : No;
798
799     if (!save_entry_string( &entry->hdr, str, flags )) return FALSE;
800     entry->bool.val = int_param != 0;
801     entry->hdr.loaded = TRUE;
802     return TRUE;
803 }
804
805 /* initialize a bool parameter using Yes/No strings */
806 static BOOL init_yesno_entry( union sysparam_all_entry *entry )
807 {
808     return init_entry_string( &entry->hdr, entry->bool.val ? Yes : No );
809 }
810
811 /* load a dword (binary) parameter from the registry */
812 static BOOL get_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
813 {
814     if (!ptr_param) return FALSE;
815
816     if (!entry->hdr.loaded)
817     {
818         DWORD val;
819         if (load_entry( &entry->hdr, &val, sizeof(val) ) == sizeof(DWORD)) entry->dword.val = val;
820     }
821     *(DWORD *)ptr_param = entry->bool.val;
822     return TRUE;
823 }
824
825 /* set a dword (binary) parameter in the registry */
826 static BOOL set_dword_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
827 {
828     DWORD val = PtrToUlong( ptr_param );
829
830     if (!save_entry( &entry->hdr, &val, sizeof(val), REG_DWORD, flags )) return FALSE;
831     entry->dword.val = val;
832     entry->hdr.loaded = TRUE;
833     return TRUE;
834 }
835
836 /* initialize a dword parameter */
837 static BOOL init_dword_entry( union sysparam_all_entry *entry )
838 {
839     return init_entry( &entry->hdr, &entry->dword.val, sizeof(entry->dword.val), REG_DWORD );
840 }
841
842 /* load an RGB parameter from the registry */
843 static BOOL get_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
844 {
845     if (!ptr_param) return FALSE;
846
847     if (!entry->hdr.loaded)
848     {
849         WCHAR buf[32];
850
851         if (load_entry( &entry->hdr, buf, sizeof(buf) ))
852         {
853             DWORD r, g, b;
854             WCHAR *end, *str = buf;
855
856             r = strtoulW( str, &end, 10 );
857             if (end == str || !*end) goto done;
858             str = end + 1;
859             g = strtoulW( str, &end, 10 );
860             if (end == str || !*end) goto done;
861             str = end + 1;
862             b = strtoulW( str, &end, 10 );
863             if (end == str) goto done;
864             if (r > 255 || g > 255 || b > 255) goto done;
865             entry->rgb.val = RGB( r, g, b );
866         }
867     }
868 done:
869     *(COLORREF *)ptr_param = entry->rgb.val;
870     return TRUE;
871 }
872
873 /* set an RGB parameter in the registry */
874 static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
875 {
876     WCHAR buf[32];
877     HBRUSH brush;
878     HPEN pen;
879
880     wsprintfW( buf, CSrgb, GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
881     if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
882     entry->rgb.val = int_param;
883     entry->hdr.loaded = TRUE;
884     if ((brush = InterlockedExchangePointer( (void **)&entry->rgb.brush, 0 )))
885     {
886         __wine_make_gdi_object_system( brush, FALSE );
887         DeleteObject( brush );
888     }
889     if ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
890     {
891         __wine_make_gdi_object_system( pen, FALSE );
892         DeleteObject( pen );
893     }
894     return TRUE;
895 }
896
897 /* initialize an RGB parameter */
898 static BOOL init_rgb_entry( union sysparam_all_entry *entry )
899 {
900     WCHAR buf[32];
901
902     wsprintfW( buf, CSrgb, GetRValue(entry->rgb.val), GetGValue(entry->rgb.val), GetBValue(entry->rgb.val) );
903     return init_entry_string( &entry->hdr, buf );
904 }
905
906 /* load a font (binary) parameter from the registry */
907 static BOOL get_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
908 {
909     if (!ptr_param) return FALSE;
910
911     if (!entry->hdr.loaded)
912     {
913         LOGFONTW font;
914
915         switch (load_entry( &entry->hdr, &font, sizeof(font) ))
916         {
917         case sizeof(font):
918             if (font.lfHeight > 0) /* positive height value means points ( inch/72 ) */
919                 font.lfHeight = -MulDiv( font.lfHeight, get_display_dpi(), 72 );
920             entry->font.val = font;
921             break;
922         case sizeof(LOGFONT16): /* win9x-winME format */
923             SYSPARAMS_LogFont16To32W( (LOGFONT16 *)&font, &entry->font.val );
924             if (entry->font.val.lfHeight > 0)
925                 entry->font.val.lfHeight = -MulDiv( entry->font.val.lfHeight, get_display_dpi(), 72 );
926             break;
927         default:
928             WARN( "Unknown format in key %s value %s\n",
929                   debugstr_w( parameter_key_names[entry->hdr.regval[0]] ),
930                   debugstr_w( entry->hdr.regval + 1 ));
931             /* fall through */
932         case 0: /* use the default GUI font */
933             GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(font), &font );
934             font.lfWeight = entry->font.weight;
935             entry->font.val = font;
936             break;
937         }
938         entry->hdr.loaded = TRUE;
939     }
940     *(LOGFONTW *)ptr_param = entry->font.val;
941     return TRUE;
942 }
943
944 /* set a font (binary) parameter in the registry */
945 static BOOL set_font_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
946 {
947     LOGFONTW font;
948     WCHAR *ptr;
949
950     memcpy( &font, ptr_param, sizeof(font) );
951     /* zero pad the end of lfFaceName so we don't save uninitialised data */
952     ptr = memchrW( font.lfFaceName, 0, LF_FACESIZE );
953     if (ptr) memset( ptr, 0, (font.lfFaceName + LF_FACESIZE - ptr) * sizeof(WCHAR) );
954
955     if (!save_entry( &entry->hdr, &font, sizeof(font), REG_BINARY, flags )) return FALSE;
956     entry->font.val = font;
957     entry->hdr.loaded = TRUE;
958     return TRUE;
959 }
960
961 /* initialize a font (binary) parameter */
962 static BOOL init_font_entry( union sysparam_all_entry *entry )
963 {
964     GetObjectW( GetStockObject( DEFAULT_GUI_FONT ), sizeof(entry->font.val), &entry->font.val );
965     entry->font.val.lfWeight = entry->font.weight;
966     return init_entry( &entry->hdr, &entry->font.val, sizeof(entry->font.val), REG_BINARY );
967 }
968
969 /* get a path parameter in the registry */
970 static BOOL get_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
971 {
972     if (!ptr_param) return FALSE;
973
974     if (!entry->hdr.loaded)
975     {
976         WCHAR buffer[MAX_PATH];
977
978         if (load_entry( &entry->hdr, buffer, sizeof(buffer) ))
979             lstrcpynW( entry->path.path, buffer, MAX_PATH );
980     }
981     lstrcpynW( ptr_param, entry->path.path, int_param );
982     return TRUE;
983 }
984
985 /* set a path parameter in the registry */
986 static BOOL set_path_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
987 {
988     WCHAR buffer[MAX_PATH];
989     BOOL ret;
990
991     lstrcpynW( buffer, ptr_param, MAX_PATH );
992     ret = save_entry_string( &entry->hdr, buffer, flags );
993     if (ret)
994     {
995         strcpyW( entry->path.path, buffer );
996         entry->hdr.loaded = TRUE;
997     }
998     return ret;
999 }
1000
1001 /* initialize a path parameter */
1002 static BOOL init_path_entry( union sysparam_all_entry *entry )
1003 {
1004     return init_entry_string( &entry->hdr, entry->path.path );
1005 }
1006
1007 /* get a binary parameter in the registry */
1008 static BOOL get_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
1009 {
1010     if (!ptr_param) return FALSE;
1011
1012     if (!entry->hdr.loaded)
1013     {
1014         void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1015         DWORD len = load_entry( &entry->hdr, buffer, entry->bin.size );
1016
1017         if (len)
1018         {
1019             memcpy( entry->bin.ptr, buffer, entry->bin.size );
1020             memset( (char *)entry->bin.ptr + len, 0, entry->bin.size - len );
1021         }
1022         HeapFree( GetProcessHeap(), 0, buffer );
1023     }
1024     memcpy( ptr_param, entry->bin.ptr, min( int_param, entry->bin.size ) );
1025     return TRUE;
1026 }
1027
1028 /* set a binary parameter in the registry */
1029 static BOOL set_binary_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1030 {
1031     BOOL ret;
1032     void *buffer = HeapAlloc( GetProcessHeap(), 0, entry->bin.size );
1033
1034     memcpy( buffer, entry->bin.ptr, entry->bin.size );
1035     memcpy( buffer, ptr_param, min( int_param, entry->bin.size ));
1036     ret = save_entry( &entry->hdr, buffer, entry->bin.size, REG_BINARY, flags );
1037     if (ret)
1038     {
1039         memcpy( entry->bin.ptr, buffer, entry->bin.size );
1040         entry->hdr.loaded = TRUE;
1041     }
1042     HeapFree( GetProcessHeap(), 0, buffer );
1043     return ret;
1044 }
1045
1046 /* initialize a binary parameter */
1047 static BOOL init_binary_entry( union sysparam_all_entry *entry )
1048 {
1049     return init_entry( &entry->hdr, entry->bin.ptr, entry->bin.size, REG_BINARY );
1050 }
1051
1052 /* get a user pref parameter in the registry */
1053 static BOOL get_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param )
1054 {
1055     union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1056     BYTE prefs[8];
1057
1058     if (!ptr_param) return FALSE;
1059
1060     if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs )) return FALSE;
1061     *(BOOL *)ptr_param = (prefs[entry->pref.offset] & entry->pref.mask) != 0;
1062     return TRUE;
1063 }
1064
1065 /* set a user pref parameter in the registry */
1066 static BOOL set_userpref_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
1067 {
1068     union sysparam_all_entry *parent_entry = (union sysparam_all_entry *)entry->pref.parent;
1069     BYTE prefs[8];
1070
1071     parent_entry->hdr.loaded = FALSE;  /* force loading it again */
1072     if (!parent_entry->hdr.get( parent_entry, sizeof(prefs), prefs )) return FALSE;
1073
1074     if (PtrToUlong( ptr_param )) prefs[entry->pref.offset] |= entry->pref.mask;
1075     else prefs[entry->pref.offset] &= ~entry->pref.mask;
1076
1077     return parent_entry->hdr.set( parent_entry, sizeof(prefs), prefs, flags );
1078 }
1079
1080 static BOOL get_entry( void *ptr, UINT int_param, void *ptr_param )
1081 {
1082     union sysparam_all_entry *entry = ptr;
1083     return entry->hdr.get( entry, int_param, ptr_param );
1084 }
1085
1086 static BOOL set_entry( void *ptr, UINT int_param, void *ptr_param, UINT flags )
1087 {
1088     union sysparam_all_entry *entry = ptr;
1089     return entry->hdr.set( entry, int_param, ptr_param, flags );
1090 }
1091
1092 #define UINT_ENTRY(name,val) \
1093     struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1094                                                   name ##_VALNAME }, (val) }
1095
1096 #define UINT_ENTRY_MIRROR(name,val) \
1097     struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_uint_entry, init_uint_entry, \
1098                                                   name ##_VALNAME, name ##_MIRROR }, (val) }
1099
1100 #define INT_ENTRY(name,val) \
1101     struct sysparam_uint_entry entry_##name = { { get_uint_entry, set_int_entry, init_int_entry, \
1102                                                   name ##_VALNAME }, (val) }
1103
1104 #define BOOL_ENTRY(name,val) \
1105     struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1106                                                   name ##_VALNAME }, (val) }
1107
1108 #define BOOL_ENTRY_MIRROR(name,val) \
1109     struct sysparam_bool_entry entry_##name = { { get_bool_entry, set_bool_entry, init_bool_entry, \
1110                                                   name ##_VALNAME, name ##_MIRROR }, (val) }
1111
1112 #define YESNO_ENTRY(name,val) \
1113     struct sysparam_bool_entry entry_##name = { { get_yesno_entry, set_yesno_entry, init_yesno_entry, \
1114                                                   name ##_VALNAME }, (val) }
1115
1116 #define TWIPS_ENTRY(name,val) \
1117     struct sysparam_uint_entry entry_##name = { { get_twips_entry, set_int_entry, init_int_entry, \
1118                                                   name ##_VALNAME }, (val) }
1119
1120 #define DWORD_ENTRY(name,val) \
1121     struct sysparam_dword_entry entry_##name = { { get_dword_entry, set_dword_entry, init_dword_entry, \
1122                                                    name ##_VALNAME }, (val) }
1123
1124 #define BINARY_ENTRY(name,data) \
1125     struct sysparam_binary_entry entry_##name = { { get_binary_entry, set_binary_entry, init_binary_entry, \
1126                                                     name ##_VALNAME }, data, sizeof(data) }
1127
1128 #define PATH_ENTRY(name) \
1129     struct sysparam_path_entry entry_##name = { { get_path_entry, set_path_entry, init_path_entry, \
1130                                                   name ##_VALNAME } }
1131
1132 #define FONT_ENTRY(name,weight) \
1133     struct sysparam_font_entry entry_##name = { { get_font_entry, set_font_entry, init_font_entry, \
1134                                                   name ##_VALNAME }, (weight) }
1135
1136 #define USERPREF_ENTRY(name,offset,mask) \
1137     struct sysparam_pref_entry entry_##name = { { get_userpref_entry, set_userpref_entry }, \
1138                                                 &entry_USERPREFERENCESMASK, (offset), (mask) }
1139
1140 static UINT_ENTRY( DRAGWIDTH, 4 );
1141 static UINT_ENTRY( DRAGHEIGHT, 4 );
1142 static UINT_ENTRY( DOUBLECLICKTIME, 500 );
1143 static UINT_ENTRY( FONTSMOOTHING, 2 );
1144 static UINT_ENTRY( GRIDGRANULARITY, 0 );
1145 static UINT_ENTRY( ICONSIZE, 32 );
1146 static UINT_ENTRY( KEYBOARDDELAY, 1 );
1147 static UINT_ENTRY( KEYBOARDSPEED, 31 );
1148 static UINT_ENTRY( MENUSHOWDELAY, 400 );
1149 static UINT_ENTRY( MINARRANGE, ARW_HIDE );
1150 static UINT_ENTRY( MINHORZGAP, 0 );
1151 static UINT_ENTRY( MINVERTGAP, 0 );
1152 static UINT_ENTRY( MINWIDTH, 154 );
1153 static UINT_ENTRY( MOUSEHOVERHEIGHT, 4 );
1154 static UINT_ENTRY( MOUSEHOVERTIME, 400 );
1155 static UINT_ENTRY( MOUSEHOVERWIDTH, 4 );
1156 static UINT_ENTRY( MOUSESPEED, 10 );
1157 static UINT_ENTRY( MOUSETRAILS, 0 );
1158 static UINT_ENTRY( SCREENSAVETIMEOUT, 300 );
1159 static UINT_ENTRY( WHEELSCROLLCHARS, 3 );
1160 static UINT_ENTRY( WHEELSCROLLLINES, 3 );
1161 static UINT_ENTRY_MIRROR( DOUBLECLKHEIGHT, 4 );
1162 static UINT_ENTRY_MIRROR( DOUBLECLKWIDTH, 4 );
1163 static UINT_ENTRY_MIRROR( MENUDROPALIGNMENT, 0 );
1164
1165 static INT_ENTRY( MOUSETHRESHOLD1, 6 );
1166 static INT_ENTRY( MOUSETHRESHOLD2, 10 );
1167 static INT_ENTRY( MOUSEACCELERATION, 1 );
1168
1169 static BOOL_ENTRY( BLOCKSENDINPUTRESETS, FALSE );
1170 static BOOL_ENTRY( DRAGFULLWINDOWS, FALSE );
1171 static BOOL_ENTRY( KEYBOARDPREF, TRUE );
1172 static BOOL_ENTRY( LOWPOWERACTIVE, FALSE );
1173 static BOOL_ENTRY( MOUSEBUTTONSWAP, FALSE );
1174 static BOOL_ENTRY( POWEROFFACTIVE, FALSE );
1175 static BOOL_ENTRY( SCREENREADER, FALSE );
1176 static BOOL_ENTRY( SCREENSAVEACTIVE, TRUE );
1177 static BOOL_ENTRY( SCREENSAVERRUNNING, FALSE );
1178 static BOOL_ENTRY( SHOWSOUNDS, FALSE );
1179 static BOOL_ENTRY( SNAPTODEFBUTTON, FALSE );
1180 static BOOL_ENTRY_MIRROR( ICONTITLEWRAP, TRUE );
1181
1182 static YESNO_ENTRY( BEEP, TRUE );
1183
1184 static TWIPS_ENTRY( BORDER, 1 );
1185 static TWIPS_ENTRY( CAPTIONHEIGHT, 18 );
1186 static TWIPS_ENTRY( CAPTIONWIDTH, 18 );
1187 static TWIPS_ENTRY( ICONHORIZONTALSPACING, 75 );
1188 static TWIPS_ENTRY( ICONVERTICALSPACING, 75 );
1189 static TWIPS_ENTRY( MENUHEIGHT, 18 );
1190 static TWIPS_ENTRY( MENUWIDTH, 18 );
1191 static TWIPS_ENTRY( PADDEDBORDERWIDTH, 0 );
1192 static TWIPS_ENTRY( SCROLLHEIGHT, 16 );
1193 static TWIPS_ENTRY( SCROLLWIDTH, 16 );
1194 static TWIPS_ENTRY( SMCAPTIONHEIGHT, 15 );
1195 static TWIPS_ENTRY( SMCAPTIONWIDTH, 13 );
1196
1197 static DWORD_ENTRY( ACTIVEWINDOWTRACKING, 0 );
1198 static DWORD_ENTRY( ACTIVEWNDTRKTIMEOUT, 0 );
1199 static DWORD_ENTRY( CARETWIDTH, 1 );
1200 static DWORD_ENTRY( FOCUSBORDERHEIGHT, 1 );
1201 static DWORD_ENTRY( FOCUSBORDERWIDTH, 1 );
1202 static DWORD_ENTRY( FONTSMOOTHINGCONTRAST, 0 );
1203 static DWORD_ENTRY( FONTSMOOTHINGORIENTATION, FE_FONTSMOOTHINGORIENTATIONRGB );
1204 static DWORD_ENTRY( FONTSMOOTHINGTYPE, FE_FONTSMOOTHINGSTANDARD );
1205 static DWORD_ENTRY( FOREGROUNDFLASHCOUNT, 3 );
1206 static DWORD_ENTRY( FOREGROUNDLOCKTIMEOUT, 0 );
1207 static DWORD_ENTRY( MOUSECLICKLOCKTIME, 1200 );
1208
1209 static PATH_ENTRY( DESKPATTERN );
1210 static PATH_ENTRY( DESKWALLPAPER );
1211
1212 static BYTE user_prefs[8] = { 0x30, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00 };
1213 static BINARY_ENTRY( USERPREFERENCESMASK, user_prefs );
1214
1215 static FONT_ENTRY( CAPTIONLOGFONT, FW_BOLD );
1216 static FONT_ENTRY( ICONTITLELOGFONT, FW_NORMAL );
1217 static FONT_ENTRY( MENULOGFONT, FW_NORMAL );
1218 static FONT_ENTRY( MESSAGELOGFONT, FW_NORMAL );
1219 static FONT_ENTRY( SMCAPTIONLOGFONT, FW_NORMAL );
1220 static FONT_ENTRY( STATUSLOGFONT, FW_NORMAL );
1221
1222 static USERPREF_ENTRY( MENUANIMATION,            0, 0x02 );
1223 static USERPREF_ENTRY( COMBOBOXANIMATION,        0, 0x04 );
1224 static USERPREF_ENTRY( LISTBOXSMOOTHSCROLLING,   0, 0x08 );
1225 static USERPREF_ENTRY( GRADIENTCAPTIONS,         0, 0x10 );
1226 static USERPREF_ENTRY( KEYBOARDCUES,             0, 0x20 );
1227 static USERPREF_ENTRY( ACTIVEWNDTRKZORDER,       0, 0x40 );
1228 static USERPREF_ENTRY( HOTTRACKING,              0, 0x80 );
1229 static USERPREF_ENTRY( MENUFADE,                 1, 0x02 );
1230 static USERPREF_ENTRY( SELECTIONFADE,            1, 0x04 );
1231 static USERPREF_ENTRY( TOOLTIPANIMATION,         1, 0x08 );
1232 static USERPREF_ENTRY( TOOLTIPFADE,              1, 0x10 );
1233 static USERPREF_ENTRY( CURSORSHADOW,             1, 0x20 );
1234 static USERPREF_ENTRY( MOUSESONAR,               1, 0x40 );
1235 static USERPREF_ENTRY( MOUSECLICKLOCK,           1, 0x80 );
1236 static USERPREF_ENTRY( MOUSEVANISH,              2, 0x01 );
1237 static USERPREF_ENTRY( FLATMENU,                 2, 0x02 );
1238 static USERPREF_ENTRY( DROPSHADOW,               2, 0x04 );
1239 static USERPREF_ENTRY( UIEFFECTS,                3, 0x80 );
1240 static USERPREF_ENTRY( DISABLEOVERLAPPEDCONTENT, 4, 0x01 );
1241 static USERPREF_ENTRY( CLIENTAREAANIMATION,      4, 0x02 );
1242 static USERPREF_ENTRY( CLEARTYPE,                4, 0x10 );
1243 static USERPREF_ENTRY( SPEECHRECOGNITION,        4, 0x20 );
1244
1245 static struct sysparam_rgb_entry system_colors[] =
1246 {
1247 #define RGB_ENTRY(name,val) { { get_rgb_entry, set_rgb_entry, init_rgb_entry, name ##_VALNAME }, (val) }
1248     RGB_ENTRY( COLOR_SCROLLBAR, RGB(212, 208, 200) ),
1249     RGB_ENTRY( COLOR_BACKGROUND, RGB(58, 110, 165) ),
1250     RGB_ENTRY( COLOR_ACTIVECAPTION, RGB(10, 36, 106) ),
1251     RGB_ENTRY( COLOR_INACTIVECAPTION, RGB(128, 128, 128) ),
1252     RGB_ENTRY( COLOR_MENU, RGB(212, 208, 200) ),
1253     RGB_ENTRY( COLOR_WINDOW, RGB(255, 255, 255) ),
1254     RGB_ENTRY( COLOR_WINDOWFRAME, RGB(0, 0, 0) ),
1255     RGB_ENTRY( COLOR_MENUTEXT, RGB(0, 0, 0) ),
1256     RGB_ENTRY( COLOR_WINDOWTEXT, RGB(0, 0, 0) ),
1257     RGB_ENTRY( COLOR_CAPTIONTEXT, RGB(255, 255, 255) ),
1258     RGB_ENTRY( COLOR_ACTIVEBORDER, RGB(212, 208, 200) ),
1259     RGB_ENTRY( COLOR_INACTIVEBORDER, RGB(212, 208, 200) ),
1260     RGB_ENTRY( COLOR_APPWORKSPACE, RGB(128, 128, 128) ),
1261     RGB_ENTRY( COLOR_HIGHLIGHT, RGB(10, 36, 106) ),
1262     RGB_ENTRY( COLOR_HIGHLIGHTTEXT, RGB(255, 255, 255) ),
1263     RGB_ENTRY( COLOR_BTNFACE, RGB(212, 208, 200) ),
1264     RGB_ENTRY( COLOR_BTNSHADOW, RGB(128, 128, 128) ),
1265     RGB_ENTRY( COLOR_GRAYTEXT, RGB(128, 128, 128) ),
1266     RGB_ENTRY( COLOR_BTNTEXT, RGB(0, 0, 0) ),
1267     RGB_ENTRY( COLOR_INACTIVECAPTIONTEXT, RGB(212, 208, 200) ),
1268     RGB_ENTRY( COLOR_BTNHIGHLIGHT, RGB(255, 255, 255) ),
1269     RGB_ENTRY( COLOR_3DDKSHADOW, RGB(64, 64, 64) ),
1270     RGB_ENTRY( COLOR_3DLIGHT, RGB(212, 208, 200) ),
1271     RGB_ENTRY( COLOR_INFOTEXT, RGB(0, 0, 0) ),
1272     RGB_ENTRY( COLOR_INFOBK, RGB(255, 255, 225) ),
1273     RGB_ENTRY( COLOR_ALTERNATEBTNFACE, RGB(181, 181, 181) ),
1274     RGB_ENTRY( COLOR_HOTLIGHT, RGB(0, 0, 200) ),
1275     RGB_ENTRY( COLOR_GRADIENTACTIVECAPTION, RGB(166, 202, 240) ),
1276     RGB_ENTRY( COLOR_GRADIENTINACTIVECAPTION, RGB(192, 192, 192) ),
1277     RGB_ENTRY( COLOR_MENUHILIGHT, RGB(10, 36, 106) ),
1278     RGB_ENTRY( COLOR_MENUBAR, RGB(212, 208, 200) )
1279 #undef RGB_ENTRY
1280 };
1281 #define NUM_SYS_COLORS (sizeof(system_colors) / sizeof(system_colors[0]))
1282
1283 /* entries that are initialized by default in the registry */
1284 static union sysparam_all_entry * const default_entries[] =
1285 {
1286     (union sysparam_all_entry *)&entry_ACTIVEWINDOWTRACKING,
1287     (union sysparam_all_entry *)&entry_ACTIVEWNDTRKTIMEOUT,
1288     (union sysparam_all_entry *)&entry_BEEP,
1289     (union sysparam_all_entry *)&entry_BLOCKSENDINPUTRESETS,
1290     (union sysparam_all_entry *)&entry_BORDER,
1291     (union sysparam_all_entry *)&entry_CAPTIONHEIGHT,
1292     (union sysparam_all_entry *)&entry_CAPTIONWIDTH,
1293     (union sysparam_all_entry *)&entry_CARETWIDTH,
1294     (union sysparam_all_entry *)&entry_DESKWALLPAPER,
1295     (union sysparam_all_entry *)&entry_DOUBLECLICKTIME,
1296     (union sysparam_all_entry *)&entry_DOUBLECLKHEIGHT,
1297     (union sysparam_all_entry *)&entry_DOUBLECLKWIDTH,
1298     (union sysparam_all_entry *)&entry_DRAGFULLWINDOWS,
1299     (union sysparam_all_entry *)&entry_DRAGHEIGHT,
1300     (union sysparam_all_entry *)&entry_DRAGWIDTH,
1301     (union sysparam_all_entry *)&entry_FOCUSBORDERHEIGHT,
1302     (union sysparam_all_entry *)&entry_FOCUSBORDERWIDTH,
1303     (union sysparam_all_entry *)&entry_FONTSMOOTHING,
1304     (union sysparam_all_entry *)&entry_FONTSMOOTHINGCONTRAST,
1305     (union sysparam_all_entry *)&entry_FONTSMOOTHINGORIENTATION,
1306     (union sysparam_all_entry *)&entry_FONTSMOOTHINGTYPE,
1307     (union sysparam_all_entry *)&entry_FOREGROUNDFLASHCOUNT,
1308     (union sysparam_all_entry *)&entry_FOREGROUNDLOCKTIMEOUT,
1309     (union sysparam_all_entry *)&entry_ICONHORIZONTALSPACING,
1310     (union sysparam_all_entry *)&entry_ICONSIZE,
1311     (union sysparam_all_entry *)&entry_ICONTITLEWRAP,
1312     (union sysparam_all_entry *)&entry_ICONVERTICALSPACING,
1313     (union sysparam_all_entry *)&entry_KEYBOARDDELAY,
1314     (union sysparam_all_entry *)&entry_KEYBOARDPREF,
1315     (union sysparam_all_entry *)&entry_KEYBOARDSPEED,
1316     (union sysparam_all_entry *)&entry_LOWPOWERACTIVE,
1317     (union sysparam_all_entry *)&entry_MENUHEIGHT,
1318     (union sysparam_all_entry *)&entry_MENUSHOWDELAY,
1319     (union sysparam_all_entry *)&entry_MENUWIDTH,
1320     (union sysparam_all_entry *)&entry_MOUSEACCELERATION,
1321     (union sysparam_all_entry *)&entry_MOUSEBUTTONSWAP,
1322     (union sysparam_all_entry *)&entry_MOUSECLICKLOCKTIME,
1323     (union sysparam_all_entry *)&entry_MOUSEHOVERHEIGHT,
1324     (union sysparam_all_entry *)&entry_MOUSEHOVERTIME,
1325     (union sysparam_all_entry *)&entry_MOUSEHOVERWIDTH,
1326     (union sysparam_all_entry *)&entry_MOUSESPEED,
1327     (union sysparam_all_entry *)&entry_MOUSETHRESHOLD1,
1328     (union sysparam_all_entry *)&entry_MOUSETHRESHOLD2,
1329     (union sysparam_all_entry *)&entry_PADDEDBORDERWIDTH,
1330     (union sysparam_all_entry *)&entry_SCREENREADER,
1331     (union sysparam_all_entry *)&entry_SCROLLHEIGHT,
1332     (union sysparam_all_entry *)&entry_SCROLLWIDTH,
1333     (union sysparam_all_entry *)&entry_SHOWSOUNDS,
1334     (union sysparam_all_entry *)&entry_SMCAPTIONHEIGHT,
1335     (union sysparam_all_entry *)&entry_SMCAPTIONWIDTH,
1336     (union sysparam_all_entry *)&entry_SNAPTODEFBUTTON,
1337     (union sysparam_all_entry *)&entry_USERPREFERENCESMASK,
1338     (union sysparam_all_entry *)&entry_WHEELSCROLLCHARS,
1339     (union sysparam_all_entry *)&entry_WHEELSCROLLLINES,
1340 };
1341
1342 /***********************************************************************
1343  *           SYSPARAMS_Init
1344  */
1345 void SYSPARAMS_Init(void)
1346 {
1347     HKEY key;
1348     DWORD i, dispos;
1349     HBITMAP h55AABitmap = CreateBitmap( 8, 8, 1, 1, wPattern55AA );
1350
1351     SYSCOLOR_55AABrush = CreatePatternBrush( h55AABitmap );
1352     __wine_make_gdi_object_system( SYSCOLOR_55AABrush, TRUE );
1353     DeleteObject( h55AABitmap );
1354
1355     /* this one must be non-volatile */
1356     if (RegCreateKeyW( HKEY_CURRENT_USER, WINE_CURRENT_USER_REGKEY, &key ))
1357     {
1358         ERR("Can't create wine registry branch\n");
1359         return;
1360     }
1361
1362     /* @@ Wine registry key: HKCU\Software\Wine\Temporary System Parameters */
1363     if (RegCreateKeyExW( key, WINE_CURRENT_USER_REGKEY_TEMP_PARAMS, 0, 0,
1364                          REG_OPTION_VOLATILE, KEY_ALL_ACCESS, 0, &volatile_base_key, &dispos ))
1365         ERR("Can't create non-permanent wine registry branch\n");
1366
1367     RegCloseKey( key );
1368
1369     if (volatile_base_key && dispos == REG_CREATED_NEW_KEY)  /* first process, initialize entries */
1370     {
1371         for (i = 0; i < sizeof(default_entries)/sizeof(default_entries[0]); i++)
1372             default_entries[i]->hdr.init( default_entries[i] );
1373     }
1374 }
1375
1376 static BOOL update_desktop_wallpaper(void)
1377 {
1378     DWORD pid;
1379
1380     if (GetWindowThreadProcessId( GetDesktopWindow(), &pid ) && pid == GetCurrentProcessId())
1381     {
1382         WCHAR wallpaper[MAX_PATH], pattern[256];
1383
1384         entry_DESKWALLPAPER.hdr.loaded = entry_DESKPATTERN.hdr.loaded = FALSE;
1385         if (get_entry( &entry_DESKWALLPAPER, MAX_PATH, wallpaper ) &&
1386             get_entry( &entry_DESKPATTERN, 256, pattern ))
1387             update_wallpaper( wallpaper, pattern );
1388     }
1389     else SendMessageW( GetDesktopWindow(), WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0 );
1390     return TRUE;
1391 }
1392
1393 /***********************************************************************
1394  *              SystemParametersInfoW (USER32.@)
1395  *
1396  *     Each system parameter has flag which shows whether the parameter
1397  * is loaded or not. Parameters, stored directly in SysParametersInfo are
1398  * loaded from registry only when they are requested and the flag is
1399  * "false", after the loading the flag is set to "true". On interprocess
1400  * notification of the parameter change the corresponding parameter flag is
1401  * set to "false". The parameter value will be reloaded when it is requested
1402  * the next time.
1403  *     Parameters, backed by or depend on GetSystemMetrics are processed
1404  * differently. These parameters are always loaded. They are reloaded right
1405  * away on interprocess change notification. We can't do lazy loading because
1406  * we don't want to complicate GetSystemMetrics.
1407  *     Parameters, backed by X settings are read from corresponding setting.
1408  * On the parameter change request the setting is changed. Interprocess change
1409  * notifications are ignored.
1410  *     When parameter value is updated the changed value is stored in permanent
1411  * registry branch if saving is requested. Otherwise it is stored
1412  * in temporary branch
1413  *
1414  * Some SPI values can also be stored as Twips values in the registry,
1415  * don't forget the conversion!
1416  */
1417 BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
1418                                    PVOID pvParam, UINT fWinIni )
1419 {
1420 #define WINE_SPI_FIXME(x) \
1421     case x: \
1422         { \
1423             static BOOL warn = TRUE; \
1424             if (warn) \
1425             { \
1426                 warn = FALSE; \
1427                 FIXME( "Unimplemented action: %u (%s)\n", x, #x ); \
1428             } \
1429         } \
1430         SetLastError( ERROR_INVALID_SPI_VALUE ); \
1431         ret = FALSE; \
1432         break
1433 #define WINE_SPI_WARN(x) \
1434     case x: \
1435         WARN( "Ignored action: %u (%s)\n", x, #x ); \
1436         ret = TRUE; \
1437         break
1438
1439     BOOL ret = USER_Driver->pSystemParametersInfo( uiAction, uiParam, pvParam, fWinIni );
1440     unsigned spi_idx = 0;
1441
1442     if (!ret) switch (uiAction)
1443     {
1444     case SPI_GETBEEP:
1445         ret = get_entry( &entry_BEEP, uiParam, pvParam );
1446         break;
1447     case SPI_SETBEEP:
1448         ret = set_entry( &entry_BEEP, uiParam, pvParam, fWinIni );
1449         break;
1450     case SPI_GETMOUSE:
1451         ret = get_entry( &entry_MOUSETHRESHOLD1, uiParam, (INT *)pvParam ) &&
1452               get_entry( &entry_MOUSETHRESHOLD2, uiParam, (INT *)pvParam + 1 ) &&
1453               get_entry( &entry_MOUSEACCELERATION, uiParam, (INT *)pvParam + 2 );
1454         break;
1455     case SPI_SETMOUSE:
1456         ret = set_entry( &entry_MOUSETHRESHOLD1, ((INT *)pvParam)[0], pvParam, fWinIni ) &&
1457               set_entry( &entry_MOUSETHRESHOLD2, ((INT *)pvParam)[1], pvParam, fWinIni ) &&
1458               set_entry( &entry_MOUSEACCELERATION, ((INT *)pvParam)[2], pvParam, fWinIni );
1459         break;
1460     case SPI_GETBORDER:
1461         ret = get_entry( &entry_BORDER, uiParam, pvParam );
1462         if (*(INT*)pvParam < 1) *(INT*)pvParam = 1;
1463         break;
1464     case SPI_SETBORDER:
1465         ret = set_entry( &entry_BORDER, uiParam, pvParam, fWinIni );
1466         break;
1467     case SPI_GETKEYBOARDSPEED:
1468         ret = get_entry( &entry_KEYBOARDSPEED, uiParam, pvParam );
1469         break;
1470     case SPI_SETKEYBOARDSPEED:
1471         if (uiParam > 31) uiParam = 31;
1472         ret = set_entry( &entry_KEYBOARDSPEED, uiParam, pvParam, fWinIni );
1473         break;
1474
1475     /* not implemented in Windows */
1476     WINE_SPI_WARN(SPI_LANGDRIVER);              /*     12 */
1477
1478     case SPI_ICONHORIZONTALSPACING:
1479         if (pvParam != NULL)
1480             ret = get_entry( &entry_ICONHORIZONTALSPACING, uiParam, pvParam );
1481         else
1482             ret = set_entry( &entry_ICONHORIZONTALSPACING, max( 32, uiParam ), pvParam, fWinIni );
1483         break;
1484     case SPI_GETSCREENSAVETIMEOUT:
1485         ret = get_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam );
1486         break;
1487     case SPI_SETSCREENSAVETIMEOUT:
1488         ret = set_entry( &entry_SCREENSAVETIMEOUT, uiParam, pvParam, fWinIni );
1489         break;
1490     case SPI_GETSCREENSAVEACTIVE:
1491         ret = get_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam );
1492         break;
1493     case SPI_SETSCREENSAVEACTIVE:
1494         ret = set_entry( &entry_SCREENSAVEACTIVE, uiParam, pvParam, fWinIni );
1495         break;
1496     case SPI_GETGRIDGRANULARITY:
1497         ret = get_entry( &entry_GRIDGRANULARITY, uiParam, pvParam );
1498         break;
1499     case SPI_SETGRIDGRANULARITY:
1500         ret = set_entry( &entry_GRIDGRANULARITY, uiParam, pvParam, fWinIni );
1501         break;
1502     case SPI_SETDESKWALLPAPER:
1503         if (!pvParam || set_entry( &entry_DESKWALLPAPER, uiParam, pvParam, fWinIni ))
1504             ret = update_desktop_wallpaper();
1505         break;
1506     case SPI_SETDESKPATTERN:
1507         if (!pvParam || set_entry( &entry_DESKPATTERN, uiParam, pvParam, fWinIni ))
1508             ret = update_desktop_wallpaper();
1509         break;
1510     case SPI_GETKEYBOARDDELAY:
1511         ret = get_entry( &entry_KEYBOARDDELAY, uiParam, pvParam );
1512         break;
1513     case SPI_SETKEYBOARDDELAY:
1514         ret = set_entry( &entry_KEYBOARDDELAY, uiParam, pvParam, fWinIni );
1515         break;
1516     case SPI_ICONVERTICALSPACING:
1517         if (pvParam != NULL)
1518             ret = get_entry( &entry_ICONVERTICALSPACING, uiParam, pvParam );
1519         else
1520             ret = set_entry( &entry_ICONVERTICALSPACING, max( 32, uiParam ), pvParam, fWinIni );
1521         break;
1522     case SPI_GETICONTITLEWRAP:
1523         ret = get_entry( &entry_ICONTITLEWRAP, uiParam, pvParam );
1524         break;
1525     case SPI_SETICONTITLEWRAP:
1526         ret = set_entry( &entry_ICONTITLEWRAP, uiParam, pvParam, fWinIni );
1527         break;
1528     case SPI_GETMENUDROPALIGNMENT:
1529         ret = get_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam );
1530         break;
1531     case SPI_SETMENUDROPALIGNMENT:
1532         ret = set_entry( &entry_MENUDROPALIGNMENT, uiParam, pvParam, fWinIni );
1533         break;
1534     case SPI_SETDOUBLECLKWIDTH:
1535         ret = set_entry( &entry_DOUBLECLKWIDTH, uiParam, pvParam, fWinIni );
1536         break;
1537     case SPI_SETDOUBLECLKHEIGHT:
1538         ret = set_entry( &entry_DOUBLECLKHEIGHT, uiParam, pvParam, fWinIni );
1539         break;
1540     case SPI_GETICONTITLELOGFONT:
1541         ret = get_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam );
1542         break;
1543     case SPI_SETDOUBLECLICKTIME:
1544         ret = set_entry( &entry_DOUBLECLICKTIME, uiParam, pvParam, fWinIni );
1545         break;
1546     case SPI_SETMOUSEBUTTONSWAP:
1547         ret = set_entry( &entry_MOUSEBUTTONSWAP, uiParam, pvParam, fWinIni );
1548         break;
1549     case SPI_SETICONTITLELOGFONT:
1550         ret = set_entry( &entry_ICONTITLELOGFONT, uiParam, pvParam, fWinIni );
1551         break;
1552
1553     case SPI_GETFASTTASKSWITCH:                 /*     35 */
1554         if (!pvParam) return FALSE;
1555         *(BOOL *)pvParam = 1;
1556         ret = TRUE;
1557         break;
1558
1559     case SPI_SETFASTTASKSWITCH:                 /*     36 */
1560         /* the action is disabled */
1561         ret = FALSE;
1562         break;
1563
1564     case SPI_SETDRAGFULLWINDOWS:
1565         ret = set_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam, fWinIni );
1566         break;
1567     case SPI_GETDRAGFULLWINDOWS:
1568         ret = get_entry( &entry_DRAGFULLWINDOWS, uiParam, pvParam );
1569         break;
1570     case SPI_GETNONCLIENTMETRICS:
1571     {
1572         LPNONCLIENTMETRICSW lpnm = pvParam;
1573
1574         if (!pvParam) return FALSE;
1575
1576         ret = get_entry( &entry_BORDER, 0, &lpnm->iBorderWidth ) &&
1577               get_entry( &entry_SCROLLWIDTH, 0, &lpnm->iScrollWidth ) &&
1578               get_entry( &entry_SCROLLHEIGHT, 0, &lpnm->iScrollHeight ) &&
1579               get_entry( &entry_CAPTIONWIDTH, 0, &lpnm->iCaptionWidth ) &&
1580               get_entry( &entry_CAPTIONHEIGHT, 0, &lpnm->iCaptionHeight ) &&
1581               get_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont ) &&
1582               get_entry( &entry_SMCAPTIONWIDTH, 0, &lpnm->iSmCaptionWidth ) &&
1583               get_entry( &entry_SMCAPTIONHEIGHT, 0, &lpnm->iSmCaptionHeight ) &&
1584               get_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont ) &&
1585               get_entry( &entry_MENUWIDTH, 0, &lpnm->iMenuWidth ) &&
1586               get_entry( &entry_MENUHEIGHT, 0, &lpnm->iMenuHeight ) &&
1587               get_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont ) &&
1588               get_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont ) &&
1589               get_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont );
1590         if (ret && lpnm->cbSize == sizeof(NONCLIENTMETRICSW))
1591             ret = get_entry( &entry_PADDEDBORDERWIDTH, 0, &lpnm->iPaddedBorderWidth );
1592         normalize_nonclientmetrics( lpnm );
1593         break;
1594     }
1595     case SPI_SETNONCLIENTMETRICS:
1596     {
1597         LPNONCLIENTMETRICSW lpnm = pvParam;
1598
1599         if (lpnm && (lpnm->cbSize == sizeof(NONCLIENTMETRICSW) ||
1600                      lpnm->cbSize == FIELD_OFFSET(NONCLIENTMETRICSW, iPaddedBorderWidth)))
1601         {
1602             ret = set_entry( &entry_BORDER, lpnm->iBorderWidth, NULL, fWinIni ) &&
1603                   set_entry( &entry_SCROLLWIDTH, lpnm->iScrollWidth, NULL, fWinIni ) &&
1604                   set_entry( &entry_SCROLLHEIGHT, lpnm->iScrollHeight, NULL, fWinIni ) &&
1605                   set_entry( &entry_CAPTIONWIDTH, lpnm->iCaptionWidth, NULL, fWinIni ) &&
1606                   set_entry( &entry_CAPTIONHEIGHT, lpnm->iCaptionHeight, NULL, fWinIni ) &&
1607                   set_entry( &entry_SMCAPTIONWIDTH, lpnm->iSmCaptionWidth, NULL, fWinIni ) &&
1608                   set_entry( &entry_SMCAPTIONHEIGHT, lpnm->iSmCaptionHeight, NULL, fWinIni ) &&
1609                   set_entry( &entry_MENUWIDTH, lpnm->iMenuWidth, NULL, fWinIni ) &&
1610                   set_entry( &entry_MENUHEIGHT, lpnm->iMenuHeight, NULL, fWinIni ) &&
1611                   set_entry( &entry_MENULOGFONT, 0, &lpnm->lfMenuFont, fWinIni ) &&
1612                   set_entry( &entry_CAPTIONLOGFONT, 0, &lpnm->lfCaptionFont, fWinIni ) &&
1613                   set_entry( &entry_SMCAPTIONLOGFONT, 0, &lpnm->lfSmCaptionFont, fWinIni ) &&
1614                   set_entry( &entry_STATUSLOGFONT, 0, &lpnm->lfStatusFont, fWinIni ) &&
1615                   set_entry( &entry_MESSAGELOGFONT, 0, &lpnm->lfMessageFont, fWinIni );
1616
1617             if (ret && lpnm->cbSize == sizeof(NONCLIENTMETRICSW))
1618                 set_entry( &entry_PADDEDBORDERWIDTH, lpnm->iPaddedBorderWidth, NULL, fWinIni );
1619         }
1620         break;
1621     }
1622     case SPI_GETMINIMIZEDMETRICS:
1623     {
1624         MINIMIZEDMETRICS * lpMm = pvParam;
1625         if (lpMm && lpMm->cbSize == sizeof(*lpMm)) {
1626             ret = get_entry( &entry_MINWIDTH, 0, &lpMm->iWidth ) &&
1627                   get_entry( &entry_MINHORZGAP, 0, &lpMm->iHorzGap ) &&
1628                   get_entry( &entry_MINVERTGAP, 0, &lpMm->iVertGap ) &&
1629                   get_entry( &entry_MINARRANGE, 0, &lpMm->iArrange );
1630             lpMm->iWidth = max( 0, lpMm->iWidth );
1631             lpMm->iHorzGap = max( 0, lpMm->iHorzGap );
1632             lpMm->iVertGap = max( 0, lpMm->iVertGap );
1633             lpMm->iArrange &= 0x0f;
1634         }
1635         break;
1636     }
1637     case SPI_SETMINIMIZEDMETRICS:
1638     {
1639         MINIMIZEDMETRICS * lpMm = pvParam;
1640         if (lpMm && lpMm->cbSize == sizeof(*lpMm))
1641             ret = set_entry( &entry_MINWIDTH, max( 0, lpMm->iWidth ), NULL, fWinIni ) &&
1642                   set_entry( &entry_MINHORZGAP, max( 0, lpMm->iHorzGap ), NULL, fWinIni ) &&
1643                   set_entry( &entry_MINVERTGAP, max( 0, lpMm->iVertGap ), NULL, fWinIni ) &&
1644                   set_entry( &entry_MINARRANGE, lpMm->iArrange & 0x0f, NULL, fWinIni );
1645         break;
1646     }
1647     case SPI_GETICONMETRICS:
1648     {
1649         LPICONMETRICSW lpIcon = pvParam;
1650         if(lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1651         {
1652             ret = get_entry( &entry_ICONHORIZONTALSPACING, 0, &lpIcon->iHorzSpacing ) &&
1653                   get_entry( &entry_ICONVERTICALSPACING, 0, &lpIcon->iVertSpacing ) &&
1654                   get_entry( &entry_ICONTITLEWRAP, 0, &lpIcon->iTitleWrap ) &&
1655                   get_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont );
1656         }
1657         break;
1658     }
1659     case SPI_SETICONMETRICS:
1660     {
1661         LPICONMETRICSW lpIcon = pvParam;
1662         if (lpIcon && lpIcon->cbSize == sizeof(*lpIcon))
1663             ret = set_entry( &entry_ICONVERTICALSPACING, max(32,lpIcon->iVertSpacing), NULL, fWinIni ) &&
1664                   set_entry( &entry_ICONHORIZONTALSPACING, max(32,lpIcon->iHorzSpacing), NULL, fWinIni ) &&
1665                   set_entry( &entry_ICONTITLEWRAP, lpIcon->iTitleWrap, NULL, fWinIni ) &&
1666                   set_entry( &entry_ICONTITLELOGFONT, 0, &lpIcon->lfFont, fWinIni );
1667         break;
1668     }
1669
1670     case SPI_SETWORKAREA:                       /*     47  WINVER >= 0x400 */
1671     {
1672         if (!pvParam) return FALSE;
1673
1674         spi_idx = SPI_SETWORKAREA_IDX;
1675         CopyRect( &work_area, pvParam );
1676         spi_loaded[spi_idx] = TRUE;
1677         ret = TRUE;
1678         break;
1679     }
1680
1681     case SPI_GETWORKAREA:                       /*     48  WINVER >= 0x400 */
1682     {
1683         if (!pvParam) return FALSE;
1684
1685         spi_idx = SPI_SETWORKAREA_IDX;
1686         if (!spi_loaded[spi_idx])
1687         {
1688             SetRect( &work_area, 0, 0,
1689                      GetSystemMetrics( SM_CXSCREEN ),
1690                      GetSystemMetrics( SM_CYSCREEN ) );
1691             EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area );
1692             spi_loaded[spi_idx] = TRUE;
1693         }
1694         CopyRect( pvParam, &work_area );
1695         ret = TRUE;
1696         TRACE("work area %s\n", wine_dbgstr_rect( &work_area ));
1697         break;
1698     }
1699
1700     WINE_SPI_FIXME(SPI_SETPENWINDOWS);          /*     49  WINVER >= 0x400 */
1701
1702     case SPI_GETFILTERKEYS:                     /*     50 */
1703     {
1704         LPFILTERKEYS lpFilterKeys = pvParam;
1705         WARN("SPI_GETFILTERKEYS not fully implemented\n");
1706         if (lpFilterKeys && lpFilterKeys->cbSize == sizeof(FILTERKEYS))
1707         {
1708             /* Indicate that no FilterKeys feature available */
1709             lpFilterKeys->dwFlags = 0;
1710             lpFilterKeys->iWaitMSec = 0;
1711             lpFilterKeys->iDelayMSec = 0;
1712             lpFilterKeys->iRepeatMSec = 0;
1713             lpFilterKeys->iBounceMSec = 0;
1714             ret = TRUE;
1715         }
1716         break;
1717     }
1718     WINE_SPI_FIXME(SPI_SETFILTERKEYS);          /*     51 */
1719
1720     case SPI_GETTOGGLEKEYS:                     /*     52 */
1721     {
1722         LPTOGGLEKEYS lpToggleKeys = pvParam;
1723         WARN("SPI_GETTOGGLEKEYS not fully implemented\n");
1724         if (lpToggleKeys && lpToggleKeys->cbSize == sizeof(TOGGLEKEYS))
1725         {
1726             /* Indicate that no ToggleKeys feature available */
1727             lpToggleKeys->dwFlags = 0;
1728             ret = TRUE;
1729         }
1730         break;
1731     }
1732     WINE_SPI_FIXME(SPI_SETTOGGLEKEYS);          /*     53 */
1733
1734     case SPI_GETMOUSEKEYS:                      /*     54 */
1735     {
1736         LPMOUSEKEYS lpMouseKeys = pvParam;
1737         WARN("SPI_GETMOUSEKEYS not fully implemented\n");
1738         if (lpMouseKeys && lpMouseKeys->cbSize == sizeof(MOUSEKEYS))
1739         {
1740             /* Indicate that no MouseKeys feature available */
1741             lpMouseKeys->dwFlags = 0;
1742             lpMouseKeys->iMaxSpeed = 360;
1743             lpMouseKeys->iTimeToMaxSpeed = 1000;
1744             lpMouseKeys->iCtrlSpeed = 0;
1745             lpMouseKeys->dwReserved1 = 0;
1746             lpMouseKeys->dwReserved2 = 0;
1747             ret = TRUE;
1748         }
1749         break;
1750     }
1751     WINE_SPI_FIXME(SPI_SETMOUSEKEYS);           /*     55 */
1752
1753     case SPI_GETSHOWSOUNDS:
1754         ret = get_entry( &entry_SHOWSOUNDS, uiParam, pvParam );
1755         break;
1756     case SPI_SETSHOWSOUNDS:
1757         ret = set_entry( &entry_SHOWSOUNDS, uiParam, pvParam, fWinIni );
1758         break;
1759
1760     case SPI_GETSTICKYKEYS:                     /*     58 */
1761     {
1762         LPSTICKYKEYS lpStickyKeys = pvParam;
1763         WARN("SPI_GETSTICKYKEYS not fully implemented\n");
1764         if (lpStickyKeys && lpStickyKeys->cbSize == sizeof(STICKYKEYS))
1765         {
1766             /* Indicate that no StickyKeys feature available */
1767             lpStickyKeys->dwFlags = 0;
1768             ret = TRUE;
1769         }
1770         break;
1771     }
1772     WINE_SPI_FIXME(SPI_SETSTICKYKEYS);          /*     59 */
1773
1774     case SPI_GETACCESSTIMEOUT:                  /*     60 */
1775     {
1776         LPACCESSTIMEOUT lpAccessTimeout = pvParam;
1777         WARN("SPI_GETACCESSTIMEOUT not fully implemented\n");
1778         if (lpAccessTimeout && lpAccessTimeout->cbSize == sizeof(ACCESSTIMEOUT))
1779         {
1780             /* Indicate that no accessibility features timeout is available */
1781             lpAccessTimeout->dwFlags = 0;
1782             lpAccessTimeout->iTimeOutMSec = 0;
1783             ret = TRUE;
1784         }
1785         break;
1786     }
1787     WINE_SPI_FIXME(SPI_SETACCESSTIMEOUT);       /*     61 */
1788
1789     case SPI_GETSERIALKEYS:                     /*     62  WINVER >= 0x400 */
1790     {
1791         LPSERIALKEYSW lpSerialKeysW = pvParam;
1792         WARN("SPI_GETSERIALKEYS not fully implemented\n");
1793         if (lpSerialKeysW && lpSerialKeysW->cbSize == sizeof(SERIALKEYSW))
1794         {
1795             /* Indicate that no SerialKeys feature available */
1796             lpSerialKeysW->dwFlags = 0;
1797             lpSerialKeysW->lpszActivePort = NULL;
1798             lpSerialKeysW->lpszPort = NULL;
1799             lpSerialKeysW->iBaudRate = 0;
1800             lpSerialKeysW->iPortState = 0;
1801             ret = TRUE;
1802         }
1803         break;
1804     }
1805     WINE_SPI_FIXME(SPI_SETSERIALKEYS);          /*     63  WINVER >= 0x400 */
1806
1807     case SPI_GETSOUNDSENTRY:                    /*     64 */
1808     {
1809         LPSOUNDSENTRYW lpSoundSentryW = pvParam;
1810         WARN("SPI_GETSOUNDSENTRY not fully implemented\n");
1811         if (lpSoundSentryW && lpSoundSentryW->cbSize == sizeof(SOUNDSENTRYW))
1812         {
1813             /* Indicate that no SoundSentry feature available */
1814             lpSoundSentryW->dwFlags = 0;
1815             lpSoundSentryW->iFSTextEffect = 0;
1816             lpSoundSentryW->iFSTextEffectMSec = 0;
1817             lpSoundSentryW->iFSTextEffectColorBits = 0;
1818             lpSoundSentryW->iFSGrafEffect = 0;
1819             lpSoundSentryW->iFSGrafEffectMSec = 0;
1820             lpSoundSentryW->iFSGrafEffectColor = 0;
1821             lpSoundSentryW->iWindowsEffect = 0;
1822             lpSoundSentryW->iWindowsEffectMSec = 0;
1823             lpSoundSentryW->lpszWindowsEffectDLL = 0;
1824             lpSoundSentryW->iWindowsEffectOrdinal = 0;
1825             ret = TRUE;
1826         }
1827         break;
1828     }
1829     WINE_SPI_FIXME(SPI_SETSOUNDSENTRY);         /*     65 */
1830
1831     case SPI_GETHIGHCONTRAST:                   /*     66  WINVER >= 0x400 */
1832     {
1833         LPHIGHCONTRASTW lpHighContrastW = pvParam;
1834         WARN("SPI_GETHIGHCONTRAST not fully implemented\n");
1835         if (lpHighContrastW && lpHighContrastW->cbSize == sizeof(HIGHCONTRASTW))
1836         {
1837             /* Indicate that no high contrast feature available */
1838             lpHighContrastW->dwFlags = 0;
1839             lpHighContrastW->lpszDefaultScheme = NULL;
1840             ret = TRUE;
1841         }
1842         break;
1843     }
1844     WINE_SPI_FIXME(SPI_SETHIGHCONTRAST);        /*     67  WINVER >= 0x400 */
1845
1846     case SPI_GETKEYBOARDPREF:
1847         ret = get_entry( &entry_KEYBOARDPREF, uiParam, pvParam );
1848         break;
1849     case SPI_SETKEYBOARDPREF:
1850         ret = set_entry( &entry_KEYBOARDPREF, uiParam, pvParam, fWinIni );
1851         break;
1852     case SPI_GETSCREENREADER:
1853         ret = get_entry( &entry_SCREENREADER, uiParam, pvParam );
1854         break;
1855     case SPI_SETSCREENREADER:
1856         ret = set_entry( &entry_SCREENREADER, uiParam, pvParam, fWinIni );
1857         break;
1858
1859     case SPI_GETANIMATION:                      /*     72  WINVER >= 0x400 */
1860     {
1861         LPANIMATIONINFO lpAnimInfo = pvParam;
1862
1863         /* Tell it "disabled" */
1864         if (lpAnimInfo && lpAnimInfo->cbSize == sizeof(ANIMATIONINFO))
1865         {
1866             lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
1867             ret = TRUE;
1868         }
1869         break;
1870     }
1871     WINE_SPI_WARN(SPI_SETANIMATION);            /*     73  WINVER >= 0x400 */
1872
1873     case SPI_GETFONTSMOOTHING:
1874         ret = get_entry( &entry_FONTSMOOTHING, uiParam, pvParam );
1875         if (ret) *(UINT *)pvParam = (*(UINT *)pvParam != 0);
1876         break;
1877     case SPI_SETFONTSMOOTHING:
1878         uiParam = uiParam ? 2 : 0; /* Win NT4/2k/XP behavior */
1879         ret = set_entry( &entry_FONTSMOOTHING, uiParam, pvParam, fWinIni );
1880         break;
1881     case SPI_SETDRAGWIDTH:
1882         ret = set_entry( &entry_DRAGWIDTH, uiParam, pvParam, fWinIni );
1883         break;
1884     case SPI_SETDRAGHEIGHT:
1885         ret = set_entry( &entry_DRAGHEIGHT, uiParam, pvParam, fWinIni );
1886         break;
1887
1888     WINE_SPI_FIXME(SPI_SETHANDHELD);            /*     78  WINVER >= 0x400 */
1889
1890     WINE_SPI_FIXME(SPI_GETLOWPOWERTIMEOUT);     /*     79  WINVER >= 0x400 */
1891     WINE_SPI_FIXME(SPI_GETPOWEROFFTIMEOUT);     /*     80  WINVER >= 0x400 */
1892     WINE_SPI_FIXME(SPI_SETLOWPOWERTIMEOUT);     /*     81  WINVER >= 0x400 */
1893     WINE_SPI_FIXME(SPI_SETPOWEROFFTIMEOUT);     /*     82  WINVER >= 0x400 */
1894
1895     case SPI_GETLOWPOWERACTIVE:
1896         ret = get_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam );
1897         break;
1898     case SPI_SETLOWPOWERACTIVE:
1899         ret = set_entry( &entry_LOWPOWERACTIVE, uiParam, pvParam, fWinIni );
1900         break;
1901     case SPI_GETPOWEROFFACTIVE:
1902         ret = get_entry( &entry_POWEROFFACTIVE, uiParam, pvParam );
1903         break;
1904     case SPI_SETPOWEROFFACTIVE:
1905         ret = set_entry( &entry_POWEROFFACTIVE, uiParam, pvParam, fWinIni );
1906         break;
1907
1908     WINE_SPI_FIXME(SPI_SETCURSORS);             /*     87  WINVER >= 0x400 */
1909     WINE_SPI_FIXME(SPI_SETICONS);               /*     88  WINVER >= 0x400 */
1910
1911     case SPI_GETDEFAULTINPUTLANG:       /*     89  WINVER >= 0x400 */
1912         ret = GetKeyboardLayout(0) != 0;
1913         break;
1914
1915     WINE_SPI_FIXME(SPI_SETDEFAULTINPUTLANG);    /*     90  WINVER >= 0x400 */
1916
1917     WINE_SPI_FIXME(SPI_SETLANGTOGGLE);          /*     91  WINVER >= 0x400 */
1918
1919     case SPI_GETWINDOWSEXTENSION:               /*     92  WINVER >= 0x400 */
1920         WARN("pretend no support for Win9x Plus! for now.\n");
1921         ret = FALSE; /* yes, this is the result value */
1922         break;
1923     case SPI_SETMOUSETRAILS:
1924         ret = set_entry( &entry_MOUSETRAILS, uiParam, pvParam, fWinIni );
1925         break;
1926     case SPI_GETMOUSETRAILS:
1927         ret = get_entry( &entry_MOUSETRAILS, uiParam, pvParam );
1928         break;
1929     case SPI_GETSNAPTODEFBUTTON:
1930         ret = get_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam );
1931         break;
1932     case SPI_SETSNAPTODEFBUTTON:
1933         ret = set_entry( &entry_SNAPTODEFBUTTON, uiParam, pvParam, fWinIni );
1934         break;
1935     case SPI_SETSCREENSAVERRUNNING:
1936         ret = set_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam, fWinIni );
1937         break;
1938     case SPI_GETMOUSEHOVERWIDTH:
1939         ret = get_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam );
1940         break;
1941     case SPI_SETMOUSEHOVERWIDTH:
1942         ret = set_entry( &entry_MOUSEHOVERWIDTH, uiParam, pvParam, fWinIni );
1943         break;
1944     case SPI_GETMOUSEHOVERHEIGHT:
1945         ret = get_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam );
1946         break;
1947     case SPI_SETMOUSEHOVERHEIGHT:
1948         ret = set_entry( &entry_MOUSEHOVERHEIGHT, uiParam, pvParam, fWinIni );
1949         break;
1950     case SPI_GETMOUSEHOVERTIME:
1951         ret = get_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam );
1952         break;
1953     case SPI_SETMOUSEHOVERTIME:
1954         ret = set_entry( &entry_MOUSEHOVERTIME, uiParam, pvParam, fWinIni );
1955         break;
1956     case SPI_GETWHEELSCROLLLINES:
1957         ret = get_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam );
1958         break;
1959     case SPI_SETWHEELSCROLLLINES:
1960         ret = set_entry( &entry_WHEELSCROLLLINES, uiParam, pvParam, fWinIni );
1961         break;
1962     case SPI_GETMENUSHOWDELAY:
1963         ret = get_entry( &entry_MENUSHOWDELAY, uiParam, pvParam );
1964         break;
1965     case SPI_SETMENUSHOWDELAY:
1966         ret = set_entry( &entry_MENUSHOWDELAY, uiParam, pvParam, fWinIni );
1967         break;
1968     case SPI_GETWHEELSCROLLCHARS:
1969         ret = get_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam );
1970         break;
1971     case SPI_SETWHEELSCROLLCHARS:
1972         ret = set_entry( &entry_WHEELSCROLLCHARS, uiParam, pvParam, fWinIni );
1973         break;
1974
1975     WINE_SPI_FIXME(SPI_GETSHOWIMEUI);           /*    110  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
1976     WINE_SPI_FIXME(SPI_SETSHOWIMEUI);           /*    111  _WIN32_WINNT >= 0x400 || _WIN32_WINDOW > 0x400 */
1977
1978     case SPI_GETMOUSESPEED:
1979         ret = get_entry( &entry_MOUSESPEED, uiParam, pvParam );
1980         break;
1981     case SPI_SETMOUSESPEED:
1982         ret = set_entry( &entry_MOUSESPEED, uiParam, pvParam, fWinIni );
1983         break;
1984     case SPI_GETSCREENSAVERRUNNING:
1985         ret = get_entry( &entry_SCREENSAVERRUNNING, uiParam, pvParam );
1986         break;
1987     case SPI_GETDESKWALLPAPER:
1988         ret = get_entry( &entry_DESKWALLPAPER, uiParam, pvParam );
1989         break;
1990     case SPI_GETACTIVEWINDOWTRACKING:
1991         ret = get_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam );
1992         break;
1993     case SPI_SETACTIVEWINDOWTRACKING:
1994         ret = set_entry( &entry_ACTIVEWINDOWTRACKING, uiParam, pvParam, fWinIni );
1995         break;
1996     case SPI_GETMENUANIMATION:
1997         ret = get_entry( &entry_MENUANIMATION, uiParam, pvParam );
1998         break;
1999     case SPI_SETMENUANIMATION:
2000         ret = set_entry( &entry_MENUANIMATION, uiParam, pvParam, fWinIni );
2001         break;
2002     case SPI_GETCOMBOBOXANIMATION:
2003         ret = get_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam );
2004         break;
2005     case SPI_SETCOMBOBOXANIMATION:
2006         ret = set_entry( &entry_COMBOBOXANIMATION, uiParam, pvParam, fWinIni );
2007         break;
2008     case SPI_GETLISTBOXSMOOTHSCROLLING:
2009         ret = get_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam );
2010         break;
2011     case SPI_SETLISTBOXSMOOTHSCROLLING:
2012         ret = set_entry( &entry_LISTBOXSMOOTHSCROLLING, uiParam, pvParam, fWinIni );
2013         break;
2014     case SPI_GETGRADIENTCAPTIONS:
2015         ret = get_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam );
2016         break;
2017     case SPI_SETGRADIENTCAPTIONS:
2018         ret = set_entry( &entry_GRADIENTCAPTIONS, uiParam, pvParam, fWinIni );
2019         break;
2020     case SPI_GETKEYBOARDCUES:
2021         ret = get_entry( &entry_KEYBOARDCUES, uiParam, pvParam );
2022         break;
2023     case SPI_SETKEYBOARDCUES:
2024         ret = set_entry( &entry_KEYBOARDCUES, uiParam, pvParam, fWinIni );
2025         break;
2026     case SPI_GETACTIVEWNDTRKZORDER:
2027         ret = get_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam );
2028         break;
2029     case SPI_SETACTIVEWNDTRKZORDER:
2030         ret = set_entry( &entry_ACTIVEWNDTRKZORDER, uiParam, pvParam, fWinIni );
2031         break;
2032     case SPI_GETHOTTRACKING:
2033         ret = get_entry( &entry_HOTTRACKING, uiParam, pvParam );
2034         break;
2035     case SPI_SETHOTTRACKING:
2036         ret = set_entry( &entry_HOTTRACKING, uiParam, pvParam, fWinIni );
2037         break;
2038     case SPI_GETMENUFADE:
2039         ret = get_entry( &entry_MENUFADE, uiParam, pvParam );
2040         break;
2041     case SPI_SETMENUFADE:
2042         ret = set_entry( &entry_MENUFADE, uiParam, pvParam, fWinIni );
2043         break;
2044     case SPI_GETSELECTIONFADE:
2045         ret = get_entry( &entry_SELECTIONFADE, uiParam, pvParam );
2046         break;
2047     case SPI_SETSELECTIONFADE:
2048         ret = set_entry( &entry_SELECTIONFADE, uiParam, pvParam, fWinIni );
2049         break;
2050     case SPI_GETTOOLTIPANIMATION:
2051         ret = get_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam );
2052         break;
2053     case SPI_SETTOOLTIPANIMATION:
2054         ret = set_entry( &entry_TOOLTIPANIMATION, uiParam, pvParam, fWinIni );
2055         break;
2056     case SPI_GETTOOLTIPFADE:
2057         ret = get_entry( &entry_TOOLTIPFADE, uiParam, pvParam );
2058         break;
2059     case SPI_SETTOOLTIPFADE:
2060         ret = set_entry( &entry_TOOLTIPFADE, uiParam, pvParam, fWinIni );
2061         break;
2062     case SPI_GETCURSORSHADOW:
2063         ret = get_entry( &entry_CURSORSHADOW, uiParam, pvParam );
2064         break;
2065     case SPI_SETCURSORSHADOW:
2066         ret = set_entry( &entry_CURSORSHADOW, uiParam, pvParam, fWinIni );
2067         break;
2068     case SPI_GETMOUSESONAR:
2069         ret = get_entry( &entry_MOUSESONAR, uiParam, pvParam );
2070         break;
2071     case SPI_SETMOUSESONAR:
2072         ret = set_entry( &entry_MOUSESONAR, uiParam, pvParam, fWinIni );
2073         break;
2074     case SPI_GETMOUSECLICKLOCK:
2075         ret = get_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam );
2076         break;
2077     case SPI_SETMOUSECLICKLOCK:
2078         ret = set_entry( &entry_MOUSECLICKLOCK, uiParam, pvParam, fWinIni );
2079         break;
2080     case SPI_GETMOUSEVANISH:
2081         ret = get_entry( &entry_MOUSEVANISH, uiParam, pvParam );
2082         break;
2083     case SPI_SETMOUSEVANISH:
2084         ret = set_entry( &entry_MOUSEVANISH, uiParam, pvParam, fWinIni );
2085         break;
2086     case SPI_GETFLATMENU:
2087         ret = get_entry( &entry_FLATMENU, uiParam, pvParam );
2088         break;
2089     case SPI_SETFLATMENU:
2090         ret = set_entry( &entry_FLATMENU, uiParam, pvParam, fWinIni );
2091         break;
2092     case SPI_GETDROPSHADOW:
2093         ret = get_entry( &entry_DROPSHADOW, uiParam, pvParam );
2094         break;
2095     case SPI_SETDROPSHADOW:
2096         ret = set_entry( &entry_DROPSHADOW, uiParam, pvParam, fWinIni );
2097         break;
2098     case SPI_GETBLOCKSENDINPUTRESETS:
2099         ret = get_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam );
2100         break;
2101     case SPI_SETBLOCKSENDINPUTRESETS:
2102         ret = set_entry( &entry_BLOCKSENDINPUTRESETS, uiParam, pvParam, fWinIni );
2103         break;
2104     case SPI_GETUIEFFECTS:
2105         ret = get_entry( &entry_UIEFFECTS, uiParam, pvParam );
2106         break;
2107     case SPI_SETUIEFFECTS:
2108         /* FIXME: this probably should mask other UI effect values when unset */
2109         ret = set_entry( &entry_UIEFFECTS, uiParam, pvParam, fWinIni );
2110         break;
2111     case SPI_GETDISABLEOVERLAPPEDCONTENT:
2112         ret = get_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam );
2113         break;
2114     case SPI_SETDISABLEOVERLAPPEDCONTENT:
2115         ret = set_entry( &entry_DISABLEOVERLAPPEDCONTENT, uiParam, pvParam, fWinIni );
2116         break;
2117     case SPI_GETCLIENTAREAANIMATION:
2118         ret = get_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam );
2119         break;
2120     case SPI_SETCLIENTAREAANIMATION:
2121         ret = set_entry( &entry_CLIENTAREAANIMATION, uiParam, pvParam, fWinIni );
2122         break;
2123     case SPI_GETCLEARTYPE:
2124         ret = get_entry( &entry_CLEARTYPE, uiParam, pvParam );
2125         break;
2126     case SPI_SETCLEARTYPE:
2127         ret = set_entry( &entry_CLEARTYPE, uiParam, pvParam, fWinIni );
2128         break;
2129     case SPI_GETSPEECHRECOGNITION:
2130         ret = get_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam );
2131         break;
2132     case SPI_SETSPEECHRECOGNITION:
2133         ret = set_entry( &entry_SPEECHRECOGNITION, uiParam, pvParam, fWinIni );
2134         break;
2135     case SPI_GETFOREGROUNDLOCKTIMEOUT:
2136         ret = get_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam );
2137         break;
2138     case SPI_SETFOREGROUNDLOCKTIMEOUT:
2139         /* FIXME: this should check that the calling thread
2140          * is able to change the foreground window */
2141         ret = set_entry( &entry_FOREGROUNDLOCKTIMEOUT, uiParam, pvParam, fWinIni );
2142         break;
2143     case SPI_GETACTIVEWNDTRKTIMEOUT:
2144         ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2145         break;
2146     case SPI_SETACTIVEWNDTRKTIMEOUT:
2147         ret = get_entry( &entry_ACTIVEWNDTRKTIMEOUT, uiParam, pvParam );
2148         break;
2149     case SPI_GETFOREGROUNDFLASHCOUNT:
2150         ret = get_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam );
2151         break;
2152     case SPI_SETFOREGROUNDFLASHCOUNT:
2153         ret = set_entry( &entry_FOREGROUNDFLASHCOUNT, uiParam, pvParam, fWinIni );
2154         break;
2155     case SPI_GETCARETWIDTH:
2156         ret = get_entry( &entry_CARETWIDTH, uiParam, pvParam );
2157         break;
2158     case SPI_SETCARETWIDTH:
2159         ret = set_entry( &entry_CARETWIDTH, uiParam, pvParam, fWinIni );
2160         break;
2161     case SPI_GETMOUSECLICKLOCKTIME:
2162         ret = get_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam );
2163         break;
2164     case SPI_SETMOUSECLICKLOCKTIME:
2165         ret = set_entry( &entry_MOUSECLICKLOCKTIME, uiParam, pvParam, fWinIni );
2166         break;
2167     case SPI_GETFONTSMOOTHINGTYPE:
2168         ret = get_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam );
2169         break;
2170     case SPI_SETFONTSMOOTHINGTYPE:
2171         ret = set_entry( &entry_FONTSMOOTHINGTYPE, uiParam, pvParam, fWinIni );
2172         break;
2173     case SPI_GETFONTSMOOTHINGCONTRAST:
2174         ret = get_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam );
2175         break;
2176     case SPI_SETFONTSMOOTHINGCONTRAST:
2177         ret = set_entry( &entry_FONTSMOOTHINGCONTRAST, uiParam, pvParam, fWinIni );
2178         break;
2179     case SPI_GETFOCUSBORDERWIDTH:
2180         ret = get_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam );
2181         break;
2182     case SPI_GETFOCUSBORDERHEIGHT:
2183         ret = get_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam );
2184         break;
2185     case SPI_SETFOCUSBORDERWIDTH:
2186         ret = set_entry( &entry_FOCUSBORDERWIDTH, uiParam, pvParam, fWinIni );
2187         break;
2188     case SPI_SETFOCUSBORDERHEIGHT:
2189         ret = set_entry( &entry_FOCUSBORDERHEIGHT, uiParam, pvParam, fWinIni );
2190         break;
2191     case SPI_GETFONTSMOOTHINGORIENTATION:
2192         ret = get_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam );
2193         break;
2194     case SPI_SETFONTSMOOTHINGORIENTATION:
2195         ret = set_entry( &entry_FONTSMOOTHINGORIENTATION, uiParam, pvParam, fWinIni );
2196         break;
2197
2198     default:
2199         FIXME( "Unknown action: %u\n", uiAction );
2200         SetLastError( ERROR_INVALID_SPI_VALUE );
2201         ret = FALSE;
2202         break;
2203     }
2204
2205     if (ret)
2206         SYSPARAMS_NotifyChange( uiAction, fWinIni );
2207     TRACE("(%u, %u, %p, %u) ret %d\n",
2208             uiAction, uiParam, pvParam, fWinIni, ret);
2209     return ret;
2210
2211 #undef WINE_SPI_FIXME
2212 #undef WINE_SPI_WARN
2213 }
2214
2215
2216 /***********************************************************************
2217  *              SystemParametersInfoA (USER32.@)
2218  */
2219 BOOL WINAPI SystemParametersInfoA( UINT uiAction, UINT uiParam,
2220                                    PVOID pvParam, UINT fuWinIni )
2221 {
2222     BOOL ret;
2223
2224     TRACE("(%u, %u, %p, %u)\n", uiAction, uiParam, pvParam, fuWinIni);
2225
2226     switch (uiAction)
2227     {
2228     case SPI_SETDESKWALLPAPER:                  /*     20 */
2229     case SPI_SETDESKPATTERN:                    /*     21 */
2230     {
2231         WCHAR buffer[256];
2232         if (pvParam)
2233             if (!MultiByteToWideChar( CP_ACP, 0, pvParam, -1, buffer,
2234                                       sizeof(buffer)/sizeof(WCHAR) ))
2235                 buffer[sizeof(buffer)/sizeof(WCHAR)-1] = 0;
2236         ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? buffer : NULL, fuWinIni );
2237         break;
2238     }
2239
2240     case SPI_GETICONTITLELOGFONT:               /*     31 */
2241     {
2242         LOGFONTW tmp;
2243         ret = SystemParametersInfoW( uiAction, uiParam, pvParam ? &tmp : NULL, fuWinIni );
2244         if (ret && pvParam)
2245             SYSPARAMS_LogFont32WTo32A( &tmp, pvParam );
2246         break;
2247     }
2248
2249     case SPI_GETNONCLIENTMETRICS:               /*     41  WINVER >= 0x400 */
2250     {
2251         NONCLIENTMETRICSW tmp;
2252         LPNONCLIENTMETRICSA lpnmA = pvParam;
2253         if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2254                       lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2255         {
2256             tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2257             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2258             if (ret)
2259                 SYSPARAMS_NonClientMetrics32WTo32A( &tmp, lpnmA );
2260         }
2261         else
2262             ret = FALSE;
2263         break;
2264     }
2265
2266     case SPI_SETNONCLIENTMETRICS:               /*     42  WINVER >= 0x400 */
2267     {
2268         NONCLIENTMETRICSW tmp;
2269         LPNONCLIENTMETRICSA lpnmA = pvParam;
2270         if (lpnmA && (lpnmA->cbSize == sizeof(NONCLIENTMETRICSA) ||
2271                       lpnmA->cbSize == FIELD_OFFSET(NONCLIENTMETRICSA, iPaddedBorderWidth)))
2272         {
2273             tmp.cbSize = sizeof(NONCLIENTMETRICSW);
2274             SYSPARAMS_NonClientMetrics32ATo32W( lpnmA, &tmp );
2275             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2276         }
2277         else
2278             ret = FALSE;
2279         break;
2280     }
2281
2282     case SPI_GETICONMETRICS:                    /*     45  WINVER >= 0x400 */
2283     {
2284         ICONMETRICSW tmp;
2285         LPICONMETRICSA lpimA = pvParam;
2286         if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2287         {
2288             tmp.cbSize = sizeof(ICONMETRICSW);
2289             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2290             if (ret)
2291             {
2292                 lpimA->iHorzSpacing = tmp.iHorzSpacing;
2293                 lpimA->iVertSpacing = tmp.iVertSpacing;
2294                 lpimA->iTitleWrap   = tmp.iTitleWrap;
2295                 SYSPARAMS_LogFont32WTo32A( &tmp.lfFont, &lpimA->lfFont );
2296             }
2297         }
2298         else
2299             ret = FALSE;
2300         break;
2301     }
2302
2303     case SPI_SETICONMETRICS:                    /*     46  WINVER >= 0x400 */
2304     {
2305         ICONMETRICSW tmp;
2306         LPICONMETRICSA lpimA = pvParam;
2307         if (lpimA && lpimA->cbSize == sizeof(ICONMETRICSA))
2308         {
2309             tmp.cbSize = sizeof(ICONMETRICSW);
2310             tmp.iHorzSpacing = lpimA->iHorzSpacing;
2311             tmp.iVertSpacing = lpimA->iVertSpacing;
2312             tmp.iTitleWrap = lpimA->iTitleWrap;
2313             SYSPARAMS_LogFont32ATo32W(  &lpimA->lfFont, &tmp.lfFont);
2314             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2315         }
2316         else
2317             ret = FALSE;
2318         break;
2319     }
2320
2321     case SPI_GETHIGHCONTRAST:                   /*     66  WINVER >= 0x400 */
2322     {
2323         HIGHCONTRASTW tmp;
2324         LPHIGHCONTRASTA lphcA = pvParam;
2325         if (lphcA && lphcA->cbSize == sizeof(HIGHCONTRASTA))
2326         {
2327             tmp.cbSize = sizeof(HIGHCONTRASTW);
2328             ret = SystemParametersInfoW( uiAction, uiParam, &tmp, fuWinIni );
2329             if (ret)
2330             {
2331                 lphcA->dwFlags = tmp.dwFlags;
2332                 lphcA->lpszDefaultScheme = NULL;  /* FIXME? */
2333             }
2334         }
2335         else
2336             ret = FALSE;
2337         break;
2338     }
2339
2340     case SPI_GETDESKWALLPAPER:                  /*     115 */
2341     {
2342         WCHAR buffer[MAX_PATH];
2343         ret = (SystemParametersInfoW( SPI_GETDESKWALLPAPER, uiParam, buffer, fuWinIni ) &&
2344                WideCharToMultiByte(CP_ACP, 0, buffer, -1, pvParam, uiParam, NULL, NULL));
2345         break;
2346     }
2347
2348     default:
2349         ret = SystemParametersInfoW( uiAction, uiParam, pvParam, fuWinIni );
2350         break;
2351     }
2352     return ret;
2353 }
2354
2355
2356 /***********************************************************************
2357  *              GetSystemMetrics (USER32.@)
2358  */
2359 INT WINAPI GetSystemMetrics( INT index )
2360 {
2361     NONCLIENTMETRICSW ncm;
2362     UINT ret;
2363
2364     /* some metrics are dynamic */
2365     switch (index)
2366     {
2367     case SM_CXSCREEN:
2368         return GetDeviceCaps( get_display_dc(), HORZRES );
2369     case SM_CYSCREEN:
2370         return GetDeviceCaps( get_display_dc(), VERTRES );
2371     case SM_CXVSCROLL:
2372     case SM_CYHSCROLL:
2373         get_entry( &entry_SCROLLWIDTH, 0, &ret );
2374         return max( 8, ret );
2375     case SM_CYCAPTION:
2376         return GetSystemMetrics( SM_CYSIZE ) + 1;
2377     case SM_CXBORDER:
2378     case SM_CYBORDER:
2379         /* SM_C{X,Y}BORDER always returns 1 regardless of 'BorderWidth' value in registry */
2380         return 1;
2381     case SM_CXDLGFRAME:
2382     case SM_CYDLGFRAME:
2383         return 3;
2384     case SM_CYVTHUMB:
2385     case SM_CXHTHUMB:
2386     case SM_CYVSCROLL:
2387     case SM_CXHSCROLL:
2388         get_entry( &entry_SCROLLHEIGHT, 0, &ret );
2389         return max( 8, ret );
2390     case SM_CXICON:
2391     case SM_CYICON:
2392         get_entry( &entry_ICONSIZE, 0, &ret );
2393         return ret;
2394     case SM_CXCURSOR:
2395     case SM_CYCURSOR:
2396         return 32;
2397     case SM_CYMENU:
2398         return GetSystemMetrics(SM_CYMENUSIZE) + 1;
2399     case SM_CXFULLSCREEN:
2400         /* see the remark for SM_CXMAXIMIZED, at least this formulation is
2401          * correct */
2402         return GetSystemMetrics( SM_CXMAXIMIZED) - 2 * GetSystemMetrics( SM_CXFRAME);
2403     case SM_CYFULLSCREEN:
2404         /* see the remark for SM_CYMAXIMIZED, at least this formulation is
2405          * correct */
2406         return GetSystemMetrics( SM_CYMAXIMIZED) - GetSystemMetrics( SM_CYMIN);
2407     case SM_CYKANJIWINDOW:
2408         return 0;
2409     case SM_MOUSEPRESENT:
2410         return 1;
2411     case SM_DEBUG:
2412         return 0;
2413     case SM_SWAPBUTTON:
2414         get_entry( &entry_MOUSEBUTTONSWAP, 0, &ret );
2415         return ret;
2416     case SM_RESERVED1:
2417     case SM_RESERVED2:
2418     case SM_RESERVED3:
2419     case SM_RESERVED4:
2420         return 0;
2421     case SM_CXMIN:
2422         ncm.cbSize = sizeof(ncm);
2423         SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2424         get_text_metr_size( get_display_dc(), &ncm.lfCaptionFont, NULL, &ret );
2425         return 3 * ncm.iCaptionWidth + ncm.iCaptionHeight + 4 * ret + 2 * GetSystemMetrics(SM_CXFRAME) + 4;
2426     case SM_CYMIN:
2427         return GetSystemMetrics( SM_CYCAPTION) + 2 * GetSystemMetrics( SM_CYFRAME);
2428     case SM_CXSIZE:
2429         get_entry( &entry_CAPTIONWIDTH, 0, &ret );
2430         return max( 8, ret );
2431     case SM_CYSIZE:
2432         ncm.cbSize = sizeof(ncm);
2433         SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2434         return ncm.iCaptionHeight;
2435     case SM_CXFRAME:
2436         get_entry( &entry_BORDER, 0, &ret );
2437         return GetSystemMetrics(SM_CXDLGFRAME) + max( 1, ret );
2438     case SM_CYFRAME:
2439         get_entry( &entry_BORDER, 0, &ret );
2440         return GetSystemMetrics(SM_CYDLGFRAME) + max( 1, ret );
2441     case SM_CXMINTRACK:
2442         return GetSystemMetrics(SM_CXMIN);
2443     case SM_CYMINTRACK:
2444         return GetSystemMetrics(SM_CYMIN);
2445     case SM_CXDOUBLECLK:
2446         get_entry( &entry_DOUBLECLKWIDTH, 0, &ret );
2447         return ret;
2448     case SM_CYDOUBLECLK:
2449         get_entry( &entry_DOUBLECLKHEIGHT, 0, &ret );
2450         return ret;
2451     case SM_CXICONSPACING:
2452         get_entry( &entry_ICONHORIZONTALSPACING, 0, &ret );
2453         return ret;
2454     case SM_CYICONSPACING:
2455         get_entry( &entry_ICONVERTICALSPACING, 0, &ret );
2456         return ret;
2457     case SM_MENUDROPALIGNMENT:
2458         get_entry( &entry_MENUDROPALIGNMENT, 0, &ret );
2459         return ret;
2460     case SM_PENWINDOWS:
2461         return 0;
2462     case SM_DBCSENABLED:
2463     {
2464         CPINFO cpinfo;
2465         GetCPInfo( CP_ACP, &cpinfo );
2466         return (cpinfo.MaxCharSize > 1);
2467     }
2468     case SM_CMOUSEBUTTONS:
2469         return 3;
2470     case SM_SECURE:
2471         return 0;
2472     case SM_CXEDGE:
2473         return GetSystemMetrics(SM_CXBORDER) + 1;
2474     case SM_CYEDGE:
2475         return GetSystemMetrics(SM_CYBORDER) + 1;
2476     case SM_CXMINSPACING:
2477         get_entry( &entry_MINHORZGAP, 0, &ret );
2478         return GetSystemMetrics(SM_CXMINIMIZED) + max( 0, (INT)ret );
2479     case SM_CYMINSPACING:
2480         get_entry( &entry_MINVERTGAP, 0, &ret );
2481         return GetSystemMetrics(SM_CYMINIMIZED) + max( 0, (INT)ret );
2482     case SM_CXSMICON:
2483     case SM_CYSMICON:
2484         return 16;
2485     case SM_CYSMCAPTION:
2486         return GetSystemMetrics(SM_CYSMSIZE) + 1;
2487     case SM_CXSMSIZE:
2488         get_entry( &entry_SMCAPTIONWIDTH, 0, &ret );
2489         return ret;
2490     case SM_CYSMSIZE:
2491         ncm.cbSize = sizeof(ncm);
2492         SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2493         return ncm.iSmCaptionHeight;
2494     case SM_CXMENUSIZE:
2495         get_entry( &entry_MENUWIDTH, 0, &ret );
2496         return ret;
2497     case SM_CYMENUSIZE:
2498         ncm.cbSize = sizeof(ncm);
2499         SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2500         return ncm.iMenuHeight;
2501     case SM_ARRANGE:
2502         get_entry( &entry_MINARRANGE, 0, &ret );
2503         return ret & 0x0f;
2504     case SM_CXMINIMIZED:
2505         get_entry( &entry_MINWIDTH, 0, &ret );
2506         return max( 0, (INT)ret ) + 6;
2507     case SM_CYMINIMIZED:
2508         return GetSystemMetrics( SM_CYSIZE ) + 6;
2509     case SM_CXMAXTRACK:
2510         return GetSystemMetrics(SM_CXVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CXFRAME);
2511     case SM_CYMAXTRACK:
2512         return GetSystemMetrics(SM_CYVIRTUALSCREEN) + 4 + 2 * GetSystemMetrics(SM_CYFRAME);
2513     case SM_CXMAXIMIZED:
2514         /* FIXME: subtract the width of any vertical application toolbars*/
2515         return GetSystemMetrics(SM_CXSCREEN) + 2 * GetSystemMetrics(SM_CXFRAME);
2516     case SM_CYMAXIMIZED:
2517         /* FIXME: subtract the width of any horizontal application toolbars*/
2518         return GetSystemMetrics(SM_CYSCREEN) + 2 * GetSystemMetrics(SM_CYCAPTION);
2519     case SM_NETWORK:
2520         return 3;  /* FIXME */
2521     case SM_CLEANBOOT:
2522         return 0; /* 0 = ok, 1 = failsafe, 2 = failsafe + network */
2523     case SM_CXDRAG:
2524         get_entry( &entry_DRAGWIDTH, 0, &ret );
2525         return ret;
2526     case SM_CYDRAG:
2527         get_entry( &entry_DRAGHEIGHT, 0, &ret );
2528         return ret;
2529     case SM_SHOWSOUNDS:
2530         get_entry( &entry_SHOWSOUNDS, 0, &ret );
2531         return ret;
2532     case SM_CXMENUCHECK:
2533     case SM_CYMENUCHECK:
2534     {
2535         TEXTMETRICW tm;
2536         ncm.cbSize = sizeof(ncm);
2537         SystemParametersInfoW( SPI_GETNONCLIENTMETRICS, 0, &ncm, 0 );
2538         get_text_metr_size( get_display_dc(), &ncm.lfMenuFont, &tm, NULL);
2539         return tm.tmHeight <= 0 ? 13 : ((tm.tmHeight + tm.tmExternalLeading + 1) / 2) * 2 - 1;
2540     }
2541     case SM_SLOWMACHINE:
2542         return 0;  /* Never true */
2543     case SM_MIDEASTENABLED:
2544         return 0;  /* FIXME */
2545     case SM_MOUSEWHEELPRESENT:
2546         return 1;
2547     case SM_XVIRTUALSCREEN:
2548     {
2549         RECT rect = get_virtual_screen_rect();
2550         return rect.left;
2551     }
2552     case SM_YVIRTUALSCREEN:
2553     {
2554         RECT rect = get_virtual_screen_rect();
2555         return rect.top;
2556     }
2557     case SM_CXVIRTUALSCREEN:
2558     {
2559         RECT rect = get_virtual_screen_rect();
2560         return rect.right - rect.left;
2561     }
2562     case SM_CYVIRTUALSCREEN:
2563     {
2564         RECT rect = get_virtual_screen_rect();
2565         return rect.bottom - rect.top;
2566     }
2567     case SM_CMONITORS:
2568     {
2569         struct monitor_info info;
2570         get_monitors_info( &info );
2571         return info.count;
2572     }
2573     case SM_SAMEDISPLAYFORMAT:
2574         return 1;
2575     case SM_IMMENABLED:
2576         return 0;  /* FIXME */
2577     case SM_CXFOCUSBORDER:
2578     case SM_CYFOCUSBORDER:
2579         return 1;
2580     case SM_TABLETPC:
2581     case SM_MEDIACENTER:
2582         return 0;
2583     case SM_CMETRICS:
2584         return SM_CMETRICS;
2585     default:
2586         return 0;
2587     }
2588 }
2589
2590
2591 /***********************************************************************
2592  *              SwapMouseButton (USER32.@)
2593  *  Reverse or restore the meaning of the left and right mouse buttons
2594  *  fSwap  [I ] TRUE - reverse, FALSE - original
2595  * RETURN
2596  *   previous state 
2597  */
2598 BOOL WINAPI SwapMouseButton( BOOL fSwap )
2599 {
2600     BOOL prev = GetSystemMetrics(SM_SWAPBUTTON);
2601     SystemParametersInfoW(SPI_SETMOUSEBUTTONSWAP, fSwap, 0, 0);
2602     return prev;
2603 }
2604
2605
2606 /**********************************************************************
2607  *              SetDoubleClickTime (USER32.@)
2608  */
2609 BOOL WINAPI SetDoubleClickTime( UINT interval )
2610 {
2611     return SystemParametersInfoW(SPI_SETDOUBLECLICKTIME, interval, 0, 0);
2612 }
2613
2614
2615 /**********************************************************************
2616  *              GetDoubleClickTime (USER32.@)
2617  */
2618 UINT WINAPI GetDoubleClickTime(void)
2619 {
2620     UINT time = 0;
2621
2622     get_entry( &entry_DOUBLECLICKTIME, 0, &time );
2623     if (!time) time = 500;
2624     return time;
2625 }
2626
2627
2628 /*************************************************************************
2629  *              GetSysColor (USER32.@)
2630  */
2631 COLORREF WINAPI DECLSPEC_HOTPATCH GetSysColor( INT nIndex )
2632 {
2633     COLORREF ret = 0;
2634
2635     if (nIndex >= 0 && nIndex < NUM_SYS_COLORS) get_entry( &system_colors[nIndex], 0, &ret );
2636     return ret;
2637 }
2638
2639
2640 /*************************************************************************
2641  *              SetSysColors (USER32.@)
2642  */
2643 BOOL WINAPI SetSysColors( INT count, const INT *colors, const COLORREF *values )
2644 {
2645     int i;
2646
2647     if (IS_INTRESOURCE(colors)) return FALSE; /* stupid app passes a color instead of an array */
2648
2649     for (i = 0; i < count; i++)
2650         if (colors[i] >= 0 && colors[i] <= NUM_SYS_COLORS)
2651             set_entry( &system_colors[colors[i]], values[i], 0, 0 );
2652
2653     /* Send WM_SYSCOLORCHANGE message to all windows */
2654
2655     SendMessageTimeoutW( HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0, SMTO_ABORTIFHUNG, 2000, NULL );
2656
2657     /* Repaint affected portions of all visible windows */
2658
2659     RedrawWindow( GetDesktopWindow(), NULL, 0,
2660                 RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW | RDW_ALLCHILDREN );
2661     return TRUE;
2662 }
2663
2664
2665 /*************************************************************************
2666  *              SetSysColorsTemp (USER32.@)
2667  */
2668 DWORD_PTR WINAPI SetSysColorsTemp( const COLORREF *pPens, const HBRUSH *pBrushes, DWORD_PTR n)
2669 {
2670     FIXME( "no longer supported\n" );
2671     return FALSE;
2672 }
2673
2674
2675 /***********************************************************************
2676  *              GetSysColorBrush (USER32.@)
2677  */
2678 HBRUSH WINAPI DECLSPEC_HOTPATCH GetSysColorBrush( INT index )
2679 {
2680     if (index < 0 || index >= NUM_SYS_COLORS) return 0;
2681
2682     if (!system_colors[index].brush)
2683     {
2684         HBRUSH brush = CreateSolidBrush( GetSysColor( index ));
2685         __wine_make_gdi_object_system( brush, TRUE );
2686         if (InterlockedCompareExchangePointer( (void **)&system_colors[index].brush, brush, 0 ))
2687         {
2688             __wine_make_gdi_object_system( brush, FALSE );
2689             DeleteObject( brush );
2690         }
2691     }
2692     return system_colors[index].brush;
2693 }
2694
2695
2696 /***********************************************************************
2697  *              SYSCOLOR_GetPen
2698  */
2699 HPEN SYSCOLOR_GetPen( INT index )
2700 {
2701     /* We can assert here, because this function is internal to Wine */
2702     assert (0 <= index && index < NUM_SYS_COLORS);
2703
2704     if (!system_colors[index].pen)
2705     {
2706         HPEN pen = CreatePen( PS_SOLID, 1, GetSysColor( index ));
2707         __wine_make_gdi_object_system( pen, TRUE );
2708         if (InterlockedCompareExchangePointer( (void **)&system_colors[index].pen, pen, 0 ))
2709         {
2710             __wine_make_gdi_object_system( pen, FALSE );
2711             DeleteObject( pen );
2712         }
2713     }
2714     return system_colors[index].pen;
2715 }
2716
2717
2718 /***********************************************************************
2719  *              ChangeDisplaySettingsA (USER32.@)
2720  */
2721 LONG WINAPI ChangeDisplaySettingsA( LPDEVMODEA devmode, DWORD flags )
2722 {
2723     if (devmode) devmode->dmDriverExtra = 0;
2724
2725     return ChangeDisplaySettingsExA(NULL,devmode,NULL,flags,NULL);
2726 }
2727
2728
2729 /***********************************************************************
2730  *              ChangeDisplaySettingsW (USER32.@)
2731  */
2732 LONG WINAPI ChangeDisplaySettingsW( LPDEVMODEW devmode, DWORD flags )
2733 {
2734     if (devmode) devmode->dmDriverExtra = 0;
2735
2736     return ChangeDisplaySettingsExW(NULL,devmode,NULL,flags,NULL);
2737 }
2738
2739
2740 /***********************************************************************
2741  *              ChangeDisplaySettingsExA (USER32.@)
2742  */
2743 LONG WINAPI ChangeDisplaySettingsExA( LPCSTR devname, LPDEVMODEA devmode, HWND hwnd,
2744                                       DWORD flags, LPVOID lparam )
2745 {
2746     LONG ret;
2747     UNICODE_STRING nameW;
2748
2749     if (devname) RtlCreateUnicodeStringFromAsciiz(&nameW, devname);
2750     else nameW.Buffer = NULL;
2751
2752     if (devmode)
2753     {
2754         DEVMODEW *devmodeW;
2755
2756         devmodeW = GdiConvertToDevmodeW(devmode);
2757         if (devmodeW)
2758         {
2759             ret = ChangeDisplaySettingsExW(nameW.Buffer, devmodeW, hwnd, flags, lparam);
2760             HeapFree(GetProcessHeap(), 0, devmodeW);
2761         }
2762         else
2763             ret = DISP_CHANGE_SUCCESSFUL;
2764     }
2765     else
2766     {
2767         ret = ChangeDisplaySettingsExW(nameW.Buffer, NULL, hwnd, flags, lparam);
2768     }
2769
2770     if (devname) RtlFreeUnicodeString(&nameW);
2771     return ret;
2772 }
2773
2774
2775 /***********************************************************************
2776  *              ChangeDisplaySettingsExW (USER32.@)
2777  */
2778 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
2779                                       DWORD flags, LPVOID lparam )
2780 {
2781     /* make sure the desktop window is created before mode changing */
2782     GetDesktopWindow();
2783
2784     return USER_Driver->pChangeDisplaySettingsEx( devname, devmode, hwnd, flags, lparam );
2785 }
2786
2787
2788 /***********************************************************************
2789  *              EnumDisplaySettingsW (USER32.@)
2790  *
2791  * RETURNS
2792  *      TRUE if nth setting exists found (described in the LPDEVMODEW struct)
2793  *      FALSE if we do not have the nth setting
2794  */
2795 BOOL WINAPI EnumDisplaySettingsW( LPCWSTR name, DWORD n, LPDEVMODEW devmode )
2796 {
2797     return EnumDisplaySettingsExW(name, n, devmode, 0);
2798 }
2799
2800
2801 /***********************************************************************
2802  *              EnumDisplaySettingsA (USER32.@)
2803  */
2804 BOOL WINAPI EnumDisplaySettingsA(LPCSTR name,DWORD n,LPDEVMODEA devmode)
2805 {
2806     return EnumDisplaySettingsExA(name, n, devmode, 0);
2807 }
2808
2809
2810 /***********************************************************************
2811  *              EnumDisplaySettingsExA (USER32.@)
2812  */
2813 BOOL WINAPI EnumDisplaySettingsExA(LPCSTR lpszDeviceName, DWORD iModeNum,
2814                                    LPDEVMODEA lpDevMode, DWORD dwFlags)
2815 {
2816     DEVMODEW devmodeW;
2817     BOOL ret;
2818     UNICODE_STRING nameW;
2819
2820     if (lpszDeviceName) RtlCreateUnicodeStringFromAsciiz(&nameW, lpszDeviceName);
2821     else nameW.Buffer = NULL;
2822
2823     ret = EnumDisplaySettingsExW(nameW.Buffer,iModeNum,&devmodeW,dwFlags);
2824     if (ret)
2825     {
2826         lpDevMode->dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod);
2827         lpDevMode->dmSpecVersion = devmodeW.dmSpecVersion;
2828         lpDevMode->dmDriverVersion = devmodeW.dmDriverVersion;
2829         WideCharToMultiByte(CP_ACP, 0, devmodeW.dmDeviceName, -1,
2830                             (LPSTR)lpDevMode->dmDeviceName, CCHDEVICENAME, NULL, NULL);
2831         lpDevMode->dmDriverExtra      = 0; /* FIXME */
2832         lpDevMode->dmBitsPerPel       = devmodeW.dmBitsPerPel;
2833         lpDevMode->dmPelsHeight       = devmodeW.dmPelsHeight;
2834         lpDevMode->dmPelsWidth        = devmodeW.dmPelsWidth;
2835         lpDevMode->u2.dmDisplayFlags  = devmodeW.u2.dmDisplayFlags;
2836         lpDevMode->dmDisplayFrequency = devmodeW.dmDisplayFrequency;
2837         lpDevMode->dmFields           = devmodeW.dmFields;
2838
2839         lpDevMode->u1.s2.dmPosition.x = devmodeW.u1.s2.dmPosition.x;
2840         lpDevMode->u1.s2.dmPosition.y = devmodeW.u1.s2.dmPosition.y;
2841         lpDevMode->u1.s2.dmDisplayOrientation = devmodeW.u1.s2.dmDisplayOrientation;
2842         lpDevMode->u1.s2.dmDisplayFixedOutput = devmodeW.u1.s2.dmDisplayFixedOutput;
2843     }
2844     if (lpszDeviceName) RtlFreeUnicodeString(&nameW);
2845     return ret;
2846 }
2847
2848
2849 /***********************************************************************
2850  *              EnumDisplaySettingsExW (USER32.@)
2851  */
2852 BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
2853                                    LPDEVMODEW lpDevMode, DWORD dwFlags)
2854 {
2855     /* make sure the desktop window is created before mode enumeration */
2856     GetDesktopWindow();
2857
2858     return USER_Driver->pEnumDisplaySettingsEx(lpszDeviceName, iModeNum, lpDevMode, dwFlags);
2859 }
2860
2861 /***********************************************************************
2862  *              SetProcessDPIAware   (USER32.@)
2863  */
2864 BOOL WINAPI SetProcessDPIAware( VOID )
2865 {
2866     FIXME( "stub!\n");
2867
2868     return TRUE;
2869 }