Before we get into system settings and Accessibility Options, I need to emphasize that not all accessibility options are available to all versions of Windows. In this section you can assume that unless otherwise noted, the settings are valid for Windows 95, Windows 98, Windows NT 4, and Windows NT 5. Where exceptions occur, in the sample programs I've added the Microsoft SysInfo Control 6.0 component to the project and added the control to the form. This allows me to check and make sure we're running on a system that supports the given Accessibility setting, as follows:
Dim nOS As Integer Dim nVer As Integer Const WINDOWS_95 As Integer = 1 Const WINDOWS_NT As Integer = 2 Const VER_95_NT4 As Integer = 4 With SysInfo1 nOS = .OSPlatform nVer = .OSVersion End With ' If Windows 95, Windows 98, or Windows NT 5.0 If (nOS = WINDOWS_95 And nVer >= VER_95_NT4) Or _ (nOS = WINDOWS_NT And nVer > VER_95_NT4) Then ' Check accessibility setting End If
The SystemParametersInfo function provides access to many of the Windows system settings. I'll go over a few of the settings that are most relevant to accessibility development. But first, let's take a look at the Visual Basic declaration of this function:
Declare Function SystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal iAction As Long, _ ByVal iParam As Long, pvParam As Any, _ ByVal fWinIni As Long) As Long
If you don't understand what's happening in this Declare statement, don't worry about it. I'll explain enough to allow you to use it effectively in your programs. Just remember that all public Declare statements must be placed in a standard module (BAS file) in your Visual Basic project.
Declaring an argument As Any as we did in our Declare statement goes against the standards established by The Mandelbrot Set (International) Limited (TMS) and as outlined in Appendix A. The parameter is declared As Any here because the return type of that parameter is dependent on the input. However, the preferred method, when practical, would be to create a different Declare statement for each possible return value. For example, if you were going to call SystemParametersInfo to retrieve information that would be returned as a Long, your Declare statement would look something like this:Declare Function WinLongSystemParametersInfo Lib "user32" _ Alias "SystemParametersInfoA" (ByVal iAction As Long, _ ByVal iParam As Long, pvParam As Long, ByVal fWinIni As Long) _ As Long
Notice also the prefix Win on the function declaration. This also is a TMS standard. However, in the samples in this chapter I've left the prefix off the declarations for clarity: you can see the exact name of the DLL functions, as well as the parameter names, and can look them up on Microsoft's Web site or in Visual Studio's online Help if you want more information.
Visual Basic Declare Statements For System DLLs
Visual Basic ships with a utility called the API Viewer. This utility, located in the Common\Tools\Winapi folder on the Visual Basic CD, reads in a text file filled with Visual Basic Declare statements, Type definitions, and Constant declarations for the Win32 API. You can search for the statement you want, then copy and paste it into your application. If you want to really understand how to declare functions from C language DLLs.
The settings for the function parameters for SystemParametersInfo depend on what system setting you're querying for. The first parameter in the SystemParametersInfo function requires a numeric constant.updated