Click to See Complete Forum and Search --> : Mouse & Handles


December 12th, 1999, 01:43 PM
I was wondering how to get the handle of a window that the mouse is currently over. If anyone has any ideas/suggestions i'd appreciate your response.

Thank You.
Lynx

Vanclei Matheus
December 13th, 1999, 11:54 AM
You may try this code:

Paste into your module


public Type POINTAPI
x as Long
y as Long
End Type

public Declare Function WindowFromPoint Lib "user32" (byval xPoint as Long, byval yPoint as Long) as Long
public Declare Function GetCursorPos Lib "user32" (lpPoint as POINTAPI) as Long




This will get the handle of the window that the mouse is over, but how can i take this event? As a solution to this problem I use the MouseUp Event of the Form, as described above:


private Sub Form1_MouseUp(...)
Dim lhWnd as Long
Dim lDummy as Long

Dim xCursor as POINTAPI

lDummy=GetCursorPos(xCursor)

'This line will return the handle
lhWnd=WindowFromPoint(xCursor.x,xCursor.y)
End Sub




so, when the user click in your window and drag releasing the mouse over other window, the application will get the handle of window where are the mouse pointer.

(sorry about my english)

Vanclei Matheus
techno_dreamer@yahoo.com.br
Techno Dreamer

December 13th, 1999, 03:39 PM
Hey that worked, thanks!

now i just want to know how to be able to do that by dragging and releasing an icon over the desired window.