AnnGetSelectList example for Delphi

Note:

This topic is for Document/Medical only.

This example gets the number of selected annotation objects; then it gets an array of the selected object handles and checks to see if any of the objects in the array are polygons.

var
//Global declarations
RasterAnn: LEADRasterAnnotation;
RasterAnnToolbar: LEADRasterAnnToolBar;

procedure TForm1.Button1Click(Sender: TObject);
begin
   RasterAnn:= CoLEADRasterAnnotation.Create ();
   RasterAnnToolbar:= CoLEADRasterAnnToolBar.Create ();
   RasterAnn.AnnParentRasterView := LEADRasterView1.Raster;
   LEADEventSink1.Connect (RasterAnn, _LEADRasterAnnotationEvents);
   RasterAnn.AnnUserMode:= ANN_USERMODE_DESIGN;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
   lType: TOleEnum;
   a: Integer;
   bSelected: Boolean;
   nCount: Integer;
   RasterVar: LEADRasterVariant; //array for the selected object handles
Begin
   RasterVar:= CoLEADRasterVariant.Create ( );
   bSelected:= False;
   RasterAnn.AnnGetSelectCount();
   nCount:= RasterAnn.AnnSelectCount;//get number of selected objects
   RasterAnn.AnnGetSelectList (RasterVar); //get the handles of the selected objects
   ShowMessage (IntToStr(nCount) + ' objects were selected');
   for a:= 1 to nCount do
   begin
      RasterAnn.AnnGetType ( RasterVar.LongItemValue[a - 1] );
      lType:= RasterAnn.AnnType;
      if (lType = ANN_OBJECT_POLYGON) then  //Is the object a polygon?
         bSelected:= True;
   end;
   if (bSelected <> True) then
      ShowMessage ('No Polygon Objects were selected');
end;