AnnLock example for C++ Builder

Note:

This topic is for Document/Medical only.

//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::AnnLockClick(TObject *Sender)
{
/*This example locks objects of type ANN_OBJECT_ELLIPSE using the key "LEADTOOLS".*/
   int nType;
   int x;
   bool bSelected;
   int nCount;
   ILEADRasterVariant* pRasterVarObjects= NULL; //array for the selected object handles
   int hObject;

   //lock only the ellipse objects that are selected

   bSelected = False;
   CoCreateInstance( CLSID_LEADRasterVariant,
                     NULL,
                     CLSCTX_ALL,
                     IID_ILEADRasterVariant,
                     (void**)&pRasterVarObjects);
   if ( pRasterVarObjects )
   {
      pRasterAnn->AnnGetSelectCount( );  //get number of selected objects
      nCount= pRasterAnn->AnnPointCount;
      pRasterAnn->AnnGetSelectList(pRasterVarObjects); //get the handles of the selected objects
      for (x = 0; x < nCount; x ++ )
      {
         hObject= pRasterVarObjects->get_LongItemValue(x);
         pRasterAnn->AnnGetType(hObject);
         nType= (short)pRasterAnn->get_AnnType_();
         if (nType == ANN_OBJECT_ELLIPSE)  //Is the object an ellipse?
         {
            bSelected = true;
            pRasterAnn->AnnLock(hObject, AnsiToOLESTR("LEADTOOLS"), false);
         }
      }
      if (bSelected != True)
         ShowMessage ("No Ellipse Objects were selected");

      if ( pRasterVarObjects )
      {
         pRasterVarObjects->Release();
         pRasterVarObjects= NULL;
      }
   }
}