AnnSelect 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 for the AnnSelect event displays a message box showing the number of selected annotation objects. It then goes through the array of selected objects to see if any of them are polygons.*/
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_ANNSELECT:
{
int nType;
int x;
int nPolyCount;
ILEADRasterVariant* pRasterVarObjects= NULL;
int nCount;
int hObject;
nPolyCount = 0;
nCount = (OleVariant)(Params.rgvarg[0]);
pRasterVarObjects= (ILEADRasterVariant*)(Params.rgvarg[1].pdispVal);
for (x = 0; x < nCount; x ++ )
{
hObject= pRasterVarObjects->get_LongItemValue(x);
pRasterAnn->AnnGetType(hObject);
nType= pRasterAnn->get_AnnType_ ( );
if (nType == ANN_OBJECT_POLYGON)
nPolyCount ++;
}
ShowMessage (IntToStr(nCount) + " objects were selected. " + IntToStr(nPolyCount) + " Polygon Objects were selected");
}
break;
}
}