[RESOLVED] Detect mouse movement outside form.
Hello all,
I'm creating a video player. When a video is playing fullscreen, I would like for a menu to appear when the mouse moves, but no event is triggered. The video 'covers' the form, so the form's MouseMove event is not triggered upon mouse movement.
Is there a way to trigger an event when mouse movement is detected?
If not, is there a way to get the cursor position?
Then, I could (in combination with a timer) compare the location of the cursor now and that of a few moments ago to register mouse momevent.
Thanks.
Re: Detect mouse movement outside form.
I found out how to get mouse position. It was so much simpler than expected that I completely overlooked this:
VB Code:
Dim MouseX As Integer
MouseX = CInt(Cursor.Position.X.ToString())
If some-one knows how to trigger an event on mouse movement, I would still like to know, though. Because using this in combination with a timer is not quite Feng Shui. :bigyello:
Re: Detect mouse movement outside form.
I hate the VB timmer. I'd just create a thread that just loops looking for mouse moves and then raises the event.
I've also seen buttons that are invisable that reside over other controls, but I can't seem to make this work in Vb.
Re: Detect mouse movement outside form.
I can't put controls over the video, the video covers all. I need to use another form to display a menu over the video.
By the way, don't continuous loops take up loads of CPU?
Re: Detect mouse movement outside form.
The one I used did not, however I had a ...thread.sleep(50) and ...DoEvents() in it.
Re: Detect mouse movement outside form.
what control are you using to play the video?
Re: Detect mouse movement outside form.
If the video control is in your form, you may try to capture the event in the WndProc()
VB Code:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
'check events......
mybase.WndProc(m)
End Sub
Re: Detect mouse movement outside form.
I use a panel control to play the video in.
I use the API-functions mciSendString and mciGetErrorString to play the video. This supports many files, but requires some hard coding.