MouseDown Event

This event occurs when the user presses a mouse button over the system tray icon.

Syntax

Private Sub csSysTray_MouseDown(button As Integer)
Private Sub csSysTray_MouseDown([index As Integer,]button As Integer)

The MouseDown event syntax has these parts:

Part Description
csSysTray The SysTray control you are working with.
index An integer that uniquely identifies a control if it's in a control array.
button Returns an integer that identifies the button that was pressed to cause the event. The button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Buttons are OR'd together to indicate which button(s) caused the event.

Quick Tip

The numbers that represent the button values (1, 2, and 4) are built-in Visual Basic constants.  You can use vbLeftButton instead of 1, vbRightButton instead of 2, and vbMiddleButton instead of 4.

Examples

Example 1 (Responding to a MouseDown event with a message for each button pressed)

Private Sub csSysTray1_MouseDown (Button As Integer)

If (Button And vbLeftButton) Then 'vbLeftButton = 1
MsgBox "Left Button Pressed"
End If
If (Button And vbRightButton) Then 'vbRightButton = 2
MsgBox "Right Button Pressed"
End If
If (Button And vbMiddleButton) Then 'vbMiddleButton = 4
MsgBox "Middle Button Pressed"
End If

End Sub