Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Mouse Cursor from Moving Horizontally, but still want to capture MouseMove Events

In my winforms app, I have a feature that opens a dropdown menu, and you move your cursor left or right to select a sub-option. But, I don't want the cursor to move, I just want the sub-options them selves to move left or right (depending on which direction the mouse is trying to move in). I hope this makes sense to you.

Does anyone know how to stop the cursor from moving in a particular direction, while still being able to capture mousemove events while the user "moves" the mouse?

Any help is appreciated, Thank you!

like image 447
βӔḺṪẶⱫŌŔ Avatar asked Jan 30 '26 23:01

βӔḺṪẶⱫŌŔ


2 Answers

You should not try to implement this, as it breaks all user interface standards and will just confuse the user. It's not up to your application to decide where the mouse should be able to move. If you want to implement some other way of allowing navigation selection then I would suggest investigating other options.

like image 178
Ira Rainey Avatar answered Feb 01 '26 13:02

Ira Rainey


I don't think you should implement such a solution at all.

But well, you could set the mouse cursor position back to its original position within the MouseMove Handler. But you have to remove the handler before setting back the position and adding them again after this. You can set the Mouse position via pInvoke. How to do that, you can find here http://pinvoke.net/default.aspx/user32.mouse_event

like image 22
DanielB Avatar answered Feb 01 '26 15:02

DanielB



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!