Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF MouseMove Event Polling

I've created a WPF application where the title bar and chrome are turned off. I have a border around the entire app, with the idea that it would act like the chrome in some regards. The first thing I'm trying to do is have the mousemove event capture the movement of the mouse when the mouse is clicked, so that the window moves with the mouse. The problem is that if the mouse moves too quickly, it manages to leave the window and therefore the mousemove no longer fires. I've been able to do this with a normal WinForm with no problems regardless of the speed of the mouse. Is there any way to do this more efficiently, or perhaps tune the polling of the mousemove? Perhaps a different container other than border that would perform better?

like image 745
CodeMonkey1313 Avatar asked Dec 08 '25 12:12

CodeMonkey1313


2 Answers

Try Me.DragMove in the window's left click event handler. It much better than most custom solutions.

like image 80
Bryan Anderson Avatar answered Dec 11 '25 01:12

Bryan Anderson


When the user clicks you should capture the mouse (see Mouse.Capture). That way, you'll get the mouse events regardless of whether the mouse cursor is over your element or not.

like image 29
Kent Boogaart Avatar answered Dec 11 '25 02:12

Kent Boogaart



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!