Monitoring Mouse Activity
Monitoring Mouse Activity
Visual Basic responds to various mouse events, which are recognized by most of the controls.
The main events are MouseDown, MouseUp and MouseMove.
Syntax
The first argument is an integer called Button. The value of the argument indicates
whether the left, right or middle mouse button was clicked.
The second argument in an integer called shift. The value of this argument indicates
whether the mouse button was clicked simultaneously with the Shift key, Ctrl key or Alt
key.
The third and fourth arguments X and Y are the coordinates of the mouse location at the
time the mouse button was clicked.
Eg.
Form_mousedown
Circle(x,y),75
Example:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Circle (X, Y), 150, vbYellow
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Circle (X, Y), 500, QBColor(Rnd * 15)
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Circle (X, Y), 300, vbRed
End Sub
Eg circle
Circle (X, Y), 1000, vbRed ' normal circle
Circle (X, Y), 1000, vbBlue, , , 0.5 'horizontal oval
Circle (X + 1000, Y + 1000), 1000, vbGreen, , , 1.5 ' vertical oval
Circle (X + 2000, Y + 2000), 1000, vbCyan, 1, 0.5 ' arc
Drawing Lines
Draw lines from one position (x1,y1) to another position (x2,y2)
syntax
Line(x1,y1) –(x2,y2)
X1,y1 – starting position
X2,y2- ending position
Line(x1,y1) –(x2,y2), color
Line(x1,y1) –(x2,y2), color, B -> line will be considered as Box
Line(x1,y1) –(x2,y2), color, BF -> line will be considered as Filled Box
For filled box, user can apply fillstyle and fillcolor.
Eg.
Line (X, Y)-(X + 1000, Y + 1000), QBColor(Rnd * 15), BF
PSet
Syntax
Pset (x,y) , color
X,y – positions and color is any vbcolor
Eg.
Drawwidth=5
Pset(x,y),vbgreen