Visual Basic

Screen readers

Windows 9x and Windows NT 5 have the ability to determine whether a screen reader device is connected to the computer. You can capture this information by calling SystemParametersInfo with the SPI_GETSCREENREADER option, as follows.

Public Const SPI_GETSCREENREADER As Long = 70
  Dim bScreenReader As Boolean
  lReturn = SystemParametersInfo(SPI_GETSCREENREADER, 0, _
                                 bScreenReader, 0)
  If bScreenReader Then
      ' Screen reader detected; turn off the background and
      ' ensure that all graphic indicators have text explanations.
  Else
      ' No screen reader detected.
  End If

Show sounds

The SystemParametersInfo function can be used to determine the ShowSounds setting, but the GetSystemMetrics function is the preferred method, so we'll save this discussion for the GetSystemMetrics section below.

GetSystemMetrics

The GetSystemMetrics function is used to determine system metrics and configuration settings. The Visual Basic Declare statement looks like this:

Declare Function GetSystemMetrics Lib "user32" _
      (ByVal nIndex As Long) As Long

The nIndex parameter takes a constant that specifies which system metric to get. The return value depends on the nIndex parameter.

The ShowSounds metric

In Windows, the user can set the ShowSounds option on the Accessibility Options property sheet, available from the Control Panel. Setting this option indicates that the user wants to see a visual indication of sounds that occur as part of applications and the operating system. You'll want to check this option in your application and provide visual indications if the ShowSounds option is True.

Const SM_SHOWSOUNDS As Long = 70
  If GetSystemMetrics(SM_SHOWSOUNDS) Then
      ' Enable visual indicators.
  End If

One method of providing visual indications of the information the sound is conveying is to use the FlashWindow function, discussed below.

Line borders

To set the proper border width and height around a control or image (as discussed in the "Size" section earlier), you would call GetSystemMetrics with the following constants:

Const SM_CXBORDER As Long = 5
  Const SM_CYBORDER As Long = 6

GetSystemMetrics will return the width and height measurements in pixels.