AnnRestrictCursor example for Delphi

Procedure TForm1.ExampleAnnRestrictCursor ( hObject: HANNOBJECT );
var
   hContainer: L_INT32;
   nObjectType: L_INT;
   dBoundsTop: L_DOUBLE;
   dBoundsLeft: L_DOUBLE;
   dBoundsWidth: L_DOUBLE;
   dBoundsHeight: L_DOUBLE;
   dBoundsRight: L_DOUBLE;
   dBoundsBottom: L_DOUBLE;
   rcClipOld: TRect;
begin
    nObjectType:= LEADAnn1.AnnGetType(hObject);

   if(( nObjectType = ANNOBJECT_AUTOMATION) And (nObjectType = ANNOBJECT_CONTAINER) ) then
   begin
      ShowMessage( 'This object is not an Automation Object and it is not a Container Object.');
   end;

   hContainer:= LEADAnn1.AnnContainer;

   dBoundsTop:= LEADAnn1.AnnRectTop[hObject];
   dBoundsLeft:= LEADAnn1.AnnRectLeft[hObject];
   dBoundsWidth:= LEADAnn1.AnnRectWidth[hObject];
   dBoundsHeight:= LEADAnn1.AnnRectHeight[hObject];

   LEADAnn1.PointsCount:= 2;
   LEADAnn1.AnnContainerPointX[2]:= dBoundsLeft;
   LEADAnn1.AnnContainerPointY[2]:= dBoundsTop;
   LEADAnn1.AnnConvert(hObject, ANNCONVERT_TO_CLIENT);

   dBoundsLeft:= LEADAnn1.ClientPointX[0];
   dBoundsTop:= LEADAnn1.ClientPointY[0];

   dBoundsRight:= (dBoundsWidth + dBoundsLeft) + 10;
   dBoundsBottom:= (dBoundsHeight + dBoundsTop) + 10;
   dBoundsTop:= dBoundsTop - 10;
   dBoundsLeft:= dBoundsLeft - 10;

   LEADAnn1.AnnRestrictCursor(hContainer, Trunc(dBoundsLeft), Trunc(dBoundsTop), Trunc(dBoundsRight), Trunc(dBoundsBottom), 0, 0, FALSE);

   rcClipOld.Top:= LEADAnn1.AnnTopPreviousClip;
   rcClipOld.Left:= LEADAnn1.AnnLeftPreviousClip;
   rcClipOld.Right:= LEADAnn1.AnnRightPreviousClip;
   rcClipOld.Bottom:= LEADAnn1.AnnBottomPreviousClip;

   // When done with the restricted cursor, use the line below
   //ClipCursor ( @rcClipOld );
end;