AnnAddUserHandle example for Delphi

Procedure TForm1.ExampleAnnAddUserHandle ( hObject: HANNOBJECT );
var
   nObjectType: L_INT;
   RectTop: L_INT32;
   RectLeft: L_INT32;
   RectWidth: L_INT32;
   RectHeight: L_INT32;
begin
   nObjectType:= LEADAnn1.AnnGetType(hObject);
     if(nObjectType = ANNOBJECT_RECT ) then
   begin
      RectTop:= Trunc(LEADAnn1.AnnRectTop[hObject]);
      RectLeft:= Trunc(LEADAnn1.AnnRectLeft[hObject]);
      RectWidth:= Trunc(LEADAnn1.AnnRectWidth[hObject]);
      RectHeight:= Trunc(LEADAnn1.AnnRectHeight[hObject]);

      LEADAnn1.AnnHandle.ID:= 100;
      LEADAnn1.AnnHandle.Visible:= true;
      LEADAnn1.AnnHandle.PenColor:= RGB(0, 0, 0);
      LEADAnn1.AnnHandle.FillColor:= RGB(255, 0, 0);
      LEADAnn1.AnnHandle.Shape:= ANNHANDLE_SHAPE_CIRCLE;
      LEADAnn1.AnnHandle.Cursor:= 0;

      LEADAnn1.AnnHandle.Flags:= ANNHANDLE_ID +
                                 ANNHANDLE_LOCATION +
                                 ANNHANDLE_CONTAINER_COORDINATES +
                                 ANNHANDLE_VISIBLE +
                                 ANNHANDLE_PEN_COLOR +
                                 ANNHANDLE_FILL_COLOR +
                                 ANNHANDLE_SHAPE;

      LEADAnn1.AnnHandle.ContainerX:= RectLeft + (RectWidth / 2);
      LEADAnn1.AnnHandle.ContainerY:= RectTop;

      LEADAnn1.AnnHandle.ContainerX:= RectLeft + (RectWidth / 2);
      LEADAnn1.AnnHandle.ContainerY:= RectTop + RectHeight;

      LEADAnn1.AnnAddUserHandle (hObject);
   end
   else
   begin
      ShowMessage ('Annotation object must be a rectangle');
   end;
end;