AnnToolChecked 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:: LEADEventSink1Invoke(TObject *Sender, int DispID,
      const TGUID &IID, int LocaleID, WORD Flags, tagDISPPARAMS &Params,
      Pointer varResult, Pointer ExcepInfo, Pointer ArgErr)
{
   switch (DispID)
   {
        case LEADRASTERANNOTATIONEVENTS_ANNTOOLCHECKED:
      {
         int iTool = (OleVariant)(Params.rgvarg[0]);
         AnsiString TestString;

         switch (iTool)
         {
            case ANN_TOOL_SELECT:
                 TestString = "Selection pointer tool";
               break;

            case ANN_TOOL_LINE:
                 TestString = "Line tool";
               break;

            case ANN_TOOL_RECT:
               TestString = "Rectangle tool";
               break;

            case ANN_TOOL_ELLIPSE:
                 TestString = "Ellipse tool";
               break;
            //...
            //...
            //...
            default:
                 TestString = "User defined tool";
         }
         ShowMessage (TestString);
        }
      break;
   }
}