2 * System parameters functions
4 * Copyright 1994 Alexandre Julliard
14 #include "wine/winuser16.h"
21 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(system
);
25 /***********************************************************************
26 * GetTimerResolution (USER.14)
28 LONG WINAPI
GetTimerResolution16(void)
33 /***********************************************************************
34 * ControlPanelInfo16 (USER.273)
36 void WINAPI
ControlPanelInfo16( INT16 nInfoType
, WORD wData
, LPSTR lpBuffer
)
38 FIXME("(%d, %04x, %p): stub.\n", nInfoType
, wData
, lpBuffer
);
41 /***********************************************************************
42 * SystemParametersInfoA (USER32.540)
44 BOOL WINAPI
SystemParametersInfoA( UINT uAction
, UINT uParam
,
45 LPVOID lpvParam
, UINT fuWinIni
)
51 *(BOOL
*) lpvParam
= KEYBOARD_GetBeepActive();
54 KEYBOARD_SetBeepActive(uParam
);
58 *(INT
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
61 case SPI_GETDRAGFULLWINDOWS
:
62 *(BOOL
*) lpvParam
= FALSE
;
67 DWORD dwBufferSize
= sizeof(buffer
);
69 if(RegOpenKeyExA(HKEY_CURRENT_USER
,
70 "Control Panel\\desktop",
71 0, KEY_QUERY_VALUE
, &hKey
) == ERROR_SUCCESS
) {
72 if(RegQueryValueExA(hKey
, "DragFullWindows", NULL
,
73 0, buffer
, &dwBufferSize
) == ERROR_SUCCESS
)
74 *(BOOL
*)lpvParam
= atoi(buffer
) != 0;
81 case SPI_SETDRAGFULLWINDOWS
:
84 case SPI_GETFASTTASKSWITCH
:
85 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
86 *(BOOL
*) lpvParam
= TRUE
;
88 *(BOOL
*) lpvParam
= FALSE
;
91 case SPI_GETGRIDGRANULARITY
:
92 *(INT
*)lpvParam
=GetProfileIntA("desktop","GridGranularity",1);
95 case SPI_GETICONTITLEWRAP
:
96 *(BOOL
*)lpvParam
=GetProfileIntA("desktop","IconTitleWrap",TRUE
);
99 case SPI_GETKEYBOARDDELAY
:
100 *(INT
*)lpvParam
=GetProfileIntA("keyboard","KeyboardDelay",1);
103 case SPI_GETKEYBOARDSPEED
:
104 *(DWORD
*)lpvParam
=GetProfileIntA("keyboard","KeyboardSpeed",30);
107 case SPI_GETMENUDROPALIGNMENT
:
108 *(BOOL
*)lpvParam
=GetSystemMetrics(SM_MENUDROPALIGNMENT
); /* XXX check this */
111 case SPI_GETSCREENSAVEACTIVE
:
112 if(USER_Driver
.pGetScreenSaveActive() ||
113 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
114 *(BOOL
*)lpvParam
= TRUE
;
116 *(BOOL
*)lpvParam
= FALSE
;
119 case SPI_GETSCREENSAVETIMEOUT
:
120 timeout
= USER_Driver
.pGetScreenSaveTimeout();
122 timeout
= GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
123 *(INT
*) lpvParam
= timeout
* 1000;
126 case SPI_ICONHORIZONTALSPACING
:
127 /* FIXME Get/SetProfileInt */
128 if (lpvParam
== NULL
)
129 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
131 *(INT
*)lpvParam
=GetSystemMetrics(SM_CXICONSPACING
);
134 case SPI_ICONVERTICALSPACING
:
135 /* FIXME Get/SetProfileInt */
136 if (lpvParam
== NULL
)
137 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
139 *(INT
*)lpvParam
=GetSystemMetrics(SM_CYICONSPACING
);
142 case SPI_GETICONTITLELOGFONT
: {
143 LPLOGFONTA lpLogFont
= (LPLOGFONTA
)lpvParam
;
145 /* from now on we always have an alias for MS Sans Serif */
147 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
148 lpLogFont
->lfFaceName
, LF_FACESIZE
);
149 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","IconTitleSize", 13);
150 lpLogFont
->lfWidth
= 0;
151 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
152 lpLogFont
->lfWeight
= FW_NORMAL
;
153 lpLogFont
->lfItalic
= FALSE
;
154 lpLogFont
->lfStrikeOut
= FALSE
;
155 lpLogFont
->lfUnderline
= FALSE
;
156 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
157 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
158 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
159 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
163 case SPI_GETICONMETRICS
: {
164 LPICONMETRICSA lpIcon
= lpvParam
;
165 if(!lpIcon
|| lpIcon
->cbSize
!= sizeof(*lpIcon
))
167 SystemParametersInfoA( SPI_ICONHORIZONTALSPACING
, 0,
168 &lpIcon
->iHorzSpacing
, FALSE
);
169 SystemParametersInfoA( SPI_ICONVERTICALSPACING
, 0,
170 &lpIcon
->iVertSpacing
, FALSE
);
171 SystemParametersInfoA( SPI_GETICONTITLEWRAP
, 0,
172 &lpIcon
->iTitleWrap
, FALSE
);
173 SystemParametersInfoA( SPI_GETICONTITLELOGFONT
, 0,
174 &lpIcon
->lfFont
, FALSE
);
177 case SPI_GETWORKAREA
:
178 SetRect( (RECT
*)lpvParam
, 0, 0,
179 GetSystemMetrics( SM_CXSCREEN
),
180 GetSystemMetrics( SM_CYSCREEN
)
183 case SPI_GETNONCLIENTMETRICS
:
185 #define lpnm ((LPNONCLIENTMETRICSA)lpvParam)
187 if (lpnm
->cbSize
== sizeof(NONCLIENTMETRICSA
))
189 LPLOGFONTA lpLogFont
= &(lpnm
->lfMenuFont
);
191 /* clear the struct, so we have 'sane' members */
193 (char*)lpvParam
+sizeof(lpnm
->cbSize
),
195 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
198 /* FIXME: initialize geometry entries */
199 /* FIXME: As these values are presumably in device units,
200 * we should calculate the defaults based on the screen dpi
203 lpnm
->iCaptionWidth
= ((TWEAK_WineLook
> WIN31_LOOK
) ? 32 : 20);
204 lpnm
->iCaptionHeight
= lpnm
->iCaptionWidth
;
205 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
206 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0, (LPVOID
)&(lpnm
->lfCaptionFont
),0);
209 lpnm
->iSmCaptionWidth
= ((TWEAK_WineLook
> WIN31_LOOK
) ? 32 : 17);
210 lpnm
->iSmCaptionHeight
= lpnm
->iSmCaptionWidth
;
211 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0, (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
213 /* menus, FIXME: names of wine.conf entrys are bogus */
215 lpnm
->iMenuWidth
= GetProfileIntA("Desktop","MenuWidth", 13); /* size of the menu buttons*/
216 lpnm
->iMenuHeight
= GetProfileIntA("Desktop","MenuHeight",
217 (TWEAK_WineLook
> WIN31_LOOK
) ? 13 : 27);
219 GetProfileStringA("Desktop", "MenuFont",
220 (TWEAK_WineLook
> WIN31_LOOK
) ? "MS Sans Serif": "System",
221 lpLogFont
->lfFaceName
, LF_FACESIZE
);
223 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","MenuFontSize", 13);
224 lpLogFont
->lfWidth
= 0;
225 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
226 lpLogFont
->lfWeight
= (TWEAK_WineLook
> WIN31_LOOK
) ? FW_NORMAL
: FW_BOLD
;
227 lpLogFont
->lfItalic
= FALSE
;
228 lpLogFont
->lfStrikeOut
= FALSE
;
229 lpLogFont
->lfUnderline
= FALSE
;
230 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
231 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
232 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
233 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
235 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0,
236 (LPVOID
)&(lpnm
->lfStatusFont
),0);
237 SystemParametersInfoA(SPI_GETICONTITLELOGFONT
, 0,
238 (LPVOID
)&(lpnm
->lfMessageFont
),0);
242 WARN("size mismatch !! (is %d; should be %d)\n", lpnm
->cbSize
, sizeof(NONCLIENTMETRICSA
));
248 case SPI_GETANIMATION
: {
249 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
251 /* Tell it "disabled" */
252 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
253 uParam
= sizeof(ANIMATIONINFO
);
254 lpAnimInfo
->iMinAnimate
= 0; /* Minimise and restore animation is disabled (nonzero == enabled) */
258 case SPI_SETANIMATION
: {
259 LPANIMATIONINFO lpAnimInfo
= (LPANIMATIONINFO
)lpvParam
;
262 WARN("SPI_SETANIMATION ignored.\n");
263 lpAnimInfo
->cbSize
= sizeof(ANIMATIONINFO
);
264 uParam
= sizeof(ANIMATIONINFO
);
268 case SPI_GETHIGHCONTRAST
:
270 LPHIGHCONTRASTA lpHighContrastA
= (LPHIGHCONTRASTA
)lpvParam
;
272 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
274 if ( lpHighContrastA
->cbSize
== sizeof( HIGHCONTRASTA
) )
276 /* Indicate that there is no high contrast available */
277 lpHighContrastA
->dwFlags
= 0;
278 lpHighContrastA
->lpszDefaultScheme
= NULL
;
289 return SystemParametersInfo16(uAction
,uParam
,lpvParam
,fuWinIni
);
295 /***********************************************************************
296 * SystemParametersInfo16 (USER.483)
298 BOOL16 WINAPI
SystemParametersInfo16( UINT16 uAction
, UINT16 uParam
,
299 LPVOID lpvParam
, UINT16 fuWinIni
)
307 *(BOOL
*) lpvParam
= KEYBOARD_GetBeepActive();
311 *(INT16
*)lpvParam
= GetSystemMetrics( SM_CXFRAME
);
314 case SPI_GETFASTTASKSWITCH
:
315 if ( GetProfileIntA( "windows", "CoolSwitch", 1 ) == 1 )
316 *(BOOL16
*) lpvParam
= TRUE
;
318 *(BOOL16
*) lpvParam
= FALSE
;
321 case SPI_GETGRIDGRANULARITY
:
322 *(INT16
*) lpvParam
= GetProfileIntA( "desktop",
327 case SPI_GETICONTITLEWRAP
:
328 *(BOOL16
*) lpvParam
= GetProfileIntA( "desktop",
333 case SPI_GETKEYBOARDDELAY
:
334 *(INT16
*) lpvParam
= GetProfileIntA( "keyboard",
335 "KeyboardDelay", 1 );
338 case SPI_GETKEYBOARDSPEED
:
339 *(WORD
*) lpvParam
= GetProfileIntA( "keyboard",
344 case SPI_GETMENUDROPALIGNMENT
:
345 *(BOOL16
*) lpvParam
= GetSystemMetrics( SM_MENUDROPALIGNMENT
); /* XXX check this */
348 case SPI_GETSCREENSAVEACTIVE
:
349 if(USER_Driver
.pGetScreenSaveActive() ||
350 GetProfileIntA( "windows", "ScreenSaveActive", 1 ) == 1)
351 *(BOOL16
*) lpvParam
= TRUE
;
353 *(BOOL16
*) lpvParam
= FALSE
;
356 case SPI_GETSCREENSAVETIMEOUT
:
357 timeout
= USER_Driver
.pGetScreenSaveTimeout();
359 timeout
= GetProfileIntA( "windows", "ScreenSaveTimeout", 300 );
360 *(INT16
*) lpvParam
= timeout
;
363 case SPI_ICONHORIZONTALSPACING
:
364 /* FIXME Get/SetProfileInt */
365 if (lpvParam
== NULL
)
366 /*SetSystemMetrics( SM_CXICONSPACING, uParam )*/ ;
368 *(INT16
*)lpvParam
= GetSystemMetrics( SM_CXICONSPACING
);
371 case SPI_ICONVERTICALSPACING
:
372 /* FIXME Get/SetProfileInt */
373 if (lpvParam
== NULL
)
374 /*SetSystemMetrics( SM_CYICONSPACING, uParam )*/ ;
376 *(INT16
*)lpvParam
= GetSystemMetrics(SM_CYICONSPACING
);
380 KEYBOARD_SetBeepActive(uParam
);
383 case SPI_SETSCREENSAVEACTIVE
:
384 USER_Driver
.pSetScreenSaveActive(uParam
);
387 case SPI_SETSCREENSAVETIMEOUT
:
388 USER_Driver
.pSetScreenSaveTimeout(uParam
);
391 case SPI_SETDESKWALLPAPER
:
392 return (SetDeskWallPaper((LPSTR
) lpvParam
));
395 case SPI_SETDESKPATTERN
:
396 if ((INT16
)uParam
== -1) {
397 GetProfileStringA("Desktop", "Pattern",
398 "170 85 170 85 170 85 170 85",
399 buffer
, sizeof(buffer
) );
400 return (DESKTOP_SetPattern((LPSTR
) buffer
));
402 return (DESKTOP_SetPattern((LPSTR
) lpvParam
));
405 case SPI_GETICONTITLELOGFONT
:
407 LPLOGFONT16 lpLogFont
= (LPLOGFONT16
)lpvParam
;
408 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
409 lpLogFont
->lfFaceName
, LF_FACESIZE
);
410 lpLogFont
->lfHeight
= -GetProfileIntA("Desktop","IconTitleSize", 13);
411 lpLogFont
->lfWidth
= 0;
412 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
413 lpLogFont
->lfWeight
= FW_NORMAL
;
414 lpLogFont
->lfItalic
= FALSE
;
415 lpLogFont
->lfStrikeOut
= FALSE
;
416 lpLogFont
->lfUnderline
= FALSE
;
417 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
418 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
419 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
420 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
423 case SPI_GETNONCLIENTMETRICS
:
425 #define lpnm ((LPNONCLIENTMETRICS16)lpvParam)
426 if( lpnm
->cbSize
== sizeof(NONCLIENTMETRICS16
) )
428 /* clear the struct, so we have 'sane' members */
430 (char*)lpvParam
+sizeof(lpnm
->cbSize
),
432 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
434 /* FIXME: initialize geometry entries */
435 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
436 (LPVOID
)&(lpnm
->lfCaptionFont
),0);
437 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
438 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
439 (LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
440 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
441 (LPVOID
)&(lpnm
->lfMenuFont
),0);
442 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
443 (LPVOID
)&(lpnm
->lfStatusFont
),0);
444 SystemParametersInfo16( SPI_GETICONTITLELOGFONT
, 0,
445 (LPVOID
)&(lpnm
->lfMessageFont
),0);
447 else /* winfile 95 sets sbSize to 340 */
448 SystemParametersInfoA( uAction
, uParam
, lpvParam
, fuWinIni
);
454 case SPI_SETDOUBLECLKHEIGHT
:
455 case SPI_SETDOUBLECLICKTIME
:
456 case SPI_SETDOUBLECLKWIDTH
:
457 case SPI_SETFASTTASKSWITCH
:
458 case SPI_SETKEYBOARDDELAY
:
459 case SPI_SETKEYBOARDSPEED
:
460 WARN("Option %d ignored.\n", uAction
);
463 case SPI_GETWORKAREA
:
464 SetRect16( (RECT16
*)lpvParam
, 0, 0,
465 GetSystemMetrics( SM_CXSCREEN
),
466 GetSystemMetrics( SM_CYSCREEN
) );
469 /* FIXME need to implement SPI_SETMOUSEHOVER... */
470 case SPI_GETMOUSEHOVERWIDTH
:
471 *(INT16
*)lpvParam
= 4;
474 case SPI_GETMOUSEHOVERHEIGHT
:
475 *(INT16
*)lpvParam
= 4;
478 case SPI_GETMOUSEHOVERTIME
:
479 *(INT16
*)lpvParam
= 400; /* default for menu dropdowns */
483 FIXME("Unknown option %d.\n", uAction
);
484 SetLastError(ERROR_INVALID_SPI_VALUE
);
490 /***********************************************************************
491 * SystemParametersInfoW (USER32.541)
493 BOOL WINAPI
SystemParametersInfoW( UINT uAction
, UINT uParam
,
494 LPVOID lpvParam
, UINT fuWinIni
)
500 case SPI_SETDESKWALLPAPER
:
503 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
504 return SetDeskWallPaper(buffer
);
506 return SetDeskWallPaper(NULL
);
508 case SPI_SETDESKPATTERN
:
509 if ((INT
) uParam
== -1)
511 GetProfileStringA("Desktop", "Pattern",
512 "170 85 170 85 170 85 170 85",
513 buffer
, sizeof(buffer
) );
514 return (DESKTOP_SetPattern((LPSTR
) buffer
));
518 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
519 return DESKTOP_SetPattern(buffer
);
521 return DESKTOP_SetPattern(NULL
);
523 case SPI_GETICONTITLELOGFONT
:
525 LPLOGFONTW lpLogFont
= (LPLOGFONTW
)lpvParam
;
527 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
528 buffer
, sizeof(buffer
) );
529 lstrcpynAtoW(lpLogFont
->lfFaceName
, buffer
, LF_FACESIZE
);
530 lpLogFont
->lfHeight
= 17;
531 lpLogFont
->lfWidth
= 0;
532 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
533 lpLogFont
->lfWeight
= FW_NORMAL
;
534 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
535 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
536 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
537 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
538 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
541 case SPI_GETICONMETRICS
: {
542 LPICONMETRICSW lpIcon
= lpvParam
;
543 if(!lpIcon
|| lpIcon
->cbSize
!= sizeof(*lpIcon
))
545 SystemParametersInfoW( SPI_ICONHORIZONTALSPACING
, 0,
546 &lpIcon
->iHorzSpacing
, FALSE
);
547 SystemParametersInfoW( SPI_ICONVERTICALSPACING
, 0,
548 &lpIcon
->iVertSpacing
, FALSE
);
549 SystemParametersInfoW( SPI_GETICONTITLEWRAP
, 0,
550 &lpIcon
->iTitleWrap
, FALSE
);
551 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0,
552 &lpIcon
->lfFont
, FALSE
);
555 case SPI_GETNONCLIENTMETRICS
: {
556 /* FIXME: implement correctly */
557 LPNONCLIENTMETRICSW lpnm
=(LPNONCLIENTMETRICSW
)lpvParam
;
559 /* clear the struct, so we have 'sane' members */
560 memset((char*)lpvParam
+sizeof(lpnm
->cbSize
),
562 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
564 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
565 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
566 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
567 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
568 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
569 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
573 case SPI_GETHIGHCONTRAST
:
575 LPHIGHCONTRASTW lpHighContrastW
= (LPHIGHCONTRASTW
)lpvParam
;
577 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
579 if ( lpHighContrastW
->cbSize
== sizeof( HIGHCONTRASTW
) )
581 /* Indicate that there is no high contrast available */
582 lpHighContrastW
->dwFlags
= 0;
583 lpHighContrastW
->lpszDefaultScheme
= NULL
;
594 return SystemParametersInfoA(uAction
,uParam
,lpvParam
,fuWinIni
);