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.

Published on: 12/21/2000 12:00:00 AM

Server Response from: ETNASC04

Copyright© 1994 - 2013 Embarcadero Technologies, Inc. All rights reserved.