Mouse Events & Controls
All the mouse events are associated with controls.
You will find mouse events listed for almost every
control as well as forms. Windows provides click-related
events in the following order:
- MouseDown
- MouseUp
- Click
- Dblclick
- MouseUp
The MouseDown, MouseMove, & MouseUp event procedures
require these four arguments:
- intButton: Describes
the button pressed: 1 for the left button, 2 for
the right, and 4 for both buttons (or for center
button if you a three button mouse).
- intShift: Describes
whether the user pressed Alt, Ctrl, or Shift while
moving or clicking the mouse.
- sngX: The horizontal
twip value where the user clicked or moved the
mouse.
- sngY: The verticaltwip
value where the user clicked or moved the mouse.
|
Visual Basic generates a movement
event after the user moves the mouse every 10
to 15 twips. |
The following code tests whether the user pressed
Shift, Ctrl, or Alt key in conjunction with the mouse
button:
Private Sub cmdTest_MouseDown(intButton
As Integer, _
intShift As Integer, sngX As Single, sngY As Single)
Dim intState As Integer
intState = intShift And 7 ' special
bitwise And
Select Case intState
Case 1
Case 2
Case 3
Case 4
Case 5
Case 6
Case 7
End Select
End Sub
|
The special And comparison tests
an internal bit flag value to determine which
key the user pressed along with the mouse event. |
|