Author: Erwin Molendijk
Using the Windows API function ClipCursor, it is possible to restrict the movement
of the mouse to a specific rectangular region on the screen.
Answer:
1 //restrict the mouse mouvement to form and release2 //this restriction after a click on the form3 4 procedure TForm1.FormCreate(Sender: TObject);
5 var6 r: TRect;
7 begin8 //it would be good idea to move the9 //mouse inside the form before restriction10 r := BoundsRect;
11 ClipCursor(@R);
12 end;
13 14 procedure TForm1.FormClick(Sender: TObject);
15 begin16 //always be sure to release the cursor17 ClipCursor(nil);
18 end;