Create example for C++ 5.0 and later
For more information on declaration and unlocking procedures used in testing this example, refer to Annotation Declaration Information.
//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 tool and button tool)
void CTutorDlg::CreateToolBar (ILEADRasterAnnToolBar * pAnnToolBar)
{
//Attach the annotation object to the raster view control
IDispatch *pDispatch=NULL;
LPUNKNOWN pIUnknownNoRelease = m_LEADRasterView1.GetControlUnknown();
pIUnknownNoRelease->QueryInterface(IID_IDispatch, (void**)&pDispatch);
pAnnToolBar->PutAnnParentRasterView(pDispatch);
if(pDispatch)
pDispatch->Release();
pAnnToolBar->PutVisible (VARIANT_TRUE);
pAnnToolBar->Create(0.0f, 0.0f, ANN_TOOLALIGN_TOP);
if (!pAnnToolBar->GetToolBarhWnd())
return;
//load button images
ILEADRasterIO *pRasterIO=NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
pAnnToolBar->PutButtonTool(pAnnToolBar->GetButtonCount(), ANN_TOOL_USER_FIRST);
pRasterIO->Load (m_LEADRasterView1.GetRaster(), "e:\\lead14\\dist\\images\\Ulay1.bmp", 0, 0, 1);
pAnnToolBar->PutButtonBitmapUp(pAnnToolBar->GetButtonCount(), m_LEADRasterView1.GetRaster().GetBitmap());
pRasterIO->Load(m_LEADRasterView1.GetRaster(), "e:\\lead14\\dist\\images\\Ulay2.bmp", 0, 0, 1);
pAnnToolBar->PutButtonBitmapDown(pAnnToolBar->GetButtonCount(), m_LEADRasterView1.GetRaster().GetBitmap());
pRasterIO->Release();
pAnnToolBar->PutButtonToolTipTextID(pAnnToolBar->GetButtonCount(), -1);
pAnnToolBar->PutButtonToolTipText (pAnnToolBar->GetButtonCount (), "User defined tool");
CString strMsg;
CString strToolText = (char *)pAnnToolBar->GetButtonToolTipText(pAnnToolBar->GetButtonCount());
strMsg.Format(TEXT("AnnToolTipText: %s"), strToolText);
AfxMessageBox(strMsg);
//associate to menu items with the newly added button
int nButtonCount = pAnnToolBar->GetButtonCount();
pAnnToolBar->PutButtonToolCount(nButtonCount, 2);
pAnnToolBar->PutButtonMenuTool(nButtonCount, 0, ANN_TOOL_LINE);
pAnnToolBar->PutButtonMenuTextID(nButtonCount, 0, -1);
pAnnToolBar->PutButtonMenuText(nButtonCount, 0, "Line Tool");
pAnnToolBar->PutButtonMenuTool(nButtonCount, 1, ANN_TOOL_BUTTON);
pAnnToolBar->PutButtonMenuTextID(nButtonCount, 1, -1);
pAnnToolBar->PutButtonMenuText(nButtonCount, 1, "Button");
pAnnToolBar->PutButtonCount(nButtonCount + 1);
m_pRasterAnn->PutAnnUserMode(ANN_USERMODE_DESIGN);
m_pRasterAnn->PutAutoSetTool(VARIANT_TRUE);
}