2 * System parameters functions
4 * Copyright 1994 Alexandre Julliard
14 #include "wine/winuser16.h"
15 #include "wine/winestring.h"
22 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(system
);
26 /***********************************************************************
27 * GetTimerResolution (USER.14)
29 LONG WINAPI
GetTimerResolution16(void)
34 /***********************************************************************
35 * ControlPanelInfo16 (USER.273)
37 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
39 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
42 /***********************************************************************
43 * SystemParametersInfoA (USER32.540)
45 BOOL WINAPI
SystemParametersInfoA( UINT uAction
, UINT uParam
,
46 LPVOID lpvParam
, UINT fuWinIni
)
52 *(BOOL
*) lpvParam
= KEYBOARD_GetBeepActive();
55 KEYBOARD_SetBeepActive(uParam
);
59 *(INT
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
62 case SPI_GETDRAGFULLWINDOWS
:
63 *(BOOL
*) lpvParam
= FALSE
;
68 DWORD dwBufferSize
= sizeof(buffer
);
70 if(RegOpenKeyExA(HKEY_CURRENT_USER
,
71 "Control Panel\\desktop",
72 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
) {
73 if(RegQueryValueExA(hKey
, "DragFullWindows", NULL
,
74 0, buffer
, &dwBufferSize
) == ERROR_SUCCESS
)
75 *(BOOL
*)lpvParam
= atoi(buffer
) != 0;
82 case SPI_SETDRAGFULLWINDOWS
:
85 case SPI_GETFASTTASKSWITCH
:
86 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
87 *(BOOL
*) lpvParam
= TRUE
;
89 *(BOOL
*) lpvParam
= FALSE
;
92 case SPI_GETGRIDGRANULARITY
:
93 *(INT
*)lpvParam
=GetProfileIntA("desktop","GridGranularity",1);
96 case SPI_GETICONTITLEWRAP
:
97 *(BOOL
*)lpvParam
=GetProfileIntA("desktop","IconTitleWrap",TRUE
);
100 case SPI_GETKEYBOARDDELAY
:
101 *(INT
*)lpvParam
=GetProfileIntA("keyboard","KeyboardDelay",1);
104 case SPI_GETKEYBOARDSPEED
:
105 *(DWORD
*)lpvParam
=GetProfileIntA("keyboard","KeyboardSpeed",30);
108 case SPI_GETMENUDROPALIGNMENT
:
109 *(BOOL
*)lpvParam
=GetSystemMetrics(SM_MENUDROPALIGNMENT
); /* XXX check this */
112 case SPI_GETSCREENSAVEACTIVE
:
113 if(USER_Driver
.pGetScreenSaveActive() ||
114 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
115 *(BOOL
*)lpvParam
= TRUE
;
117 *(BOOL
*)lpvParam
= FALSE
;
120 case SPI_GETSCREENSAVETIMEOUT
:
121 timeout
= USER_Driver
.pGetScreenSaveTimeout();
123 timeout
= GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
124 *(INT
*) lpvParam
= timeout
* 1000;
127 case SPI_ICONHORIZONTALSPACING
:
128 /* FIXME Get/SetProfileInt */
129 if (lpvParam
== NULL
)
130 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
132 *(INT
*)lpvParam
=GetSystemMetrics(SM_CXICONSPACING
);
135 case SPI_ICONVERTICALSPACING
:
136 /* FIXME Get/SetProfileInt */
137 if (lpvParam
== NULL
)
138 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
140 *(INT
*)lpvParam
=GetSystemMetrics(SM_CYICONSPACING
);
143 case SPI_GETICONTITLELOGFONT
: {
144 LPLOGFONTA lpLogFont
= (LPLOGFONTA
)lpvParam
;
146 /* from now on we always have an alias for MS Sans Serif */
148 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
149 lpLogFont
->lfFaceName
, LF_FACESIZE
);
150 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","IconTitleSize", 13);
151 lpLogFont
->lfWidth
= 0;
152 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
153 lpLogFont
->lfWeight
= FW_NORMAL
;
154 lpLogFont
->lfItalic
= FALSE
;
155 lpLogFont
->lfStrikeOut
= FALSE
;
156 lpLogFont
->lfUnderline
= FALSE
;
157 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
158 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
159 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
160 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
164 case SPI_GETICONMETRICS
: {
165 LPICONMETRICSA lpIcon
= lpvParam
;
166 if(!lpIcon
|| lpIcon
->cbSize
!= sizeof(*lpIcon
))
168 SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0,
169 &lpIcon
->iHorzSpacing
, FALSE
);
170 SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0,
171 &lpIcon
->iVertSpacing
, FALSE
);
172 SystemParametersInfoA( SPI_GETICONTITLEWRAP
, 0,
173 &lpIcon
->iTitleWrap
, FALSE
);
174 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0,
175 &lpIcon
->lfFont
, FALSE
);
178 case SPI_GETWORKAREA
:
179 SetRect( (RECT
*)lpvParam
, 0, 0,
180 GetSystemMetrics( SM_CXSCREEN
),
181 GetSystemMetrics( SM_CYSCREEN
)
184 case SPI_GETNONCLIENTMETRICS
:
186 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
188 if (lpnm
->cbSize
== sizeof(NONCLIENTMETRICSA
))
190 LPLOGFONTA lpLogFont
= &(lpnm
->lfMenuFont
);
192 /* clear the struct, so we have 'sane' members */
194 (char*)lpvParam
+sizeof(lpnm
->cbSize
),
196 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
199 /* FIXME: initialize geometry entries */
200 /* FIXME: As these values are presumably in device units,
201 * we should calculate the defaults based on the screen dpi
204 lpnm
->iCaptionWidth
= ((TWEAK_WineLook
> WIN31_LOOK
) ? 32 : 20);
205 lpnm
->iCaptionHeight
= lpnm
->iCaptionWidth
;
206 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
207 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0, (LPVOID
)&(lpnm
->lfCaptionFont
),0);
210 lpnm
->iSmCaptionWidth
= ((TWEAK_WineLook
> WIN31_LOOK
) ? 32 : 17);
211 lpnm
->iSmCaptionHeight
= lpnm
->iSmCaptionWidth
;
212 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0, (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
214 /* menus, FIXME: names of wine.conf entrys are bogus */
216 lpnm
->iMenuWidth
= GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/
217 lpnm
->iMenuHeight
= GetProfileIntA("Desktop","MenuHeight",
218 (TWEAK_WineLook
> WIN31_LOOK
) ? 13 : 27);
220 GetProfileStringA("Desktop", "MenuFont",
221 (TWEAK_WineLook
> WIN31_LOOK
) ? "MS Sans Serif": "System",
222 lpLogFont
->lfFaceName
, LF_FACESIZE
);
224 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","MenuFontSize", 13);
225 lpLogFont
->lfWidth
= 0;
226 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
227 lpLogFont
->lfWeight
= (TWEAK_WineLook
> WIN31_LOOK
) ? FW_NORMAL
: FW_BOLD
;
228 lpLogFont
->lfItalic
= FALSE
;
229 lpLogFont
->lfStrikeOut
= FALSE
;
230 lpLogFont
->lfUnderline
= FALSE
;
231 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
232 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
233 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
234 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
236 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0,
237 (LPVOID
)&(lpnm
->lfStatusFont
),0);
238 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0,
239 (LPVOID
)&(lpnm
->lfMessageFont
),0);
243 WARN("size mismatch !! (is %d; should be %d)\n", lpnm
->cbSize
, sizeof(NONCLIENTMETRICSA
));
249 case SPI_GETANIMATION
: {
250 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
252 /* Tell it "disabled" */
253 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
254 uParam
= sizeof(ANIMATIONINFO
);
255 lpAnimInfo
->iMinAnimate
= 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
259 case SPI_SETANIMATION
: {
260 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
263 WARN("SPI_SETANIMATION ignored.\n");
264 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
265 uParam
= sizeof(ANIMATIONINFO
);
269 case SPI_GETHIGHCONTRAST
:
271 LPHIGHCONTRASTA lpHighContrastA
= (LPHIGHCONTRASTA
)lpvParam
;
273 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
275 if ( lpHighContrastA
->cbSize
== sizeof( HIGHCONTRASTA
) )
277 /* Indicate that there is no high contrast available */
278 lpHighContrastA
->dwFlags
= 0;
279 lpHighContrastA
->lpszDefaultScheme
= NULL
;
290 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
296 /***********************************************************************
297 * SystemParametersInfo16 (USER.483)
299 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
300 LPVOID lpvParam
, UINT16 fuWinIni
)
308 *(BOOL
*) lpvParam
= KEYBOARD_GetBeepActive();
312 *(INT16
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
315 case SPI_GETFASTTASKSWITCH
:
316 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
317 *(BOOL16
*) lpvParam
= TRUE
;
319 *(BOOL16
*) lpvParam
= FALSE
;
322 case SPI_GETGRIDGRANULARITY
:
323 *(INT16
*) lpvParam
= GetProfileIntA( "desktop",
328 case SPI_GETICONTITLEWRAP
:
329 *(BOOL16
*) lpvParam
= GetProfileIntA( "desktop",
334 case SPI_GETKEYBOARDDELAY
:
335 *(INT16
*) lpvParam
= GetProfileIntA( "keyboard",
336 "KeyboardDelay", 1 );
339 case SPI_GETKEYBOARDSPEED
:
340 *(WORD
*) lpvParam
= GetProfileIntA( "keyboard",
345 case SPI_GETMENUDROPALIGNMENT
:
346 *(BOOL16
*) lpvParam
= GetSystemMetrics( SM_MENUDROPALIGNMENT
); /* XXX check this */
349 case SPI_GETSCREENSAVEACTIVE
:
350 if(USER_Driver
.pGetScreenSaveActive() ||
351 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
352 *(BOOL16
*) lpvParam
= TRUE
;
354 *(BOOL16
*) lpvParam
= FALSE
;
357 case SPI_GETSCREENSAVETIMEOUT
:
358 timeout
= USER_Driver
.pGetScreenSaveTimeout();
360 timeout
= GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
361 *(INT16
*) lpvParam
= timeout
;
364 case SPI_ICONHORIZONTALSPACING
:
365 /* FIXME Get/SetProfileInt */
366 if (lpvParam
== NULL
)
367 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
369 *(INT16
*)lpvParam
= GetSystemMetrics( SM_CXICONSPACING
);
372 case SPI_ICONVERTICALSPACING
:
373 /* FIXME Get/SetProfileInt */
374 if (lpvParam
== NULL
)
375 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
377 *(INT16
*)lpvParam
= GetSystemMetrics(SM_CYICONSPACING
);
381 KEYBOARD_SetBeepActive(uParam
);
384 case SPI_SETSCREENSAVEACTIVE
:
385 USER_Driver
.pSetScreenSaveActive(uParam
);
388 case SPI_SETSCREENSAVETIMEOUT
:
389 USER_Driver
.pSetScreenSaveTimeout(uParam
);
392 case SPI_SETDESKWALLPAPER
:
393 return (SetDeskWallPaper((LPSTR
) lpvParam
));
396 case SPI_SETDESKPATTERN
:
397 if ((INT16
)uParam
== -1) {
398 GetProfileStringA("Desktop", "Pattern",
399 "170 85 170 85 170 85 170 85",
400 buffer
, sizeof(buffer
) );
401 return (DESKTOP_SetPattern((LPSTR
) buffer
));
403 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
406 case SPI_GETICONTITLELOGFONT
:
408 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
409 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
410 lpLogFont
->lfFaceName
, LF_FACESIZE
);
411 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","IconTitleSize", 13);
412 lpLogFont
->lfWidth
= 0;
413 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
414 lpLogFont
->lfWeight
= FW_NORMAL
;
415 lpLogFont
->lfItalic
= FALSE
;
416 lpLogFont
->lfStrikeOut
= FALSE
;
417 lpLogFont
->lfUnderline
= FALSE
;
418 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
419 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
420 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
421 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
424 case SPI_GETNONCLIENTMETRICS
:
426 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
427 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS16
) )
429 /* clear the struct, so we have 'sane' members */
431 (char*)lpvParam
+sizeof(lpnm
->cbSize
),
433 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
435 /* FIXME: initialize geometry entries */
436 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
437 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
438 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
439 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
440 (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
441 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
442 (LPVOID
)&(lpnm
->lfMenuFont
),0);
443 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
444 (LPVOID
)&(lpnm
->lfStatusFont
),0);
445 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
446 (LPVOID
)&(lpnm
->lfMessageFont
),0);
448 else /* winfile 95 sets sbSize to 340 */
449 SystemParametersInfoA( uAction
, uParam
, lpvParam
, fuWinIni
);
455 case SPI_SETDOUBLECLKHEIGHT
:
456 case SPI_SETDOUBLECLICKTIME
:
457 case SPI_SETDOUBLECLKWIDTH
:
458 case SPI_SETFASTTASKSWITCH
:
459 case SPI_SETKEYBOARDDELAY
:
460 case SPI_SETKEYBOARDSPEED
:
461 WARN("Option %d ignored.\n", uAction
);
464 case SPI_GETWINDOWSEXTENSION
:
465 WARN("pretend no support for Win9x Plus! for now.\n");
466 return FALSE
; /* yes, this is the result value */
468 case SPI_GETWORKAREA
:
469 SetRect16( (RECT16
*)lpvParam
, 0, 0,
470 GetSystemMetrics( SM_CXSCREEN
),
471 GetSystemMetrics( SM_CYSCREEN
) );
474 /* FIXME need to implement SPI_SETMOUSEHOVER... */
475 case SPI_GETMOUSEHOVERWIDTH
:
476 *(INT16
*)lpvParam
= 4;
479 case SPI_GETMOUSEHOVERHEIGHT
:
480 *(INT16
*)lpvParam
= 4;
483 case SPI_GETMOUSEHOVERTIME
:
484 *(INT16
*)lpvParam
= 400; /* default for menu dropdowns */
488 FIXME("Unknown option %d.\n", uAction
);
489 SetLastError(ERROR_INVALID_SPI_VALUE
);
495 /***********************************************************************
496 * SystemParametersInfoW (USER32.541)
498 BOOL WINAPI
SystemParametersInfoW( UINT uAction
, UINT uParam
,
499 LPVOID lpvParam
, UINT fuWinIni
)
505 case SPI_SETDESKWALLPAPER
:
508 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
509 return SetDeskWallPaper(buffer
);
511 return SetDeskWallPaper(NULL
);
513 case SPI_SETDESKPATTERN
:
514 if ((INT
) uParam
== -1)
516 GetProfileStringA("Desktop", "Pattern",
517 "170 85 170 85 170 85 170 85",
518 buffer
, sizeof(buffer
) );
519 return (DESKTOP_SetPattern((LPSTR
) buffer
));
523 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
524 return DESKTOP_SetPattern(buffer
);
526 return DESKTOP_SetPattern(NULL
);
528 case SPI_GETICONTITLELOGFONT
:
530 LPLOGFONTW lpLogFont
= (LPLOGFONTW
)lpvParam
;
532 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
533 buffer
, sizeof(buffer
) );
534 lstrcpynAtoW(lpLogFont
->lfFaceName
, buffer
, LF_FACESIZE
);
535 lpLogFont
->lfHeight
= 17;
536 lpLogFont
->lfWidth
= 0;
537 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
538 lpLogFont
->lfWeight
= FW_NORMAL
;
539 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
540 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
541 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
542 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
543 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
546 case SPI_GETICONMETRICS
: {
547 LPICONMETRICSW lpIcon
= lpvParam
;
548 if(!lpIcon
|| lpIcon
->cbSize
!= sizeof(*lpIcon
))
550 SystemParametersInfoW( SPI_ICONHORIZONTALSPACING
, 0,
551 &lpIcon
->iHorzSpacing
, FALSE
);
552 SystemParametersInfoW( SPI_ICONVERTICALSPACING
, 0,
553 &lpIcon
->iVertSpacing
, FALSE
);
554 SystemParametersInfoW( SPI_GETICONTITLEWRAP
, 0,
555 &lpIcon
->iTitleWrap
, FALSE
);
556 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0,
557 &lpIcon
->lfFont
, FALSE
);
560 case SPI_GETNONCLIENTMETRICS
: {
561 /* FIXME: implement correctly */
562 LPNONCLIENTMETRICSW lpnm
=(LPNONCLIENTMETRICSW
)lpvParam
;
564 /* clear the struct, so we have 'sane' members */
565 memset((char*)lpvParam
+sizeof(lpnm
->cbSize
),
567 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
569 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
570 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
571 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
572 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
573 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
574 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
578 case SPI_GETHIGHCONTRAST
:
580 LPHIGHCONTRASTW lpHighContrastW
= (LPHIGHCONTRASTW
)lpvParam
;
582 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
584 if ( lpHighContrastW
->cbSize
== sizeof( HIGHCONTRASTW
) )
586 /* Indicate that there is no high contrast available */
587 lpHighContrastW
->dwFlags
= 0;
588 lpHighContrastW
->lpszDefaultScheme
= NULL
;
599 return SystemParametersInfoA(uAction
,uParam
,lpvParam
,fuWinIni
);