Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
GetWindowFromPoint
View previous topic :: View next topic  
Author Message
Gilad_r
Centurion


Joined: 03 Mar 2004
Posts: 156

PostPosted: Apr 20th, 2004 04:48 PM    Post subject: GetWindowFromPoint Reply with quote

this function is used to get a window handle from a point on the screen.
it doesn't ignore disabled windows, and returns the deepest descendent possible.

[vb:1:65a03520f0] Public Function GetWindowFromPoint(ByVal X As Long, ByVal Y As Long) As Long

Dim p As POINTAPI, ch As Long, h As Long

ch = WindowFromPoint(X, Y)

Do

h = ch
p.X = X: p.Y = Y
ScreenToClient h, p
ch = RealChildWindowFromPoint(h, p.X, p.Y)

Loop Until ch = h Or ch = 0

GetWindowFromPoint = h

End Function[/vb:1:65a03520f0]

the declarations:
[vb:1:65a03520f0] Private Type POINTAPI
X As Long
Y As Long
End Type

Private Declare Function WindowFromPoint Lib "user32" _
(ByVal xPoint As Long, _
ByVal yPoint As Long) As Long

Private Declare Function RealChildWindowFromPoint Lib "user32" _
(ByVal hWndParent As Long, _
ByVal xPoint As Long, _
ByVal yPoint As Long) As Long

Private Declare Function ScreenToClient Lib "user32" _
(ByVal hWnd As Long, _
lpPoint As POINTAPI) As Long[/vb:1:65a03520f0]

enjoy.
Gilad
_________________
"you should make amends with you" (Incubus)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic