首页 » Visual Basic » VB获取鼠标所在窗口的句柄

VB获取鼠标所在窗口的句柄

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 hWnd As Long
   Dim NowPOINT As POINTAPI
   GetCursorPos NowPOINT    '将鼠标所在坐标赋给 nowpoint
   hWnd = WindowFromPoint(NowPOINT.x, NowPOINT.y) '获取 在指定坐标窗口句柄
   Label1.Caption = hWnd
End Sub

, , ,

转发到新浪微博 转发到新浪微博

目前这篇文章有140条评论(Rss)

我要评论