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

Rectangle.MouseMove 事件 (访问)Rectangle.MouseMove Event (Access)

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

用户移动鼠标时发生MouseMove事件。The MouseMove event occurs when the user moves the mouse.

语法Syntax

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

表达式_一个表示矩形对象的变量。_expression A variable that represents a Rectangle object.

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
按钮Button必需RequiredIntegerInteger该按钮将被按下或释放时引发事件。如果需要测试 Button 参数,可以使用下列固有常量之一作为位掩码:The button that was pressed or released when the event was triggered. 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

  • MouseMove事件仅适用于窗体、 窗体节和窗体,不适用于报表上的控件上。The MouseMove 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.

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

MouseMove事件不断以生成鼠标指针移动对象上。除非其他对象生成鼠标事件,对象就能识别 MouseMove 事件时鼠标指针放在其边框内。The MouseMove event is generated continually as the mouse pointer moves over objects. Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

导致发生某个窗体的MouseMove事件,请在窗体空白区域、 记录选择器或滚动条上移动鼠标指针。若要使窗体节发生的MouseMove事件,请在窗体节的空白区域上移动鼠标指针。To cause a MouseMove event for a form to occur, move the mouse pointer over a blank area, record selector, or scroll bar on the form. To cause a MouseMove event for a form section to occur, move the mouse pointer over a blank area of the form section.

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

注意Note

要运行宏或事件过程中按下和释放鼠标按钮时的响应,请使用MouseDownMouseUp事件。To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.

示例Example

下面的示例确定鼠标的位置以及是否按鼠标左键和/或 SHIFT 键。移动鼠标时,鼠标指针位置的 x 和 y 坐标会显示在标签控件中。The following example determines where the mouse is and whether the left mouse button and/or the SHIFT key is pressed. The x and y coordinates of the mouse pointer position are displayed in a label control as you move the mouse.

Private Sub Detail_MouseMove(Button As Integer, _ 
     Shift As Integer, X As Single, Y As Single) 
    Dim intShiftDown As Integer, intLeftButton As Integer 

    Me!Coordinates.Caption = X &; ", " &; Y 
    ' Use bit masks to determine state of 
    ' SHIFT key and left button. 
    intShiftDown = Shift And acShiftMask 
    intLeftButton = Button And acLeftButton 
    ' Check that SHIFT key and left button  
    ' are both pressed. 
    If intShiftDown And intLeftButton > 0 Then 
        MsgBox "Shift key and left mouse button were pressed." 
    End If 
End Sub

另请参阅See also

概念Concepts

矩形对象Rectangle Object

© 2018 Microsoft