2 * System parameters functions
4 * Copyright 1994 Alexandre Julliard
12 #include "wine/winuser16.h"
19 #include "debugtools.h"
21 DEFAULT_DEBUG_CHANNEL(system);
23 /***********************************************************************
24 * GetTimerResolution (USER.14)
26 LONG WINAPI GetTimerResolution16(void)
31 /***********************************************************************
32 * SystemParametersInfo32A (USER32.540)
34 BOOL WINAPI SystemParametersInfoA( UINT uAction, UINT uParam,
35 LPVOID lpvParam, UINT fuWinIni )
41 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
44 KEYBOARD_SetBeepActive(uParam);
48 *(INT *)lpvParam = GetSystemMetrics( SM_CXFRAME );
51 case SPI_GETDRAGFULLWINDOWS:
52 *(BOOL *) lpvParam = FALSE;
55 case SPI_SETDRAGFULLWINDOWS:
58 case SPI_GETFASTTASKSWITCH:
59 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
60 *(BOOL *) lpvParam = TRUE;
62 *(BOOL *) lpvParam = FALSE;
65 case SPI_GETGRIDGRANULARITY:
66 *(INT*)lpvParam=GetProfileIntA("desktop","GridGranularity",1);
69 case SPI_GETICONTITLEWRAP:
70 *(BOOL*)lpvParam=GetProfileIntA("desktop","IconTitleWrap",TRUE);
73 case SPI_GETKEYBOARDDELAY:
74 *(INT*)lpvParam=GetProfileIntA("keyboard","KeyboardDelay",1);
77 case SPI_GETKEYBOARDSPEED:
78 *(DWORD*)lpvParam=GetProfileIntA("keyboard","KeyboardSpeed",30);
81 case SPI_GETMENUDROPALIGNMENT:
82 *(BOOL*)lpvParam=GetSystemMetrics(SM_MENUDROPALIGNMENT); /* XXX check this */
85 case SPI_GETSCREENSAVEACTIVE:
86 if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) ||
87 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
88 *(BOOL*)lpvParam = TRUE;
90 *(BOOL*)lpvParam = FALSE;
93 case SPI_GETSCREENSAVETIMEOUT:
94 timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
96 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
97 *(INT *) lpvParam = timeout * 1000;
100 case SPI_ICONHORIZONTALSPACING:
101 /* FIXME Get/SetProfileInt */
102 if (lpvParam == NULL)
103 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
105 *(INT*)lpvParam=GetSystemMetrics(SM_CXICONSPACING);
108 case SPI_ICONVERTICALSPACING:
109 /* FIXME Get/SetProfileInt */
110 if (lpvParam == NULL)
111 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
113 *(INT*)lpvParam=GetSystemMetrics(SM_CYICONSPACING);
116 case SPI_GETICONTITLELOGFONT: {
117 LPLOGFONTA lpLogFont = (LPLOGFONTA)lpvParam;
119 /* from now on we always have an alias for MS Sans Serif */
121 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
122 lpLogFont->lfFaceName, LF_FACESIZE );
123 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13);
124 lpLogFont->lfWidth = 0;
125 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
126 lpLogFont->lfWeight = FW_NORMAL;
127 lpLogFont->lfItalic = FALSE;
128 lpLogFont->lfStrikeOut = FALSE;
129 lpLogFont->lfUnderline = FALSE;
130 lpLogFont->lfCharSet = ANSI_CHARSET;
131 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
132 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
133 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
137 case SPI_GETICONMETRICS: {
138 LPICONMETRICSA lpIcon = lpvParam;
139 if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon))
141 SystemParametersInfoA( SPI_ICONHORIZONTALSPACING, 0,
142 &lpIcon->iHorzSpacing, FALSE );
143 SystemParametersInfoA( SPI_ICONVERTICALSPACING, 0,
144 &lpIcon->iVertSpacing, FALSE );
145 SystemParametersInfoA( SPI_GETICONTITLEWRAP, 0,
146 &lpIcon->iTitleWrap, FALSE );
147 SystemParametersInfoA( SPI_GETICONTITLELOGFONT, 0,
148 &lpIcon->lfFont, FALSE );
151 case SPI_GETWORKAREA:
152 SetRect( (RECT *)lpvParam, 0, 0,
153 GetSystemMetrics( SM_CXSCREEN ),
154 GetSystemMetrics( SM_CYSCREEN )
157 case SPI_GETNONCLIENTMETRICS:
159 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
161 if( lpnm->cbSize == sizeof(NONCLIENTMETRICSA) )
163 LPLOGFONTA lpLogFont = &(lpnm->lfMenuFont);
165 /* clear the struct, so we have 'sane' members */
167 (char*)lpvParam+sizeof(lpnm->cbSize),
169 lpnm->cbSize-sizeof(lpnm->cbSize)
172 /* FIXME: initialize geometry entries */
173 /* FIXME: As these values are presumably in device units,
174 * we should calculate the defaults based on the screen dpi
177 lpnm->iCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 20);
178 lpnm->iCaptionHeight = lpnm->iCaptionWidth;
179 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
180 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfCaptionFont),0);
183 lpnm->iSmCaptionWidth = ((TWEAK_WineLook > WIN31_LOOK) ? 32 : 17);
184 lpnm->iSmCaptionHeight = lpnm->iSmCaptionWidth;
185 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0, (LPVOID)&(lpnm->lfSmCaptionFont),0);
187 /* menus, FIXME: names of wine.conf entrys are bogus */
189 lpnm->iMenuWidth = GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/
190 lpnm->iMenuHeight = GetProfileIntA("Desktop","MenuHeight",
191 (TWEAK_WineLook > WIN31_LOOK) ? 13 : 27);
193 GetProfileStringA("Desktop", "MenuFont",
194 (TWEAK_WineLook > WIN31_LOOK) ? "MS Sans Serif": "System",
195 lpLogFont->lfFaceName, LF_FACESIZE );
197 lpLogFont->lfHeight = -GetProfileIntA("Desktop","MenuFontSize", 13);
198 lpLogFont->lfWidth = 0;
199 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
200 lpLogFont->lfWeight = (TWEAK_WineLook > WIN31_LOOK) ? FW_NORMAL : FW_BOLD;
201 lpLogFont->lfItalic = FALSE;
202 lpLogFont->lfStrikeOut = FALSE;
203 lpLogFont->lfUnderline = FALSE;
204 lpLogFont->lfCharSet = ANSI_CHARSET;
205 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
206 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
207 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
209 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
210 (LPVOID)&(lpnm->lfStatusFont),0);
211 SystemParametersInfoA(SPI_GETICONTITLELOGFONT, 0,
212 (LPVOID)&(lpnm->lfMessageFont),0);
217 case SPI_GETANIMATION: {
218 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
220 /* Tell it "disabled" */
221 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
222 uParam = sizeof(ANIMATIONINFO);
223 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
227 case SPI_SETANIMATION: {
228 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
231 WARN("SPI_SETANIMATION ignored.\n");
232 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
233 uParam = sizeof(ANIMATIONINFO);
237 case SPI_GETHIGHCONTRAST:
239 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
241 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
243 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
245 /* Indicate that there is no high contrast available */
246 lpHighContrastA->dwFlags = 0;
247 lpHighContrastA->lpszDefaultScheme = NULL;
258 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
264 /***********************************************************************
265 * SystemParametersInfo16 (USER.483)
267 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
268 LPVOID lpvParam, UINT16 fuWinIni )
276 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
280 *(INT16 *)lpvParam = GetSystemMetrics( SM_CXFRAME );
283 case SPI_GETFASTTASKSWITCH:
284 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
285 *(BOOL16 *) lpvParam = TRUE;
287 *(BOOL16 *) lpvParam = FALSE;
290 case SPI_GETGRIDGRANULARITY:
291 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
296 case SPI_GETICONTITLEWRAP:
297 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
302 case SPI_GETKEYBOARDDELAY:
303 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
304 "KeyboardDelay", 1 );
307 case SPI_GETKEYBOARDSPEED:
308 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
313 case SPI_GETMENUDROPALIGNMENT:
314 *(BOOL16 *) lpvParam = GetSystemMetrics( SM_MENUDROPALIGNMENT ); /* XXX check this */
317 case SPI_GETSCREENSAVEACTIVE:
318 if(MONITOR_GetScreenSaveActive(&MONITOR_PrimaryMonitor) ||
319 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
320 *(BOOL16 *) lpvParam = TRUE;
322 *(BOOL16 *) lpvParam = FALSE;
325 case SPI_GETSCREENSAVETIMEOUT:
326 timeout = MONITOR_GetScreenSaveTimeout(&MONITOR_PrimaryMonitor);
328 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
329 *(INT16 *) lpvParam = timeout;
332 case SPI_ICONHORIZONTALSPACING:
333 /* FIXME Get/SetProfileInt */
334 if (lpvParam == NULL)
335 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
337 *(INT16 *)lpvParam = GetSystemMetrics( SM_CXICONSPACING );
340 case SPI_ICONVERTICALSPACING:
341 /* FIXME Get/SetProfileInt */
342 if (lpvParam == NULL)
343 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
345 *(INT16 *)lpvParam = GetSystemMetrics(SM_CYICONSPACING);
349 KEYBOARD_SetBeepActive(uParam);
352 case SPI_SETSCREENSAVEACTIVE:
353 MONITOR_SetScreenSaveActive(&MONITOR_PrimaryMonitor, uParam);
356 case SPI_SETSCREENSAVETIMEOUT:
357 MONITOR_SetScreenSaveTimeout(&MONITOR_PrimaryMonitor, uParam);
360 case SPI_SETDESKWALLPAPER:
361 return (SetDeskWallPaper((LPSTR) lpvParam));
364 case SPI_SETDESKPATTERN:
365 if ((INT16)uParam == -1) {
366 GetProfileStringA("Desktop", "Pattern",
367 "170 85 170 85 170 85 170 85",
368 buffer, sizeof(buffer) );
369 return (DESKTOP_SetPattern((LPSTR) buffer));
371 return (DESKTOP_SetPattern((LPSTR) lpvParam));
374 case SPI_GETICONTITLELOGFONT:
376 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
377 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
378 lpLogFont->lfFaceName, LF_FACESIZE );
379 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13);
380 lpLogFont->lfWidth = 0;
381 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
382 lpLogFont->lfWeight = FW_NORMAL;
383 lpLogFont->lfItalic = FALSE;
384 lpLogFont->lfStrikeOut = FALSE;
385 lpLogFont->lfUnderline = FALSE;
386 lpLogFont->lfCharSet = ANSI_CHARSET;
387 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
388 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
389 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
392 case SPI_GETNONCLIENTMETRICS:
394 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
395 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
397 /* clear the struct, so we have 'sane' members */
399 (char*)lpvParam+sizeof(lpnm->cbSize),
401 lpnm->cbSize-sizeof(lpnm->cbSize)
403 /* FIXME: initialize geometry entries */
404 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
405 (LPVOID)&(lpnm->lfCaptionFont),0);
406 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
407 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
408 (LPVOID)&(lpnm->lfSmCaptionFont),0);
409 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
410 (LPVOID)&(lpnm->lfMenuFont),0);
411 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
412 (LPVOID)&(lpnm->lfStatusFont),0);
413 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
414 (LPVOID)&(lpnm->lfMessageFont),0);
416 else /* winfile 95 sets sbSize to 340 */
417 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
423 case SPI_SETDOUBLECLKHEIGHT:
424 case SPI_SETDOUBLECLICKTIME:
425 case SPI_SETDOUBLECLKWIDTH:
426 case SPI_SETFASTTASKSWITCH:
427 case SPI_SETKEYBOARDDELAY:
428 case SPI_SETKEYBOARDSPEED:
429 WARN("Option %d ignored.\n", uAction);
432 case SPI_GETWORKAREA:
433 SetRect16( (RECT16 *)lpvParam, 0, 0,
434 GetSystemMetrics( SM_CXSCREEN ),
435 GetSystemMetrics( SM_CYSCREEN ) );
439 FIXME("Unknown option %d.\n", uAction);
440 SetLastError(ERROR_INVALID_SPI_VALUE);
446 /***********************************************************************
447 * SystemParametersInfo32W (USER32.541)
449 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
450 LPVOID lpvParam, UINT fuWinIni )
456 case SPI_SETDESKWALLPAPER:
459 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
460 return SetDeskWallPaper(buffer);
462 return SetDeskWallPaper(NULL);
464 case SPI_SETDESKPATTERN:
465 if ((INT) uParam == -1)
467 GetProfileStringA("Desktop", "Pattern",
468 "170 85 170 85 170 85 170 85",
469 buffer, sizeof(buffer) );
470 return (DESKTOP_SetPattern((LPSTR) buffer));
474 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
475 return DESKTOP_SetPattern(buffer);
477 return DESKTOP_SetPattern(NULL);
479 case SPI_GETICONTITLELOGFONT:
481 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
483 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
484 buffer, sizeof(buffer) );
485 lstrcpynAtoW(lpLogFont->lfFaceName, buffer, LF_FACESIZE);
486 lpLogFont->lfHeight = 17;
487 lpLogFont->lfWidth = 0;
488 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
489 lpLogFont->lfWeight = FW_NORMAL;
490 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
491 lpLogFont->lfCharSet = ANSI_CHARSET;
492 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
493 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
494 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
497 case SPI_GETICONMETRICS: {
498 LPICONMETRICSW lpIcon = lpvParam;
499 if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon))
501 SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0,
502 &lpIcon->iHorzSpacing, FALSE );
503 SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0,
504 &lpIcon->iVertSpacing, FALSE );
505 SystemParametersInfoW( SPI_GETICONTITLEWRAP, 0,
506 &lpIcon->iTitleWrap, FALSE );
507 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0,
508 &lpIcon->lfFont, FALSE );
511 case SPI_GETNONCLIENTMETRICS: {
512 /* FIXME: implement correctly */
513 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
515 /* clear the struct, so we have 'sane' members */
516 memset((char*)lpvParam+sizeof(lpnm->cbSize),
518 lpnm->cbSize-sizeof(lpnm->cbSize)
520 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
521 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
522 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
523 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
524 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
525 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
529 case SPI_GETHIGHCONTRAST:
531 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
533 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
535 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
537 /* Indicate that there is no high contrast available */
538 lpHighContrastW->dwFlags = 0;
539 lpHighContrastW->lpszDefaultScheme = NULL;
550 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);