把那个程序加一句代码就行了,红色那句是我新加上去的!
Dim meCaption As GetWindowsText
Dim mePos As CursorPos
Dim meHwnd As windowsRfromPoint
Private Sub Form_Load()
Set mePos = New CursorPos
Set meHwnd = New windowsRfromPoint
Set meCaption = New GetWindowsText
End Sub
Private Sub Timer1_Timer()
Text1.Text = ""
mePos.CurrsorPos
meHwnd.X = mePos.PosX
meHwnd.Y = mePos.PosY
meCaption.FrmHwnd = meHwnd.windowsRfromPoint
Text1.Text = meCaption.Caption
Me.Caption = "鼠标指向此窗体的句柄是:" & meHwnd.windowsRfromPoint
End Sub
这是我封装好的api
改成这样吧.美观些
Dim meCaption As New GetWindowsText
Dim mePos As New CursorPos
Dim meHwnd As New windowsRfromPoint
Private Sub Timer1_Timer()
Text1.Text = ""
mePos.CurrsorPos
meHwnd.X = mePos.PosX
meHwnd.Y = mePos.PosY
meCaption.FrmHwnd = meHwnd.windowsRfromPoint
Text1.Text = meCaption.Caption
Me.Caption = "鼠标指向此窗体的句柄是:" & meHwnd.windowsRfromPoint
End Sub