How do I limit the movement of the mouse cursor?

By: Vincent Drake

Abstract: How to "trap" the mouse in an area.


How do I limit the mouse movement to a certain area?


Use the Windows API function ClipCursor(). For example, insert this code into a form's OnMouseDown event handler:


and this code to the form OnMouseUp event handler:


When you click and hold the mouse on the form, you will not be able to move the mouse outside of the form.

Server Response from: ETNASC04