AnnSelect example for Delphi

var
//Global declarations
RasterAnn: LEADRasterAnnotation;
procedure TForm1.Button1Click(Sender: TObject);
begin
   RasterAnn:= CoLEADRasterAnnotation.Create ();
   RasterAnn.AnnParentRasterView := LEADRasterView1.Raster;
   LEADEventSink1.Connect (RasterAnn, _LEADRasterAnnotationEvents);
   RasterAnn.AnnUserMode:= ANN_USERMODE_DESIGN;
end;

//This example for the AnnSelect event displays a message box showing the number of //selected procedure TForm1.LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
  const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
  varResult, ExcepInfo, ArgErr: Pointer);
var
   nType: AnnObjectType;
   x: Integer;
   nPolyCount: Integer;
   nCount: Integer;
   RasterVarObjects: LEADRasterVariant;
begin
   case (DispID) of
      LEADRASTERANNOTATIONEVENTS_ANNSELECT:
      begin
         nCount:= OleVariant(Params.rgvarg^[0]);
         RasterVarObjects:= LEADRasterVariant(Params.rgvarg^[1].dispVal);
         nPolyCount:= 0;
         for x:= 0 to nCount-1 do
         begin
              RasterAnn.AnnGetType (RasterVarObjects.LongItemValue[x]);
            nType:= RasterAnn.AnnType;
              if nType = ANN_OBJECT_POLYGON then
               nPolyCount:= nPolyCount + 1;
           end;
         ShowMessage (IntToStr(nCount) + ' objects were selected.  ' + IntToStr(nPolyCount) + ' Polygon Objects were selected');
      end;
   end;
end;