下面可以实现此功能的程序是(  )。

admin2015-06-30  28

问题 下面可以实现此功能的程序是(  )。

选项 A、 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=1 Then
    Label1="X=" & X & "   Y=" & Y
  End If
End Sub
B、 Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=1 Then
    Label1="X=" & X & "   Y=" & Y
  End If
End Sub
C、Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button=1 Then
    Label1="X=" & X & "   Y=" & Y
  End If
End Sub
D、 Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1="X=" & X & "   Y=" & Y
End Sub

答案C

解析 鼠标移动时产生的事件是MouseMove事件。MouseDown事件过程的参数定义如下:
Sub Form_MouseMove(Button As integer, Shift As Integer, x As Single, y As single)
其中Button表示被按下的鼠标键,按下左键时值为1,按下右键时值为2,按下中间键时值为4。x,y参数表示鼠标光标当前位置的坐标。
题目要求按住左键时移动显示鼠标位置,因此在事件过程要判断是否按下了左键,按下了左键则在标签中显示鼠标位置,否则不显示。因此可用If Button=1来判断是否按下了左键及是否显示鼠标位置。因此应该选择C选项。
转载请注明原文地址:https://jikaoti.com/ti/ot60FFFM
0

最新回复(0)