车库出入口对着窗户:vb中如何获取指针现在坐标

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 06:48:12
一个程序,当坐标小于某个值时就会发生某事件的代码
对不起,没说清楚,不能用form_mousemove事件,因为form完全被其他控件覆盖了。

使用API函数,还有与他相关的类型,放在模块里面
Public Declare Function GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Public Type POINTAPI
x As Long
y As Long
End Type
-----------------------------------------------------------
这里不能使用MOUSEMOVE事件,必须使用TIMER每隔一段时间计算一次

Private Sub Timer1_Timer()
dim MousePt as pointapi
getcursorpos mousept
if mousept.x<? or mousept.y<? then
'do process
end if
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If x<a and y<b Then

^^^^^^^^
^^^^^^^

End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
if x<某值 and y<某值 then

事件

End If
End Sub