ComboBox.MouseMove 事件 (Access)ComboBox.MouseMove event (Access)

MouseMove 事件發生於使用者移動滑鼠時發生。The MouseMove event occurs when the user moves the mouse.


運算式MouseMove(] 按鈕shift 鍵XY)expression.MouseMove (Button, Shift, X, Y)

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.


名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
ButtonButton 必要Required IntegerInteger 在事件觸發時按下或放開的按鈕。The button that was pressed or released when the event was triggered. 如果您需要測試_Button_引數,您可以使用下列其中一個內部常數作為位元遮罩: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.

ShiftShift 必要Required IntegerInteger _按鈕_引數所指定的按鈕已按下或發行時會 Shift、 Ctrl 和 Alt 鍵的狀態。The state of the Shift, Ctrl, and Alt keys when the button specified by the Button argument was pressed or released. 如果您需要測試_Shift_引數,您可以使用下列其中一個內部常數作為位元遮罩: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.

XX 必要Required SingleSingle 目前滑鼠指標,以twip 為單位的位置的_x_座標。The x coordinate for the current location of the mouse pointer, in twips.
YY 必要Required SingleSingle 目前滑鼠指標,以 twip 為單位的位置的_y_座標。The y coordinate for the current location of the mouse pointer, in twips.


MouseMove事件套只能用於表單、 表單區段及表單上的控制項和不適用於報表上的控制項。The MouseMove event applies only to forms, form sections, and controls on a form, and not to 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 事件產生持續為滑鼠指標移 over 物件。The MouseMove event is generated continually as the mouse pointer moves over objects. 除非另一個物件就會產生滑鼠事件,物件會辨識每當滑鼠指標位於其框線內 MouseMove 事件。Unless another object generates a mouse event, an object recognizes a MouseMove event whenever the mouse pointer is positioned within its borders.

若要引發 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. 若要使表單] 區段中發生 MouseMove 事件,將滑鼠指標移 [表單] 區段中的空白區域。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.

若要執行回應按下及放開滑鼠按鈕的巨集或事件程序,您可以使用 MouseDownMouseUp 事件。To run a macro or event procedure in response to pressing and releasing the mouse buttons, you use the MouseDown and MouseUp events.


下列範例會判斷滑鼠的位置,以及滑鼠左鍵和 (或) Shift 鍵是否已按下。The following example determines where the mouse is and whether the left mouse button and/or the Shift key is pressed. 滑鼠指標的 X 和 Y 座標會顯示在滑鼠移動到的標籤控制項。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

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.