# Re: 请问前辈，滑鼠移动时会触发何事件，如何拦截？

Posted by 哈林 on September 25, 1999 at 23:48:55:

In Reply to: 请问前辈，滑鼠移动时会触发何事件，如何拦截？ posted by Jake on September 20, 1999 at 10:08:50:

也是得呼叫API哩...
请加入一个Timer和一个Label
并新增一个模组
以下的程式码请参考:

在模组:
Public Declare Function GetCursorPos Lib "user32" (lpPoint As PointAPI) As Long
Public Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As PointAPI) As Long
Type PointAPI
x As Long
y As Long
End Type

在一般:
Dim MousePos As PointAPI

Private Sub Timer1_Timer()
Dim Rval As Long
Rval = GetCursorPos(MousePos) '捉取绝对座标值
Rval = ScreenToClient(hwnd, MousePos) '转换成控制项或物件上的相对座标值
Label1.Caption = MousePos.x & "," & MousePos.y
End Sub

'Label1.Caption里的值就是你要的东西了~

Follow Ups: