AnnGetSelectList example for C++ Builder

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.

//Global declarations
LEADRasterAnnotation * pRasterAnn= NULL;
LEADRasterAnnToolBar* pRasterAnnToolbar= NULL;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
   CoCreateInstance(CLSID_LEADRasterAnnotation, NULL, CLSCTX_ALL, IID_ILEADRasterAnnotation, (void**)&pRasterAnn);
   CoCreateInstance(CLSID_LEADRasterAnnToolBar, NULL, CLSCTX_ALL, IID_ILEADRasterAnnToolBar, (void**)&pRasterAnnToolbar);
   pRasterAnn->AnnParentRasterView = LEADRasterView1->Raster;
   LEADEventSink1->Connect (pRasterAnn, DIID__LEADRasterAnnotationEvents);
   pRasterAnn->AnnUserMode = ANN_USERMODE_DESIGN ;
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
   if (pRasterAnn)
      pRasterAnn->Release ();
   if (pRasterAnnToolbar)
      pRasterAnnToolbar-> Release();
}

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   AnnObjectType nType;
   int a;
   bool bSelected;
   int nCount;
   int hObject;
   ILEADRasterVariant* pRasterVarObjects; //array for the selected object handles
   bSelected= False;

   CoCreateInstance( CLSID_LEADRasterVariant,
                     NULL,
                     CLSCTX_ALL,
                     IID_ILEADRasterVariant,
                     (void**)&pRasterVarObjects);

   pRasterAnn->AnnGetSelectCount( );
   nCount= pRasterAnn->AnnSelectCount;//get number of selected objects 
   pRasterAnn->AnnGetSelectList( pRasterVarObjects ); //get the handles of the selected objects
   ShowMessage (IntToStr(nCount) + " objects were selected" );
   for (a = 0; a < nCount; a ++)
   {
      hObject= pRasterVarObjects->get_LongItemValue(a);
      pRasterAnn->AnnGetType(hObject);
      nType= pRasterAnn->get_AnnType_();
      if (nType == ANN_OBJECT_POLYGON)   //Is the object a polygon?
         bSelected = True;
   }
   if (!bSelected)
      ShowMessage ("No Polygon Objects were selected");
   if ( pRasterVarObjects )
   {
      pRasterVarObjects->Release();
      pRasterVarObjects= NULL;
   }
}