AnnGetSelectList example for C++ 4.0 and later

Note: This topic is for Document/Medical only.

This example gets the number of selected annotation objects; then it gets an array of the selected object handles and checks to see if any of the objects in the array are polygons.

void CMfc40Dlg::OnGetSelectedButton() 
{
   int nType;
   int uCount;
   long x;
   int bSelected;
   CString msg;
   int hObject;
   VARIANT aObjects;

   VariantInit(&aObjects);
   uCount = m_Lead1.AnnGetSelectCount();  //get number of selected objects
   aObjects = m_Lead1.AnnGetSelectList(); //get handles of the selected objects
   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");
   VariantClear(&aObjects);
}