Table of contents
TOC
折叠目录
展开目录

OptionButton.MouseDown 事件 (访问)OptionButton.MouseDown Event (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

用户按下鼠标按钮时发生MouseDown事件。The MouseDown event occurs when the user presses a mouse button.

语法Syntax

表达式在 MouseDown(* 按钮班次 * X,* * Y ** )expression. **MouseDown( ** Button, ** Shift, ** X, ** Y )

表达式_一个表示一个选项按钮对象的变量。_expression A variable that represents an OptionButton object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
按钮Button必需RequiredIntegerInteger按下以触发该事件的鼠标键。如果需要测试 Button 参数,可以使用下列固有常量之一作为位掩码:The button that was pressed to trigger the event. If you need to test for the Button argument, you can use one of the following intrinsic constants as bit masks:

  • acLeftButton 鼠标左键的位掩码。acLeftButton The bit mask for the left mouse button.

  • acRightButton 鼠标右按钮的位掩码。acRightButton The bit mask for the right mouse button.

  • acMiddleButton 鼠标中键的位掩码。acMiddleButton The bit mask for the middle mouse button.

| |Shift|需要 |整数|在 Button 参数所指定的按钮被按下或释放时 SHIFT、 CTRL 和 ALT 键的状态。如果需要测试 Shift 参数,可以使用下列固有常量之一作为位掩码:| | Shift|Required|Integer|The state of the SHIFT, CTRL, and ALT keys when the button specified by the Button argument was pressed or released. If you need to test for the Shift argument, you can use one of the following intrinsic constants as bit masks:
  • acShiftMask 按住 SHIFT 键的位掩码。acShiftMask The bit mask for the SHIFT key.

  • acCtrlMask CTRL 键位掩码。acCtrlMask The bit mask for the CTRL key.

  • acAltMask ALT 键的位掩码。acAltMask The bit mask for the ALT key.

| |X|需要 |单个|以缇为单位的鼠标指针当前位置的 x 坐标。| |Y|需要 |单个|以缇为单位的鼠标指针的当前位置的 y 坐标。|| | X|Required|Single|The x coordinate for the current location of the mouse pointer, in twips. | | Y|Required|Single|The y coordinate for the current location of the mouse pointer, in twips. |

注解Remarks

  • MouseDown事件仅适用于窗体、 窗体节和窗体,不适用于报表上的控件上。The MouseDown event applies only to forms, form sections , and controls on a form, not controls on a report.

  • 该事件不适用于附到其他控件上的标签,例如文本框的标签。它只适用于“独立”的标签。在附属标签中按下和释放鼠标键与在标签所附属的控件中按下和释放按钮有相同的效果。这种情况下,将只发生控件的正常事件,而不会发生附属标签的独立事件。This event does not apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Pressing and releasing a mouse button in an attached label has the same effect as pressing and releasing the button in the associated control. The normal events for the control occur; no separate events occur for the attached label.

若要在这些事件发生时运行宏或事件过程,请设置OnMouseDown属性为宏的名称或 [事件过程]。To run a macro or event procedure when these events occur, set the OnMouseDown property to the name of the macro or to [Event Procedure].

MouseDown 事件可用于指定当按下或释放特定的鼠标按钮时,会发生什么情况。与单击DblClick事件,不同 MouseDown 事件可以区分为左、 右和中间的鼠标按钮。您还可以编写代码的使用 SHIFT、 CTRL 和 ALT 键的鼠标键盘组合。You can use a MouseDown event to specify what happens when a particular mouse button is pressed or released. Unlike the Click and DblClick events, the MouseDown event enables you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keys.

导致发生某个窗体的MouseDown事件,按窗体上的空白区域或记录选择器中的鼠标按钮。若要使窗体节发生 MouseDown 事件,请按鼠标按钮在窗体节的空白区域中。To cause a MouseDown event for a form to occur, press the mouse button in a blank area or record selector on the form. To cause a MouseDown event for a form section to occur, press the mouse button in a blank area of the form section.

以下情况适用于MouseDown事件:The following apply to MouseDown events:

  • 如果指针在窗体或控件上时按下鼠标键,该对象将接收所有鼠标事件,直到最后一个MouseUp事件。If a mouse button is pressed while the pointer is over a form or control, that object receives all mouse events up to and including the last MouseUp event.

  • 如果鼠标按钮被连续按下,那个接收第一次按下后的鼠标事件的对象,将接收所有的鼠标事件,直到释放所有按钮为止。If mouse buttons are pressed in succession, the object that receives the mouse event after the first press receives all mouse events until all buttons are released.

要响应由移动鼠标事件,请使用MouseMove事件。To respond to an event caused by moving the mouse, you use a MouseMove event.

示例Example

下面的示例说明如何找出引发 MouseDown 事件的鼠标按钮。The following example shows how you can find out which mouse button caused a MouseDown event.

若要尝试运行该示例,请将以下事件过程添加到窗体中:To try the example, add the following event procedure to a form:

Private Sub Form_MouseDown(Button As Integer, _ 
         Shift As Integer, X As Single, _ 
         Y As Single) 
    If Button = acLeftButton Then 
        MsgBox "You pressed the left button." 
    End If 
    If Button = acRightButton Then 
        MsgBox "You pressed the right button." 
    End If 
    If Button = acMiddleButton Then 
        MsgBox "You pressed the middle button." 
    End If 
End Sub

另请参阅See also

概念Concepts

OptionButton 对象OptionButton Object

© 2018 Microsoft