The mouse class consists of three types of properties:
Dim oMouse As New Mouse
If Not oMouse.MousePresent Then
MsgBox "You must have a mouse to use this application."
End If
Dim oMouse As New Mouse
oMouse.MouseButtonSwap = True
The only group of properties that requires any special explanation is the set of three properties: MouseSpeed, MouseThreshold1, and MouseThreshold2. These three work together to control how quickly the mouse cursor moves across the screen as you move the mouse physically. The MouseSpeed parameter can take on values between 0 and 2, representing the speed of the mouse cursor relative to the distance you’ve moved the mouse. The MouseThreshold (1 and 2) properties can take on values between 0 and 12. The following paragraphs explain how these three properties are related.
As you may have noticed, the more quickly you move the mouse, the further the mouse cursor moves on the screen. This means you don’t have to lift the mouse and reposition it as often as you might otherwise have to. Windows uses three values to calculate the distance it will move the mouse cursor every time you move the mouse, based on two tests.
At measured time intervals, as you move the mouse, Windows polls the position of the mouse and the speed at which you’re moving it. If, during one interval, the distance along either the x or y axis is greater than the first mouse threshold value (MouseThreshold1) and the mouse speed (MouseSpeed) is not 0, Windows doubles the distance. If the distance along either the x or y axis is greater than the second mouse threshold value and the mouse speed is 2, the operating system doubles the distance that resulted from applying the first threshold test. It is thus possible for the operating system to multiply relatively specified mouse motion along the x or y axis by up to four times.
If you use the Mouse Control Panel applet, you’ll see only a single linear slider control to manage the mouse speed. Windows takes the seven possible settings on the slider and converts them into preset values for the three properties. Table 9.14 lists these preset triplets of values, starting with the slowest and ending with the fastest setting. Figure 9.13 shows the Mouse Control Panel applet, with the first, middle, and last MouseSpeed triplets pointed out.
Table 9.14: Preset Values for the Three Mouse Parameters
Speed | Threshold1 | Threshold2 |
0 | 0 | 0 |
1 | 10 | 0 |
1 | 7 | 0 |
1 | 4 | 0 |
2 | 4 | 12 |
2 | 4 | 9 |
2 | 4 | 6 |
Figure 9.13: Mouse Control Panel applet, showing MouseSpeed triplets
Therefore, the MouseSpeed parameter controls the general speed of the mouse. As you move the mouse, if the MouseSpeed parameter is greater than 0 and the mouse is moved more physical units than the value specified in Threshold1, Windows doubles the distance, and the cursor moves farther. If the MouseSpeed is 2 and the distance moved was also greater than the value in the MouseThreshold2 parameter, Windows again doubles the distance. You can see that it makes no sense to have both the MouseSpeed parameter set to 1 and the Threshold2 parameter set to anything except 0—Windows will never even look at the Threshold2 value in that case.
If you intend to set these values, here are some general rules to help you:
Therefore, if your MouseSpeed, MouseThreshold1, and MouseThreshold2 values are (0, 0, 0), there’s no acceleration as you move the mouse. As long as the first value is 0, Windows never even looks at the next two.
If the values are (1, 10, 0) and:
If the values are (2, 4, 6) and:
As you can see, it’s important to understand the relationship between the movement of the mouse and the MouseSpeed, MouseThreshold1, and MouseThreshold2 parameters in controlling the speed and acceleration of the mouse cursor.