I attached several MouseMove and MouseClick events to my program, and the following is one of them:
- Get a "global" mouse movement so that I can read the location of the mouse even outside the form.
- Do not let my mouse leave the form in the first place.
My project is a game, so it would be great if the mouse did not leave my form, as in most other games (for example, you can move it if you switch focus using alt + tab fe.) And look at the answers to other issues requiring a global movement of monsieur, they seem pretty dirty for my needs.
Is there an easy way to prevent my mouse from going beyond my form? Or, firstly, so that it does not cross borders in the first place, I want the mouse to remain inside the client area.
Additional information about the game:
The game is a short game lasting 5-30 seconds (it gets too heavy after 30 seconds to keep you alive), where you have to dodge bullets with the mouse. This is very annoying when you push the mouse out of the form, and then the player ( System.Windows.Forms.Panel attached to the mouse) stops and instantly hits the bullet. This is why preventing the mouse from moving out of the area would be nice.
user2032433
source share