mouse move event

L

Logan Mckinley

I need to be able to detect mouse movement even when it is not over my
application. I can get the mouse cords using MousePosition but I am not
sure if there is an event that hits my program when the mouse is not over my
program.
One idea i had was make a child form that was transparent and use the
MouseMove event to keep that transparent window under the mouse but the
transparent window did not catch the MouseMove event.
I also tried putting a timer on the form that checks MousePosition but to
make it smooth i would have to check it so often that it is to processor
intensive.

Any help is appriciated,
Thanks in advance,
~Logan
 
R

Rafael J. Pellicer

With API: GetCursorPos Lib "user32" Alias "GetCursorPos" (lpPoint As
POINTAPI) As Long
 
L

Logan Mckinley

Am i correct that this API will just return the location of the mouse? If
so I am currently able to get that using "Cursor.Position". My problem is i
need to query this every time the mouse moves and don't know the event that
fires when the mouse is not over my form.
Thanks,
~Logan
 
M

Magnus Persson

You need to "Capture" the mouse, otherwise you will not receive mouse events
when pointer is outside your window.
To do this you set the Capture property of your form to true. When ever your
application looses focus you should set the Capture property back to false.

Normally you only use this "capture" function in controls within a form. If
you capture mouse events outside your main form I guess you need to pass the
events on to the window that the mouse hoovers.

/Magnus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top