AnnSelect example for C++ 4.0 and later

Note: This topic is for Document/Medical only.

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 CMfc40Dlg::OnAnnSelect Lead1(const VARIANT FAR& aObjects, short uCount) 
{
  int nType;
  long x;
  int bSelected = 0;
  CString msg;
  int hObject;

  msg.Format("%d",uCount);
  msg = msg + " objects were selected";
  AfxMessageBox ((LPCTSTR)msg);

  for (x=0; x<uCount; x++)
  {
    SafeArrayGetElement(aObjects.parray, &x, &hObject);
    nType = m_Lead1.AnnGetType(hObject);
    if (nType == ANNOBJECT_POLYGON)
        bSelected = TRUE;
  }
  if (bSelected != TRUE)
    AfxMessageBox("No Polygon Objects were selected");
}