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.