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(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
) );
444 FIXME("Unknown option %d.\n", uAction
);
445 SetLastError(ERROR_INVALID_SPI_VALUE
);
451 /***********************************************************************
452 * SystemParametersInfo32W (USER32.541)
454 BOOL WINAPI
SystemParametersInfoW( UINT uAction
, UINT uParam
,
455 LPVOID lpvParam
, UINT fuWinIni
)
461 case SPI_SETDESKWALLPAPER
:
464 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
465 return SetDeskWallPaper(buffer
);
467 return SetDeskWallPaper(NULL
);
469 case SPI_SETDESKPATTERN
:
470 if ((INT
) uParam
== -1)
472 GetProfileStringA("Desktop", "Pattern",
473 "170 85 170 85 170 85 170 85",
474 buffer
, sizeof(buffer
) );
475 return (DESKTOP_SetPattern((LPSTR
) buffer
));
479 lstrcpynWtoA(buffer
,(LPWSTR
)lpvParam
,sizeof(buffer
));
480 return DESKTOP_SetPattern(buffer
);
482 return DESKTOP_SetPattern(NULL
);
484 case SPI_GETICONTITLELOGFONT
:
486 LPLOGFONTW lpLogFont
= (LPLOGFONTW
)lpvParam
;
488 GetProfileStringA("Desktop", "IconTitleFaceName", "MS Sans Serif",
489 buffer
, sizeof(buffer
) );
490 lstrcpynAtoW(lpLogFont
->lfFaceName
, buffer
, LF_FACESIZE
);
491 lpLogFont
->lfHeight
= 17;
492 lpLogFont
->lfWidth
= 0;
493 lpLogFont
->lfEscapement
= lpLogFont
->lfOrientation
= 0;
494 lpLogFont
->lfWeight
= FW_NORMAL
;
495 lpLogFont
->lfItalic
= lpLogFont
->lfStrikeOut
= lpLogFont
->lfUnderline
= FALSE
;
496 lpLogFont
->lfCharSet
= ANSI_CHARSET
;
497 lpLogFont
->lfOutPrecision
= OUT_DEFAULT_PRECIS
;
498 lpLogFont
->lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
499 lpLogFont
->lfPitchAndFamily
= DEFAULT_PITCH
| FF_SWISS
;
502 case SPI_GETICONMETRICS
: {
503 LPICONMETRICSW lpIcon
= lpvParam
;
504 if(!lpIcon
|| lpIcon
->cbSize
!= sizeof(*lpIcon
))
506 SystemParametersInfoW( SPI_ICONHORIZONTALSPACING
, 0,
507 &lpIcon
->iHorzSpacing
, FALSE
);
508 SystemParametersInfoW( SPI_ICONVERTICALSPACING
, 0,
509 &lpIcon
->iVertSpacing
, FALSE
);
510 SystemParametersInfoW( SPI_GETICONTITLEWRAP
, 0,
511 &lpIcon
->iTitleWrap
, FALSE
);
512 SystemParametersInfoW( SPI_GETICONTITLELOGFONT
, 0,
513 &lpIcon
->lfFont
, FALSE
);
516 case SPI_GETNONCLIENTMETRICS
: {
517 /* FIXME: implement correctly */
518 LPNONCLIENTMETRICSW lpnm
=(LPNONCLIENTMETRICSW
)lpvParam
;
520 /* clear the struct, so we have 'sane' members */
521 memset((char*)lpvParam
+sizeof(lpnm
->cbSize
),
523 lpnm
->cbSize
-sizeof(lpnm
->cbSize
)
525 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfCaptionFont
),0);
526 lpnm
->lfCaptionFont
.lfWeight
= FW_BOLD
;
527 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfSmCaptionFont
),0);
528 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMenuFont
),0);
529 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfStatusFont
),0);
530 SystemParametersInfoW(SPI_GETICONTITLELOGFONT
,0,(LPVOID
)&(lpnm
->lfMessageFont
),0);
534 case SPI_GETHIGHCONTRAST
:
536 LPHIGHCONTRASTW lpHighContrastW
= (LPHIGHCONTRASTW
)lpvParam
;
538 FIXME("SPI_GETHIGHCONTRAST not fully implemented\n");
540 if ( lpHighContrastW
->cbSize
== sizeof( HIGHCONTRASTW
) )
542 /* Indicate that there is no high contrast available */
543 lpHighContrastW
->dwFlags
= 0;
544 lpHighContrastW
->lpszDefaultScheme
= NULL
;
555 return SystemParametersInfoA(uAction
,uParam
,lpvParam
,fuWinIni
);