AnnGetHyperlinkType 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 examples determines the type of the hyperlink and then displays the
//params if the type is ANN_LINK_ANNEVENT or ANN_LINK_ANNEVENT5
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_ANNHYPERLINK:
{
int lParam5= OleVariant(Params.rgvarg[0]);
int lParam4= OleVariant(Params.rgvarg[1]);
int lParam3= OleVariant(Params.rgvarg[2]);
int lParam2= OleVariant(Params.rgvarg[3]);
int lParam1= OleVariant(Params.rgvarg[4]);
int iParamCount= OleVariant(Params.rgvarg[5]);
int hObject= OleVariant(Params.rgvarg[6]);
AnsiString msgStr;
short nType;
pRasterAnn->AnnGetHyperlinkType (hObject);
nType= pRasterAnn->AnnHyperlinkType;
if ((nType == ANN_LINK_ANNEVENT5) || (nType == ANN_LINK_ANNEVENT))
{
if (iParamCount >= 0)
msgStr= IntToStr(iParamCount) + " params are valid \n";
if (iParamCount >= 1)
msgStr = msgStr + "Param1: " + IntToStr(lParam1) + "\n";
if (iParamCount >= 2)
msgStr = msgStr + "Param2: " + IntToStr(lParam2) + "\n";
if (iParamCount >= 3)
msgStr = msgStr + "Param3: " + IntToStr(lParam3) + "\n";
if (iParamCount >= 4)
msgStr = msgStr + "Param4: " + IntToStr(lParam4) + "\n";
if (iParamCount == 5)
msgStr = msgStr + "Param5: " + IntToStr(lParam5) + "\n";
}
else
msgStr= "Invalid Type";
ShowMessage (msgStr);
}
break;
}
}