Visual Basic

Keyboard preference

The first constant setting we'll use is SPI_GETKEYBOARDPREF, which is defined as follows:

Const SPI_GETKEYBOARDPREF As Long = 68

Specifying SPI_GETKEYBOARDPREF as the first parameter in the SystemParametersInfo function indicates that we're querying the system as to whether the user prefers the keyboard to the mouse. The user specifies this setting by selecting Accessibility Options from the Control Panel, then selecting the Show Extra Keyboard Help In Programs option on the Keyboard property page.

NOTE


This option is not available in Windows NT 4.

The second and fourth parameters of SystemParametersInfo, iParam and fWinIni, should be set to 0. The third parameter, pvParam, returns True if the user has selected keyboard preference, False otherwise. So your call would look something like this:

Dim bUseKeyboard As Boolean
  If SystemParametersInfo(SPI_GETKEYBOARDPREF, 0, _
                          bUseKeyboard, 0) Then
      ' Enable and display keyboard shortcuts.
  End If

You can see an example of this function in the Keyboard sample.

High contrast

The High Contrast option is useful when checking color settings. The user sets this display option by selecting Accessibility Options from the Control Panel, clicking the Display tab, and selecting the Use High Contrast check box. The user sets this option to display a system-defined set of colors that provide a high amount of contrast. This option is especially useful to users who are colorblind. If this option is set, it is an indication to your application that it should be using system colors and hiding all background images.

NOTE


This option is not available in Windows NT 4.

To find this setting, you need to declare the following user-defined type (UDT) in a module in your project.

Type tHIGHCONTRAST
      cbSize            As Long
      dwflags           As Long
      lpszDefaultScheme As String
  End Type

You next define the system constants:

Public Const SPI_GETHIGHCONRAST As Long = 66
  Public Const HCF_HIGHCONTRASTON As Long = &H1&

After declaring the SystemParametersInfo function, you make your call as follows:

Dim thc     As tHIGHCONTRAST
  Dim lReturn As Long
  thc.cbSize = Len(thc)
  lReturn = SystemParametersInfo(SPI_GETHIGHCONTRAST, Len(thc), _
                                 thc, 0)
  If thc.dwflags And HCF_HIGHCONTRASTON Then
      ' High contrast option is on.
  Else
       ' High contrast option is off.
  End If

You can see this function in the ColorOpt2 sample. In that sample, if the high contrast option is on when the application starts, the background picture is turned off by default.

by BrainBellupdated
Advertisement: