AnnGetPoint... example for C++ 4.0 and later
Note: This topic is for Document/Medical only.
In the AnnDrawn event, this example checks to see if the annotation object is a polygon. If it is a polygon, the example gets the number of points that define the object; then it gets the arrays of X and Y coordinates and displays the points in a message box.
void CMfc40Dlg::OnAnnDrawnLead1(long hObject)
{
int nType;
long a;
VARIANT xPoints; //array for the X coordinates
VARIANT yPoints; //array for the Y coordinates
long nPoints; //number of points in the object
CString msg;
CString msg2;
float x;
float y;
nType = m_Lead1.AnnGetType(hObject);
if (nType == ANNOBJECT_POLYGON) //Is the object a polygon?
{
VariantInit(&xPoints);
VariantInit(&yPoints);
AfxMessageBox("Object is a Polygon");
m_Lead1.SetEnableMethodErrors(FALSE);
nPoints = m_Lead1.AnnGetPointCount(hObject); //get the number of points
xPoints = m_Lead1.AnnGetPointX(hObject); //get the X coordinates
yPoints = m_Lead1.AnnGetPointY(hObject); //get the Y coordinates
msg = "(";
for (a=0; a<nPoints; a++)
{
msg = msg + "{";
SafeArrayGetElement(xPoints.parray, &a, &x);
msg2.Format("%g", x);
msg = msg + msg2;
msg = msg + ",";
msg2.Empty();
SafeArrayGetElement(yPoints.parray, &a, &y);
msg2.Format("%g", y);
msg = msg + msg2;
msg = msg + "}";
}
VariantClear(&xPoints);
VariantClear(&yPoints);
msg = msg + ")";
msg2.Empty;
msg2.Format("The Polygon's %ld points:", nPoints);
::MessageBox(NULL,(LPCTSTR) msg,(LPCTSTR) msg2,MB_OK);
}
}