AnnGetPoint example for C++ 5.0 and later

Note: This topic is for Document/Medical only.

For more information on declaration and unlocking procedures used in testing this example, refer to Annotation Declaration Information.

void CRasterAnnSink::OnAnnDrawn(long hAnnObject)
{
   AnnObjectType nType; 
   long i; 
   long nPoints;     //number of points in the object
   CString strMsg; 
   CString strTmp; 
   float x,y; 
   ILEADRasterVariant * pltRasVarX = NULL; 
   ILEADRasterVariant * pltRasVarY = NULL; 

   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant, (void **)&pltRasVarX); 
   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant, (void **)&pltRasVarY); 
   
   m_pDlg->m_pRasterAnn->AnnGetType(hAnnObject); 
   nType  = m_pDlg->m_pRasterAnn->GetAnnType();
   if (nType == ANN_OBJECT_POLYGON) //Is the object a polygon? 
   {      
      AfxMessageBox(TEXT("Object is a Polygon"));
      m_pDlg->m_pRasterAnn->AnnGetPointCount(hAnnObject); //get the number of points
         nPoints = m_pDlg->m_pLEADRasterAnn->getAnnPointCount();
      m_pDlg->m_pRasterAnn->AnnGetPointX(hAnnObject, pltRasVarX);     //get the X coordinates
      m_pDlg->m_pRasterAnn->AnnGetPointY(hAnnObject, pltRasVarY);     //get the Y coordinates
      
      strMsg.Format(TEXT("The polygon points [%d] are: "), nPoints); 
      
      for (i=0; i<nPoints; i++)
      {
         x = pltRasVarX->FloatItemValue(i); 
         y = pltRasVarY->FloatItemValue(i); 
         strTmp.Format(TEXT("{%g,%g}  "), x, y); 
         strMsg += strTmp; 
      }   
               
      strMsg += TEXT(")");
      AfxMessageBox(strMsg); 
   }

   pltRasVarX->Release ();
   pltRasVarY->Release ();
}