SPI Functions
System Parameters Info Functions
SPI Functions
Functions Synopsis
SPI_*() functions are all based on SystemParametersInfo() function of the Windows SDK. Given the fact that this function uses data types that do not exist in Visual FoxPro, we found it useful to provide these services to you.
The SystemParametersInfo() function queries or sets system-wide parameters. This function can also update the user profile while setting a parameter.
One of my favorites is the ability to setup the Windows Wallpaper easily. You’ll also notice that it is possible to change keyboard delay and keyboard speed.
Following is a table of all SystemParametersInfo() values you can query or set. In order to have the most accurate information we could provide, we slightly adapted the Microsoft Visual C++ help.
VALUE / MeaningSPI_GETACCESSTIMEOUT / Retrieves information about the time-out period associated with the accessibility features. The wParam parameter specifies the size of an ACCESSTIMEOUT structure, and pvParam is the address of the ACCESSTIMEOUT structure that receives the information.
SPI_GETBEEP / Determines whether the warning beeper is on (TRUE) or off (FALSE). The pvParam parameter points to a BOOL variable.
SPI_GETBORDER / Retrieves the border multiplier factor that determines the width of a window's sizing border. The pvParam parameter points to an integer variable.
SPI_GETFASTTASKSWITCH / Determines whether fast task switching is enabled. The pvParam parameter points to a BOOL variable that receives TRUE if enabled, or FALSE otherwise.
SPI_GETFILTERKEYS / Retrieves information about the FilterKeys accessibility feature. The wParam parameter specifies the size of the FILTERKEYS structure, and pvParam is the address of the FILTERKEYS structure that receives the information.
SPI_GETGRIDGRANULARITY / Retrieves the current granularity value of the desktop sizing grid. The pvParam parameter points to an integer variable that receives the granularity.
SPI_GETICONTITLELOGFONT / Retrieves the logical font information for the current icon-title font. The wParam parameter specifies the size of a LOGFONT structure, and the pvParam parameter points to the LOGFONT structure to fill in.
SPI_GETICONTITLEWRAP / Determines whether icon-title wrapping is enabled. The pvParam parameter points to a BOOL variable that receives TRUE if enabled, or FALSE otherwise.
SPI_GETKEYBOARDDELAY / Retrieves the keyboard repeat-delay setting. The pvParam parameter points to an integer variable that receives the setting.
SPI_GETKEYBOARDSPEED / Retrieves the keyboard repeat-speed setting. The pvParam parameter points to a DWORD variable that receives the setting.
SPI_GETMENUDROPALIGNMENT / Determines whether pop-up menus are left aligned or right aligned, relative to the corresponding menu-bar item. The pvParam parameter points to a BOOL variable that receives TRUE if left-aligned, or FALSE otherwise.
SPI_GETMOUSE / Retrieves the mouse thresholds and speed. The pvParam parameter points to an array of three integers that receive the x-threshold, the y-threshold, and the speed.
SPI_GETMOUSEKEYS / Retrieves information about the MouseKeys accessibility feature. The wParam parameter specifies the size of a MOUSEKEYS structure, and pvParam is the address of the MOUSEKEYS structure that receives the information.
SPI_GETSCREENSAVEACTIVE / Determines whether screen saving is enabled. The pvParam parameter points to a BOOL variable that receives TRUE if enabled, or FALSE otherwise.
SPI_GETSCREENSAVETIMEOUT / Retrieves the screen saver time-out value, in milliseconds. The pvParam parameter points to an integer variable that receives the value.
SPI_GETSHOWSOUNDS / Determines whether the user requires an application to present information visually in situations where it would otherwise present the information only in audible form. The wParam parameter points to a BOOL variable. Using this value is equivalent to calling GetSystemMetrics(SM_GETSHOWSOUNDS). That is the recommended call.
SPI_GETSOUNDSENTRY / Retrieves information about the SoundSentry accessibility feature. The wParam parameter specifies the size of a SOUNDSENTRY structure, and pvParam is the address of the SOUNDSENTRY structure that receives the information.
SPI_GETSTICKYKEYS / Retrieves information about the MouseKeys accessibility feature. The wParam parameter specifies the size of a STICKYKEYS structure, and pvParam is the address of the STICKYKEYS structure that receives the information.
SPI_GETTOGGLEKEYS / Retrieves information about the ToggleKeys accessibility feature. The wParam parameter specifies the size of a TOGGLEKEYS structure, and pvParam is the address of the TOGGLEKEYS structure that receives the information.
SPI_ICONHORIZONTALSPACING / Sets the width of an icon cell. The wParam parameter specifies the width, in pixels.
SPI_ICONVERTICALSPACING / Sets the height of an icon cell. The wParam parameter specifies the height, in pixels.
SPI_LANGDRIVER / Identifies the language driver. The pvParam parameter points to a character array that receives the filename of the language driver.
SPI_SETACCESSTIMEOUT / Sets the time-out period associated with the accessibility features. The wParam parameter specifies the size of the ACCESSTIMEOUT structure, and pvParam is the address of the ACCESSTIMEOUT structure that contains the new parameters.
SPI_SETBEEP / Turns the warning beeper on or off. The wParam parameter specifies TRUE for on, or FALSE for off.
SPI_SETBORDER / Sets the border multiplier factor that determines the width of a window's sizing border. The wParam parameter specifies the new value.
SPI_SETDESKPATTERN / Sets the current desktop pattern by causing Windows to read the Pattern= setting from the WIN.INI file.
SPI_SETDESKWALLPAPER / Sets the desktop wallpaper. The pvParam parameter points to a null-terminated string containing the name of a bitmap file.
SPI_SETDOUBLECLICKTIME / Sets the double-click time for the mouse to the value of the wParam parameter. The double-click time is the maximum number of milliseconds that can occur between the first and second clicks of a double-click.
SPI_SETDOUBLECLKHEIGHT / Sets the height of the double-click rectangle to the value of the wParam parameter. The double-click rectangle is the rectangle within which the second click of a double-click must fall for it to be registered as a double-click.
SPI_SETDOUBLECLKWIDTH / Sets the width of the double-click rectangle to the value of the wParam parameter. The double-click rectangle is the rectangle within which the second click of a double-click must fall for it to be registered as a double-click.
SPI_SETFASTTASKSWITCH / Turns fast task switching on or off. The wParam parameter specifies TRUE for on, or FALSE for off.
SPI_SETFILTERKEYS / Sets the parameters of the FilterKeys accessibility feature. The wParam parameter specifies the size of the FILTERKEYS structure, and pvParam is the address of the FILTERKEYS structure that contains the new parameters.
SPI_SETGRIDGRANULARITY / Sets the granularity of the desktop sizing grid to the value of the wParam parameter.
SPI_SETICONTITLELOGFONT / Sets the font that is used for icon titles. The wParam parameter specifies the size of a LOGFONT structure, and the lParam parameter points to a LOGFONT structure.
SPI_SETICONTITLEWRAP / Turns icon-title wrapping on or off. The wParam parameter specifies TRUE for on, or FALSE for off.
SPI_SETKEYBOARDDELAY / Sets the keyboard repeat-delay setting to the value of the wParam parameter.
SPI_SETKEYBOARDSPEED / Sets the keyboard repeat-speed setting to the value of the wParam parameter.
SPI_SETMENUDROPALIGNMENT / Sets the alignment value of pop-up menus. The wParam parameter specifies TRUE for right alignment, or FALSE for left alignment.
SPI_SETMOUSE / Sets the mouse thresholds and speed. The pvParam parameter points to an array of three integers that specifies the x-threshold, the y-threshold, and the speed.
SPI_SETMOUSEBUTTONSWAP / Swaps or restores the meaning of the left and right mouse buttons. The wParam parameter specifies TRUE to swap the meanings of the buttons, or FALSE to restore their original meanings.
SPI_SETMOUSEKEYS / Sets the parameters of the MouseKeys accessibility feature. The wParam parameter specifies the size of the MOUSEKEYS structure, and pvParam is the address of the MOUSEKEYS structure that contains the new parameters.
SPI_SETSCREENSAVEACTIVE / Sets the state of the screen saver. The wParam parameter specifies TRUE to activate screen saving, or FALSE to deactivate it.
SPI_SETSCREENSAVETIMEOUT / Sets the screen saver time-out value to the value of the wParam parameter. This value is the amount of time, in milliseconds, that the system must be idle before the screen saver activates.
SPI_SETSHOWSOUNDS / Sets the ShowSounds accessibility feature as on or off. The wParam parameter specifies TRUE for on, or FALSE for off.
SPI_SETSOUNDSENTRY / Sets the parameters of the SoundSentry accessibility feature. The wParam parameter specifies the size of the SOUNDSENTRY structure, and pvParam is the address of the SOUNDSENTRY structure that contains the new parameters.
SPI_SETSTICKYKEYS / Sets the parameters of the StickyKeys accessibility feature. The wParam parameter specifies the size of the STICKYKEYS structure, and pvParam is the address of the STICKYKEYS structure that contains the new parameters.
SPI_SETTOGGLEKEYS / Sets the parameters of the ToggleKeys accessibility feature. The wParam parameter specifies the size of the TOGGLEKEYS structure, and pvParam is the address of the TOGGLEKEYS structure that contains the new parameters.
Many SPI settings can be found in the WIN.INI file :
[windows]
load=C:\WINDOWS\POINTER.EXE C:\MOUSE\POINTER.EXE
run=C:\WINDOWS\WSIZER.EXE
Beep=yes
NullPort=None
BorderWidth=3
CursorBlinkRate=530
DoubleClickSpeed=452
Programs=com exe bat pif
Documents=
KeyboardDelay=0
KeyboardSpeed=31
ScreenSaveActive=0
ScreenSaveTimeOut=120
MouseThreshold1=0
MouseThreshold2=0
MouseSpeed=0
device=Epson EPL-5600,HPPCL5MS,LPT1:
[Desktop]
Pattern=(aucun)
TileWallPaper=1
GridGranularity=5
Wallpaper=D:\CSERVE\DOWNLOAD\WIN95.BMP
WallpaperStyle=0
SPI Functions
SPI_GetBeep(): Determines whether the warning beeper is on.
Syntax
SPI_GetBeep() lIsBeepOn
Parameters
None.
Returns
lIsBeepOn.T. when warning beep on; .F. otherwise.
SPI_GetBorder(): Retrieves the border multiplier factor that determines the width of a window's sizing border.
Syntax
SPI_GetBorder() nBorder
Parameters
None.
Returns
nBorderborder multiplier factor.
SPI_GetDoubleClickHeight(): Height in pixels of the double-click rectangle.
Remark
Height, in pixels, of the rectangle around the location of a first click in a double-click sequence. The second click must occur within this rectangle for the system to consider the two clicks a double-click.
Alias
GetDoubleClickHeight(), SYS_GetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight() nHeight
Parameters
None.
Returns
nHeightcurrent height in pixels of the rectangle in which the double click should occur.
SPI_GetDoubleClickTime(): Retrieves the current double-click time for the mouse.
Remark
A double-click is a series of two clicks of the mouse button, the second occurring within a specified time after the first. The double-click time is the maximum number of milliseconds that may occur between the first and second click of a double-click. Unlike the _DBLCLICK internal variable of Visual FoxPro, the SPI_GetDoubleClickTime() function always retrieves the current value of the Windows Mouse Control Panel.
Alias
GetDoubleClickTime(), SYS_GetDoubleClickTime()
Syntax
SPI_GetDoubleClickTime() nMilliSeconds
Parameters
None.
Returns
nMilliSecondscurrent double-click time, in milliseconds.
SPI_GetDoubleClickWidth(): Width in pixels of the double-click rectangle.
Remark
Width, in pixels, of the rectangle around the location of a first click in a double-click sequence. The second click must occur within this rectangle for the system to consider the two clicks a double-click.
Alias
GetDoubleClickHeight(), SYS_GetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight() nHeight
Parameters
None.
Returns
nHeightcurrent width in pixels of the rectangle in which the double click should occur.
SPI_GetFastTaskSwitch(): Is Alt-Tab enabled?
Remark
This flag is obsolete. Previous versions of Windows use this flag to determine whether ALT+TAB fast task switching is enabled. Beginning with Windows 95 and Windows NT version 4.0, fast task switching is always enabled
Syntax
SPI_GetFastTaskSwitch() lAltTab
Parameters
None.
Returns
lAltTabAlt-Tab fast task switching allowed (.T.) or not (.F.).
SPI_GetGrid(): Retrieves the current granularity value of the desktop sizing grid.
Syntax
SPI_GetGrid() nGranularity
Parameters
None.
Returns
nGranularitycurrent granularity value.
SPI_GetIconTitleWrap(): Determines whether icon-title wrapping is enabled.
Syntax
SPI_GetIconTitleWrap() lIconWrapping
Parameters
None.
Returns
lIconWrapping.T. if icon-title wrapping is ON; .F. otherwise.
SPI_GetKeyboardDelay(): Retrieves the keyboard repeat-delay setting.
Syntax
SPI_GetKeyboardDelay() nDelay
Parameters
None.
Returns
nDelaykeyboard repeat-delay.
SPI_GetKeyboardSpeed(): Retrieves the keyboard repeat-speed setting.
Syntax
SPI_GetKeyboardSpeed() nSpeed
Parameters
None.
Returns
nSpeedkeyboard repeat-speed.
SPI_GetLastError(): Returns the last error encountered when using SPI_*() functions.
Alias
SPI_LastError()
Syntax
SPI_GetLastError() szError
Parameters
None.
Returns
szErrorLast SPI error description.
SPI_GetMenuDropAlignment(): Determines whether pop-up menus are left-aligned or right-aligned, relative to the corresponding menu-bar item.
Syntax
SPI_GetMenuDropAlignment() lLeftAligned
Parameters
None.
Returns
lLeftAligned.T. if left-aligned; .F.otherwise.
SPI_GetScreenReader(): Determines whether a screen reviewer utility is running.
Remark
This function only returns a meaningful value under Windows95. A screen reviewer utility directs textual information to an output device, such as a speech synthesizer or Braille display. When this flag is set, an application should provide textual information in situations where it would otherwise present the information graphically.
Syntax
SPI_GetScreenReader() lScreenReader
Parameters
None.
Returns
lScreenReaderDetermines whether a screen reviewer utility is running (.T.) or not (.F.).
SPI_GetScreenSaveActive(): Determines whether screen saving is enabled.
Syntax
SPI_GetScreenSaveActive() lScreenSaveActive
Parameters
None.
Returns
lScreenSaveActive.T. if screen save active; .F. otherwise.
SPI_GetScreenSaveTimeout(): Gets the screen saver time-out value.
Syntax
SPI_GetScreenSaveTimeout() nValue
Parameters
None.
Returns
nValuescreen saver time-out value.
SPI_GetShowSounds(): Determines whether the Show Sounds accessibility flag is on or off.
Syntax
SPI_GetShowSounds() lShowSounds
Parameters
None.
Returns
lShowSounds.T. if the user requires an application to present information visually in situations where it would otherwise present the information only in audible form; .F. otherwise.
SPI_GetWorkArea(): Retrieves the size of the working area.
Remark
This function is not supported in Windows NT 4, Server or Workstation, but it is in Windows 2000 and in XP!
Syntax
SPI_GetWorkArea( [@nTop,@nLeft,@nBottom,@nRight] ) szArea
Parameters
nToptop of rectangle. If passed, it must be passed by reference.
nLeftleft of rectangle. If passed, it must be passed by reference.
nBottombottom of rectangle. If passed, it must be passed by reference.
nRightright of rectangle. If passed, it must be passed by reference.
Either you pass no parameter or you pass them all.
Returns
szAreagets the size of the working area. The working area is the portion of the screen not obscured by the tray (taskbar). The coordinates of the working area rectangle are formatted according to the following pattern: "t,l,b,r" (top, left, bottom, right). If the function wasn't successful, then szArea is empty.
if nTop,nLeft,nBottom and nRight were passed, these values will be updated and the result of SPI_GetWorkArea() can simply be ignored.
Example
& This code can be invoked after the user has moved the window on the screen
& What is here, is a check to avoid having windows that are outside the limits
& of the desktop
LOCAL nTop
LOCAL nLeft
LOCAL nBottom
LOCAL nRight
WITH ThisForm
m.nTop = 0
m.nLeft = 0
m.nBottom = 0
m.nRight = 0
SPI_GetWorkArea( @nTop,@nLeft,@nBottom,@nRight )
& Impossibility to hide the window at the bottom of the screen
IF ( .Top + .Height > m.nBottom )
.Top = m.nBottom - .Height
ENDIF
& Impossibility to hide the window at the top of the screen
IF ( .Top < 0 )
.Top = 0
ENDIF
& Impossibility to hide the window at the rightmost side of the screen
IF ( .Left + .Width > m.nRight )
.Left = m.nRight - .Width
ENDIF
& Impossibility to hide the window at the leftmost side of the screen
IF ( .Left < 0 )
.Left = 0
ENDIF
ENDWITH
SPI_LastVersion(): Returns the file stamp of SPI functions.
Remark
This function helps the developer identifying the last version of a set of functions. Sometimes the global version information of FOCUS.FLL (MIS_major() and MIS_minor()) does not help tracking down the changes in a project. Starting with version 6.0 of FOCUS.FLL, each source file has now an internal date and time stamp.
Syntax
SPI_LastVersion() szLastVersion
Parameters
None.
Returns
szLastVersionstring identifying the last version of the functions set. The string is similar to "C:\Focus\5.0\SPI.C-Mon Oct 19 15:55:22 1998".
SPI_SetBorder(): Sets the border multiplier factor that determines the width of a window's sizing border.
Syntax
SPI_SetBorder( nBorder ) lSuccess
Parameters
nBorderborder multiplier factor.
Returns
lSuccess.T. if function was successful, .F. otherwise.
SPI_SetBeep(): Turns the warning beeper on or off.
Syntax
SPI_SetBeep( lSetting ) lSucess
Parameters
lSetting.T. to turn the warning beep ON;.F. to turn it off.
Returns
lSuccess.T. if function was successful, .F. otherwise.
SPI_SetDoubleClickHeight(): Height in pixels of the double-click rectangle.
Remark
Height, in pixels, of the rectangle around the location of a first click in a double-click sequence. The second click must occur within this rectangle for the system to consider the two clicks a double-click.
Alias
SetDoubleClickHeight(), SYS_SetDoubleClickHeight()
Syntax
SPI_SetDoubleClickHeight( nHeight ) lSuccess
Parameters
nHeightheight in pixels of the rectangle in which the double click should occur.
Returns
lSuccess.T. if function was successful, .F. otherwise.
SPI_GetDoubleClickTime(): Sets the current double-click time for the mouse.
Remark
A double-click is a series of two clicks of the mouse button, the second occurring within a specified time after the first. The double-click time is the maximum number of milliseconds that may occur between the first and second click of a double-click. Unlike the _DBLCLICK internal variable of Visual FoxPro, the SPI_SetDoubleClickTime() function always influences the current value of the Windows Mouse Control Panel.
Alias
SetDoubleClickTime(), SYS_SetDoubleClickTime()
Syntax
SPI_SetDoubleClickTime( nMilliSeconds )
Parameters
nMilliSecondsdouble-click time, in milliseconds.
Returns
lSuccess.T. if function was successful, .F. otherwise.
SPI_SetDoubleClickWidth(): Width in pixels of the double-click rectangle.
Remark
Width, in pixels, of the rectangle around the location of a first click in a double-click sequence. The second click must occur within this rectangle for the system to consider the two clicks a double-click.
Alias
SetDoubleClickHeight(), SYS_SetDoubleClickHeight()
Syntax
SPI_GetDoubleClickHeight( nHeight ) lSuccess
Parameters
nHeightwidth in pixels of the rectangle in which the double click should occur.
Returns
lSuccess.T. if function was successful, .F. otherwise.
SPI_SetFastTaskSwitch(): Enables or disables Alt-Tab.