2 * System metrics functions
4 * Copyright 1994 Alexandre Julliard
14 #include "wine/winuser16.h"
20 #include "sysmetrics.h"
22 static int sysMetrics[SM_WINE_CMETRICS+1];
25 /***********************************************************************
26 * RegistryTwips2Pixels
28 * Convert a a dimension value that was obtained from the registry. These are
29 * quoted as being "twips" values if negative and pixels if positive.
31 * MSDN Library - April 2001 -> Resource Kits ->
32 * Windows 2000 Resource Kit Reference ->
33 * Technical Reference to the Windows 2000 Registry ->
34 * HKEY_CURRENT_USE -> Control Panel -> Desktop -> WindowMetrics
36 * This is written as a function to prevent repeated evaluation of the
39 inline static int RegistryTwips2Pixels(int x)
47 /***********************************************************************
48 * SYSMETRICS_GetRegistryMetric
50 * Get a registry entry from the already open key. This allows us to open the
51 * section once and read several values.
53 * Of course this function belongs somewhere more usable but here will do
56 static int SYSMETRICS_GetRegistryMetric (
57 HKEY hkey, /* handle to the registry section */
58 const char *key, /* value name in the section */
59 int default_value) /* default to return */
61 int value = default_value;
65 DWORD type, count = sizeof(buffer);
66 if(!RegQueryValueExA (hkey, key, 0, &type, buffer, &count))
70 /* Are there any utilities for converting registry entries
73 /* FIXME_(reg)("We need reg format converter\n"); */
79 return RegistryTwips2Pixels(value);
83 /***********************************************************************
86 * Initialisation of the system metrics array.
88 * Differences in return values between 3.1 and 95 apps under Win95 (FIXME ?):
89 * SM_CXVSCROLL x+1 x Fixed May 24, 1999 - Ronald B. Cemer
90 * SM_CYHSCROLL x+1 x Fixed May 24, 1999 - Ronald B. Cemer
91 * SM_CXDLGFRAME x-1 x Already fixed
92 * SM_CYDLGFRAME x-1 x Already fixed
93 * SM_CYCAPTION x+1 x Fixed May 24, 1999 - Ronald B. Cemer
94 * SM_CYMENU x-1 x Already fixed
95 * SM_CYFULLSCREEN x-1 x
96 * SM_CXFRAME Fixed July 6, 2001 - Bill Medland
98 * (collides with TWEAK_WineLook sometimes,
99 * so changing anything might be difficult)
101 * Starting at Win95 there are now a large number or Registry entries in the
102 * [WindowMetrics] section that are probably relevant here.
104 void SYSMETRICS_Init(void)
106 HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
107 HKEY hkey; /* key to the window metrics area of the registry */
112 if (RegOpenKeyExA (HKEY_CURRENT_USER, "Control Panel\\desktop\\WindowMetrics",
113 0, KEY_QUERY_VALUE, &hkey) != ERROR_SUCCESS) hkey = 0;
115 if (TWEAK_WineLook > WIN31_LOOK)
117 sysMetrics[SM_CXVSCROLL] = SYSMETRICS_GetRegistryMetric( hkey, "ScrollWidth", 16 );
118 sysMetrics[SM_CYHSCROLL] = sysMetrics[SM_CXVSCROLL];
120 /* The Win 2000 resource kit SAYS that this is governed by the ScrollHeight
121 * but on my computer that controls the CYV/CXH values. */
122 sysMetrics[SM_CYCAPTION] = SYSMETRICS_GetRegistryMetric(hkey, "CaptionHeight", 18)
123 + 1; /* for the separator? */
125 sysMetrics[SM_CYMENU] = SYSMETRICS_GetRegistryMetric (hkey, "MenuHeight", 18) + 1;
128 sysMetrics[SM_CXDLGFRAME] = 3;
129 sysMetrics[SM_CYDLGFRAME] = sysMetrics[SM_CXDLGFRAME];
131 /* force setting of SM_CXFRAME/SM_CYFRAME */
132 SystemParametersInfoA( SPI_GETBORDER, 0, &dummy, 0 );
136 sysMetrics[SM_CXVSCROLL] = 17;
137 sysMetrics[SM_CYHSCROLL] = sysMetrics[SM_CXVSCROLL];
138 sysMetrics[SM_CYCAPTION] = 20;
139 sysMetrics[SM_CYMENU] = 18;
140 sysMetrics[SM_CXDLGFRAME] = 4;
141 sysMetrics[SM_CYDLGFRAME] = sysMetrics[SM_CXDLGFRAME];
142 sysMetrics[SM_CXFRAME] = GetProfileIntA("Windows", "BorderWidth", 4) + 1;
143 sysMetrics[SM_CYFRAME] = sysMetrics[SM_CXFRAME];
146 sysMetrics[SM_CXCURSOR] = 32;
147 sysMetrics[SM_CYCURSOR] = 32;
148 sysMetrics[SM_CXSCREEN] = GetDeviceCaps( hdc, HORZRES );
149 sysMetrics[SM_CYSCREEN] = GetDeviceCaps( hdc, VERTRES );
150 sysMetrics[SM_WINE_BPP] = GetDeviceCaps( hdc, BITSPIXEL );
151 sysMetrics[SM_CXBORDER] = 1;
152 sysMetrics[SM_CYBORDER] = sysMetrics[SM_CXBORDER];
153 sysMetrics[SM_CYVTHUMB] = sysMetrics[SM_CXVSCROLL] - 1;
154 sysMetrics[SM_CXHTHUMB] = sysMetrics[SM_CYVTHUMB];
155 sysMetrics[SM_CXICON] = 32;
156 sysMetrics[SM_CYICON] = 32;
157 sysMetrics[SM_CXFULLSCREEN] = sysMetrics[SM_CXSCREEN];
158 sysMetrics[SM_CYFULLSCREEN] =
159 sysMetrics[SM_CYSCREEN] - sysMetrics[SM_CYCAPTION];
160 sysMetrics[SM_CYKANJIWINDOW] = 0;
161 sysMetrics[SM_MOUSEPRESENT] = 1;
162 sysMetrics[SM_CYVSCROLL] = SYSMETRICS_GetRegistryMetric (hkey, "ScrollHeight", sysMetrics[SM_CXVSCROLL]);
163 sysMetrics[SM_CXHSCROLL] = SYSMETRICS_GetRegistryMetric (hkey, "ScrollHeight", sysMetrics[SM_CYHSCROLL]);
164 sysMetrics[SM_DEBUG] = 0;
166 sysMetrics[SM_SWAPBUTTON] = 0;
167 sysMetrics[SM_SWAPBUTTON] = SYSPARAMS_GetMouseButtonSwap();
169 sysMetrics[SM_RESERVED1] = 0;
170 sysMetrics[SM_RESERVED2] = 0;
171 sysMetrics[SM_RESERVED3] = 0;
172 sysMetrics[SM_RESERVED4] = 0;
174 /* FIXME: The following two are calculated, but how? */
175 sysMetrics[SM_CXMIN] = (TWEAK_WineLook > WIN31_LOOK) ? 112 : 100;
176 sysMetrics[SM_CYMIN] = (TWEAK_WineLook > WIN31_LOOK) ? 27 : 28;
178 sysMetrics[SM_CXSIZE] = sysMetrics[SM_CYCAPTION] - 2;
179 sysMetrics[SM_CYSIZE] = sysMetrics[SM_CXSIZE];
180 sysMetrics[SM_CXMINTRACK] = sysMetrics[SM_CXMIN];
181 sysMetrics[SM_CYMINTRACK] = sysMetrics[SM_CYMIN];
183 sysMetrics[SM_CXDOUBLECLK] = 4;
184 sysMetrics[SM_CYDOUBLECLK] = 4;
185 SYSPARAMS_GetDoubleClickSize( &sysMetrics[SM_CXDOUBLECLK], &sysMetrics[SM_CYDOUBLECLK] );
187 sysMetrics[SM_CXICONSPACING] = 75;
188 SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0,
189 &sysMetrics[SM_CXICONSPACING], 0 );
190 sysMetrics[SM_CYICONSPACING] = 75;
191 SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0,
192 &sysMetrics[SM_CYICONSPACING], 0 );
194 SystemParametersInfoA( SPI_GETMENUDROPALIGNMENT, 0,
195 &sysMetrics[SM_MENUDROPALIGNMENT], 0 );
196 sysMetrics[SM_PENWINDOWS] = 0;
197 sysMetrics[SM_DBCSENABLED] = 0;
199 /* FIXME: Need to query X for the following */
200 sysMetrics[SM_CMOUSEBUTTONS] = 3;
202 sysMetrics[SM_SECURE] = 0;
203 sysMetrics[SM_CXEDGE] = sysMetrics[SM_CXBORDER] + 1;
204 sysMetrics[SM_CYEDGE] = sysMetrics[SM_CXEDGE];
205 sysMetrics[SM_CXMINSPACING] = 160;
206 sysMetrics[SM_CYMINSPACING] = 24;
207 sysMetrics[SM_CXSMICON] = sysMetrics[SM_CYSIZE] - (sysMetrics[SM_CYSIZE] % 2);
208 sysMetrics[SM_CYSMICON] = sysMetrics[SM_CXSMICON];
209 sysMetrics[SM_CYSMCAPTION] = 16;
210 sysMetrics[SM_CXSMSIZE] = 15;
211 sysMetrics[SM_CYSMSIZE] = sysMetrics[SM_CXSMSIZE];
212 sysMetrics[SM_CXMENUSIZE] = sysMetrics[SM_CYMENU];
213 sysMetrics[SM_CYMENUSIZE] = sysMetrics[SM_CXMENUSIZE];
215 /* FIXME: What do these mean? */
216 sysMetrics[SM_ARRANGE] = ARW_HIDE;
217 sysMetrics[SM_CXMINIMIZED] = 160;
218 sysMetrics[SM_CYMINIMIZED] = 24;
220 /* FIXME: How do I calculate these? */
221 sysMetrics[SM_CXMAXTRACK] =
222 sysMetrics[SM_CXSCREEN] + 4 + 2 * sysMetrics[SM_CXFRAME];
223 sysMetrics[SM_CYMAXTRACK] =
224 sysMetrics[SM_CYSCREEN] + 4 + 2 * sysMetrics[SM_CYFRAME];
225 sysMetrics[SM_CXMAXIMIZED] =
226 sysMetrics[SM_CXSCREEN] + 2 * sysMetrics[SM_CXFRAME];
227 sysMetrics[SM_CYMAXIMIZED] =
228 sysMetrics[SM_CYSCREEN] - 45;
229 sysMetrics[SM_NETWORK] = 3;
231 /* For the following: 0 = ok, 1 = failsafe, 2 = failsafe + network */
232 sysMetrics[SM_CLEANBOOT] = 0;
234 sysMetrics[SM_CXDRAG] = 2;
235 sysMetrics[SM_CYDRAG] = 2;
236 sysMetrics[SM_CXMENUCHECK] = 14;
237 sysMetrics[SM_CYMENUCHECK] = 14;
239 /* FIXME: Should check the type of processor for the following */
240 sysMetrics[SM_SLOWMACHINE] = 0;
242 /* FIXME: Should perform a check */
243 sysMetrics[SM_MIDEASTENABLED] = 0;
245 sysMetrics[SM_MOUSEWHEELPRESENT] = 0;
247 sysMetrics[SM_CXVIRTUALSCREEN] = sysMetrics[SM_CXSCREEN];
248 sysMetrics[SM_CYVIRTUALSCREEN] = sysMetrics[SM_CYSCREEN];
249 sysMetrics[SM_XVIRTUALSCREEN] = 0;
250 sysMetrics[SM_YVIRTUALSCREEN] = 0;
251 sysMetrics[SM_CMONITORS] = 1;
252 sysMetrics[SM_SAMEDISPLAYFORMAT] = 1;
253 sysMetrics[SM_CMETRICS] = SM_CMETRICS;
255 SystemParametersInfoA( SPI_GETSHOWSOUNDS, 0, &sysMetrics[SM_SHOWSOUNDS], 0 );
257 if (hkey) RegCloseKey (hkey);
262 /***********************************************************************
265 * Sets system metrics.
267 INT SYSMETRICS_Set( INT index, INT value )
269 if ((index < 0) || (index > SM_WINE_CMETRICS)) return 0;
272 INT prev = sysMetrics[index];
273 sysMetrics[index] = value;
279 /***********************************************************************
280 * GetSystemMetrics (USER.179)
282 INT16 WINAPI GetSystemMetrics16( INT16 index )
284 return (INT16)GetSystemMetrics(index);
288 /***********************************************************************
289 * GetSystemMetrics (USER32.@)
291 INT WINAPI GetSystemMetrics( INT index )
293 if ((index < 0) || (index > SM_WINE_CMETRICS)) return 0;
294 return sysMetrics[index];