Article ID: 138518
Article Last Modified on 12/9/2003
#If Win32 Then
Declare Function WindowFromPointXY Lib "User32" _
Alias "WindowFromPoint" (ByVal xPoint As Long, _
ByVal yPoint As Long) As Long
#Else
Declare Function WindowFromPointYX Lib "User" _
Alias "WindowFromPoint" (ByVal yPoint As Integer, ByVal _
xPoint As Integer) As Integer
#End If
Function VBWindowFromPoint(ByVal x As Long, ByVal y As Long) As Long
#If Win32 Then
VBWindowFromPoint = WindowFromPointXY(x, y)
#Else
VBWindowFromPoint = WindowFromPointYX(y, x)
#End If
End Function
' Convert form coordinates to screen coordinates screenX = X + Form1.Left / Screen.TwipsPerPixelX screenY = Y + Form1.Top / Screen.TwipsPerPixelY ' Retrieve the window handle hWindow = VBWindowFromPoint(screenX, screenY) If hWindow = Form1.hWnd Then MsgBox "Success" End If
Additional query words: 4.00 vb4win vb4all
Keywords: KB138518