Create example for C++ Builder
//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();
}
/*This example creates an annotation toolbar and adds a button to the toolbar.
The button displays different images when selected/deselected
The button has two tools associated with (line and button tool)*/
void __fastcall TForm1::CreateToolBarClick(TObject *Sender)
{
LEADRasterIO* pRasterIO= NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
pRasterAnnToolbar->AnnParentRasterView = LEADRasterView1->Raster;
pRasterAnnToolbar->Visible = True;
pRasterAnnToolbar->Create (0, 0, ANN_TOOLALIGN_TOP);
if (pRasterAnnToolbar->ToolBarhWnd)
{
AnsiString Msg;
BSTR strToolText;
pRasterAnnToolbar->set_ButtonTool (pRasterAnnToolbar->ButtonCount, ANN_TOOL_USER_FIRST);
pRasterIO->Load (LEADRasterView2->Raster, AnsiToOLESTR("e:\\lead14\\dist\\images\\Ulay1.bmp"), 0, 0, 1);
pRasterAnnToolbar->set_ButtonBitmapUp (pRasterAnnToolbar->ButtonCount, LEADRasterView2->Raster->Bitmap);
pRasterIO->Load (LEADRasterView2->Raster, AnsiToOLESTR("e:\\lead14\\dist\\images\\Ulay2.bmp"), 0, 0, 1);
pRasterAnnToolbar->set_ButtonBitmapDown (pRasterAnnToolbar->ButtonCount, LEADRasterView2->Raster->Bitmap);
pRasterAnnToolbar->set_ButtonToolTipTextID (pRasterAnnToolbar->ButtonCount, -1);
pRasterAnnToolbar->set_ButtonToolTipText (pRasterAnnToolbar->ButtonCount, AnsiToOLESTR("User defined tool"));
pRasterAnnToolbar->get_ButtonToolTipText((short)pRasterAnnToolbar->ButtonCount, &strToolText);
Msg = "AnnToolTipText: ";
Msg += strToolText;
ShowMessage (Msg);
pRasterAnnToolbar->set_ButtonToolCount (pRasterAnnToolbar->ButtonCount, 2);
pRasterAnnToolbar->set_ButtonMenuTool (pRasterAnnToolbar->ButtonCount, 0, ANN_TOOL_LINE);
pRasterAnnToolbar->set_ButtonMenuTextID (pRasterAnnToolbar->ButtonCount, 0, -1);
pRasterAnnToolbar->set_ButtonMenuText (pRasterAnnToolbar->ButtonCount, 0, AnsiToOLESTR("User defined tool"));
pRasterAnnToolbar->set_ButtonMenuTool(pRasterAnnToolbar->ButtonCount, 1, ANN_TOOL_BUTTON);
pRasterAnnToolbar->set_ButtonMenuTextID(pRasterAnnToolbar->ButtonCount, 1, -1);
pRasterAnnToolbar->set_ButtonMenuText(pRasterAnnToolbar->ButtonCount, 1, AnsiToOLESTR("Button"));
pRasterAnnToolbar->ButtonCount++;
pRasterAnn->AnnUserMode = ANN_USERMODE_DESIGN;
pRasterAnn->AutoSetTool = True;
}
pRasterIO-> Release( );
}