Professional Documents
Culture Documents
Monitoring Mouse Activity
Monitoring Mouse Activity
Monitoring Mouse Activity
Controls recognize a mouse event only when the mouse pointer is inside is inside the control.
All Mouse Event procedures take the same form and use the same parameter
This simple event procedure usese the positioning information passed by X and Y
Each time you click a mouse button, a small circle is centered exactly where you clicked
Eg:
The button argument uses the lowest three bits of value of the integer,
To work mouse button to perform different task for each button button arguments are used
Clicking Right mouse button performs different action and Left mouse button performs
different action
Eg:
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Ccode As Integer
Randomize
Ccode = Int(15 * Rnd)
Select Case Button
Case vbLeftButton
Circle (X, Y), 75, QBColor(Ccode)
FillColor = &HFFFFFF
Case vbRightButton
FillStyle = 0
FillColor = QBColor(Ccode)
Circle (X, Y), 75
End Select
End Sub
COMBINING THE KEYBOARD AND MOUSE:
Select case shift this is the shift parameter in the mouse event
Visual Basic calls the mouse move event procedure whenever the user moves the mouse.
This is the most powerful of the mouse event procedure because you can analyse completely
the state of mouse buttons.
Manual Dragging
Automatic Dragging
These correspond to two different values of the drag mode property.
Item Description
Dragmode property Allows automatic dragging or manual dragging
Dragicon property Set this to change from the gray rectangle to a
actual icon. When dragging.
Dragdropevent Associated with the target of the operation.
Dragover event Associated with any control the source control
passing over when dragging.
Drag method Starts or stops dragging. When dragmode is set
to manual.
Manual dragging:
In manual dragging for every special circumstances the user needs to write the codes
The syntax for this method is control. Drag TypeOfAction.
In automatic dragging the user may drag the control around the project
The drag mode property value for automatic dragging is 1