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 * SystemParametersInfoA (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(USER_Driver->pGetScreenSaveActive() ||
87 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
88 *(BOOL*)lpvParam = TRUE;
90 *(BOOL*)lpvParam = FALSE;
93 case SPI_GETSCREENSAVETIMEOUT:
94 timeout = USER_Driver->pGetScreenSaveTimeout();
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);
216 WARN("size mismatch !! (is %d; should be %d)\n", lpnm->cbSize, sizeof(NONCLIENTMETRICSA));
222 case SPI_GETANIMATION: {
223 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
225 /* Tell it "disabled" */
226 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
227 uParam = sizeof(ANIMATIONINFO);
228 lpAnimInfo->iMinAnimate = 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
232 case SPI_SETANIMATION: {
233 LPANIMATIONINFO lpAnimInfo = (LPANIMATIONINFO)lpvParam;
236 WARN("SPI_SETANIMATION ignored.\n");
237 lpAnimInfo->cbSize = sizeof(ANIMATIONINFO);
238 uParam = sizeof(ANIMATIONINFO);
242 case SPI_GETHIGHCONTRAST:
244 LPHIGHCONTRASTA lpHighContrastA = (LPHIGHCONTRASTA)lpvParam;
246 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
248 if ( lpHighContrastA->cbSize == sizeof( HIGHCONTRASTA ) )
250 /* Indicate that there is no high contrast available */
251 lpHighContrastA->dwFlags = 0;
252 lpHighContrastA->lpszDefaultScheme = NULL;
263 return SystemParametersInfo16(uAction,uParam,lpvParam,fuWinIni);
269 /***********************************************************************
270 * SystemParametersInfo16 (USER.483)
272 BOOL16 WINAPI SystemParametersInfo16( UINT16 uAction, UINT16 uParam,
273 LPVOID lpvParam, UINT16 fuWinIni )
281 *(BOOL *) lpvParam = KEYBOARD_GetBeepActive();
285 *(INT16 *)lpvParam = GetSystemMetrics( SM_CXFRAME );
288 case SPI_GETFASTTASKSWITCH:
289 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
290 *(BOOL16 *) lpvParam = TRUE;
292 *(BOOL16 *) lpvParam = FALSE;
295 case SPI_GETGRIDGRANULARITY:
296 *(INT16 *) lpvParam = GetProfileIntA( "desktop",
301 case SPI_GETICONTITLEWRAP:
302 *(BOOL16 *) lpvParam = GetProfileIntA( "desktop",
307 case SPI_GETKEYBOARDDELAY:
308 *(INT16 *) lpvParam = GetProfileIntA( "keyboard",
309 "KeyboardDelay", 1 );
312 case SPI_GETKEYBOARDSPEED:
313 *(WORD *) lpvParam = GetProfileIntA( "keyboard",
318 case SPI_GETMENUDROPALIGNMENT:
319 *(BOOL16 *) lpvParam = GetSystemMetrics( SM_MENUDROPALIGNMENT ); /* XXX check this */
322 case SPI_GETSCREENSAVEACTIVE:
323 if(USER_Driver->pGetScreenSaveActive() ||
324 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
325 *(BOOL16 *) lpvParam = TRUE;
327 *(BOOL16 *) lpvParam = FALSE;
330 case SPI_GETSCREENSAVETIMEOUT:
331 timeout = USER_Driver->pGetScreenSaveTimeout();
333 timeout = GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
334 *(INT16 *) lpvParam = timeout;
337 case SPI_ICONHORIZONTALSPACING:
338 /* FIXME Get/SetProfileInt */
339 if (lpvParam == NULL)
340 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
342 *(INT16 *)lpvParam = GetSystemMetrics( SM_CXICONSPACING );
345 case SPI_ICONVERTICALSPACING:
346 /* FIXME Get/SetProfileInt */
347 if (lpvParam == NULL)
348 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
350 *(INT16 *)lpvParam = GetSystemMetrics(SM_CYICONSPACING);
354 KEYBOARD_SetBeepActive(uParam);
357 case SPI_SETSCREENSAVEACTIVE:
358 USER_Driver->pSetScreenSaveActive(uParam);
361 case SPI_SETSCREENSAVETIMEOUT:
362 USER_Driver->pSetScreenSaveTimeout(uParam);
365 case SPI_SETDESKWALLPAPER:
366 return (SetDeskWallPaper((LPSTR) lpvParam));
369 case SPI_SETDESKPATTERN:
370 if ((INT16)uParam == -1) {
371 GetProfileStringA("Desktop", "Pattern",
372 "170 85 170 85 170 85 170 85",
373 buffer, sizeof(buffer) );
374 return (DESKTOP_SetPattern((LPSTR) buffer));
376 return (DESKTOP_SetPattern((LPSTR) lpvParam));
379 case SPI_GETICONTITLELOGFONT:
381 LPLOGFONT16 lpLogFont = (LPLOGFONT16)lpvParam;
382 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
383 lpLogFont->lfFaceName, LF_FACESIZE );
384 lpLogFont->lfHeight = -GetProfileIntA("Desktop","IconTitleSize", 13);
385 lpLogFont->lfWidth = 0;
386 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
387 lpLogFont->lfWeight = FW_NORMAL;
388 lpLogFont->lfItalic = FALSE;
389 lpLogFont->lfStrikeOut = FALSE;
390 lpLogFont->lfUnderline = FALSE;
391 lpLogFont->lfCharSet = ANSI_CHARSET;
392 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
393 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
394 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
397 case SPI_GETNONCLIENTMETRICS:
399 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
400 if( lpnm->cbSize == sizeof(NONCLIENTMETRICS16) )
402 /* clear the struct, so we have 'sane' members */
404 (char*)lpvParam+sizeof(lpnm->cbSize),
406 lpnm->cbSize-sizeof(lpnm->cbSize)
408 /* FIXME: initialize geometry entries */
409 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
410 (LPVOID)&(lpnm->lfCaptionFont),0);
411 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
412 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
413 (LPVOID)&(lpnm->lfSmCaptionFont),0);
414 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
415 (LPVOID)&(lpnm->lfMenuFont),0);
416 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
417 (LPVOID)&(lpnm->lfStatusFont),0);
418 SystemParametersInfo16( SPI_GETICONTITLELOGFONT, 0,
419 (LPVOID)&(lpnm->lfMessageFont),0);
421 else /* winfile 95 sets sbSize to 340 */
422 SystemParametersInfoA( uAction, uParam, lpvParam, fuWinIni );
428 case SPI_SETDOUBLECLKHEIGHT:
429 case SPI_SETDOUBLECLICKTIME:
430 case SPI_SETDOUBLECLKWIDTH:
431 case SPI_SETFASTTASKSWITCH:
432 case SPI_SETKEYBOARDDELAY:
433 case SPI_SETKEYBOARDSPEED:
434 WARN("Option %d ignored.\n", uAction);
437 case SPI_GETWORKAREA:
438 SetRect16( (RECT16 *)lpvParam, 0, 0,
439 GetSystemMetrics( SM_CXSCREEN ),
440 GetSystemMetrics( SM_CYSCREEN ) );
443 /* FIXME need to implement SPI_SETMOUSEHOVER... */
444 case SPI_GETMOUSEHOVERWIDTH:
445 *(INT16 *)lpvParam = 4;
448 case SPI_GETMOUSEHOVERHEIGHT:
449 *(INT16 *)lpvParam = 4;
452 case SPI_GETMOUSEHOVERTIME:
453 *(INT16 *)lpvParam = 400; /* default for menu dropdowns */
457 FIXME("Unknown option %d.\n", uAction);
458 SetLastError(ERROR_INVALID_SPI_VALUE);
464 /***********************************************************************
465 * SystemParametersInfoW (USER32.541)
467 BOOL WINAPI SystemParametersInfoW( UINT uAction, UINT uParam,
468 LPVOID lpvParam, UINT fuWinIni )
474 case SPI_SETDESKWALLPAPER:
477 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
478 return SetDeskWallPaper(buffer);
480 return SetDeskWallPaper(NULL);
482 case SPI_SETDESKPATTERN:
483 if ((INT) uParam == -1)
485 GetProfileStringA("Desktop", "Pattern",
486 "170 85 170 85 170 85 170 85",
487 buffer, sizeof(buffer) );
488 return (DESKTOP_SetPattern((LPSTR) buffer));
492 lstrcpynWtoA(buffer,(LPWSTR)lpvParam,sizeof(buffer));
493 return DESKTOP_SetPattern(buffer);
495 return DESKTOP_SetPattern(NULL);
497 case SPI_GETICONTITLELOGFONT:
499 LPLOGFONTW lpLogFont = (LPLOGFONTW)lpvParam;
501 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
502 buffer, sizeof(buffer) );
503 lstrcpynAtoW(lpLogFont->lfFaceName, buffer, LF_FACESIZE);
504 lpLogFont->lfHeight = 17;
505 lpLogFont->lfWidth = 0;
506 lpLogFont->lfEscapement = lpLogFont->lfOrientation = 0;
507 lpLogFont->lfWeight = FW_NORMAL;
508 lpLogFont->lfItalic = lpLogFont->lfStrikeOut = lpLogFont->lfUnderline = FALSE;
509 lpLogFont->lfCharSet = ANSI_CHARSET;
510 lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
511 lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
512 lpLogFont->lfPitchAndFamily = DEFAULT_PITCH | FF_SWISS;
515 case SPI_GETICONMETRICS: {
516 LPICONMETRICSW lpIcon = lpvParam;
517 if(!lpIcon || lpIcon->cbSize != sizeof(*lpIcon))
519 SystemParametersInfoW( SPI_ICONHORIZONTALSPACING, 0,
520 &lpIcon->iHorzSpacing, FALSE );
521 SystemParametersInfoW( SPI_ICONVERTICALSPACING, 0,
522 &lpIcon->iVertSpacing, FALSE );
523 SystemParametersInfoW( SPI_GETICONTITLEWRAP, 0,
524 &lpIcon->iTitleWrap, FALSE );
525 SystemParametersInfoW( SPI_GETICONTITLELOGFONT, 0,
526 &lpIcon->lfFont, FALSE );
529 case SPI_GETNONCLIENTMETRICS: {
530 /* FIXME: implement correctly */
531 LPNONCLIENTMETRICSW lpnm=(LPNONCLIENTMETRICSW)lpvParam;
533 /* clear the struct, so we have 'sane' members */
534 memset((char*)lpvParam+sizeof(lpnm->cbSize),
536 lpnm->cbSize-sizeof(lpnm->cbSize)
538 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfCaptionFont),0);
539 lpnm->lfCaptionFont.lfWeight = FW_BOLD;
540 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfSmCaptionFont),0);
541 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMenuFont),0);
542 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfStatusFont),0);
543 SystemParametersInfoW(SPI_GETICONTITLELOGFONT,0,(LPVOID)&(lpnm->lfMessageFont),0);
547 case SPI_GETHIGHCONTRAST:
549 LPHIGHCONTRASTW lpHighContrastW = (LPHIGHCONTRASTW)lpvParam;
551 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
553 if ( lpHighContrastW->cbSize == sizeof( HIGHCONTRASTW ) )
555 /* Indicate that there is no high contrast available */
556 lpHighContrastW->dwFlags = 0;
557 lpHighContrastW->lpszDefaultScheme = NULL;
568 return SystemParametersInfoA(uAction,uParam,lpvParam,fuWinIni);