在VB中,如何获取鼠标所在的点处的控件句柄
不论鼠标放在屏幕的何处,该处都必须有某一个控件,必须有它的句柄。如何获取鼠标所在处的控件句柄呢...
不论鼠标放在屏幕的何处,该处都必须有某一个控件,必须有它的句柄。如何获取鼠标所在处的控件句柄呢
展开
2个回答
展开全部
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim a As POINTAPI
GetCursorPos a
b = WindowFromPoint(a.x, a.y)
Me.Caption = b
End Sub
添加一个timer控件 代码如上 取得句柄在窗体标题处显示
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Timer1_Timer()
Dim a As POINTAPI
GetCursorPos a
b = WindowFromPoint(a.x, a.y)
Me.Caption = b
End Sub
添加一个timer控件 代码如上 取得句柄在窗体标题处显示
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询