How to restrict mouse moving area in Delphi

It's very simple. Just drop TSystemMouse component onto your form. It can restrict mouse moving area by bounds or client are of owner form, any other form, any control on any form and any window in the system by handle. Also you can restrict moveing area by any rectangle in screen coordinates.

with cmpSystemMouse do
begin
  Clipping:=clipByRect;
  with Screen do
    ClipRect:=Rect(Width div 4,Height div 4,3*Width div 4,3*Height div 4);
end;

cmpSystemMouse.Clipping:=clipByFormClient;

The following code restrict mouse moving area after the click on control, so user can move mouse only within this control:

procedure TfrmSysMouseMain.btnClipByControlBoundsClick(Sender: TObject);
begin
  with cmpSystemMouse do
  begin
    Clipping:=clipByControlBounds;
    ClipControl:=Sender as TControl;
  end;
end;
See also
System Mouse
Components for Delphi / C++ Builder
Howtos for Programmers