AnnBoundingRect... example for Visual C++ 4.0
VARIANT variantX, variantY;
SAFEARRAY *ptrsafearrayX, *ptrsafearrayY;
SAFEARRAYBOUND arrayboundX, arrayboundY;
float *pX, *pY; /* pointer to the data */
/* Set up the VARIANT and the SAFEARRAY structures */
arrayboundX.cElements = 4;
arrayboundX.lLbound = 0;
arrayboundY.cElements = 4;
arrayboundY.lLbound = 0;
ptrsafearrayX = SafeArrayCreate( VT_R4, 1, &arrayboundX);
ptrsafearrayY = SafeArrayCreate( VT_R4, 1, &arrayboundX);
SafeArrayLock( ptrsafearrayX );
SafeArrayLock( ptrsafearrayY );
pX = (float*)ptrsafearrayX->pvData; /* get a pointer to the buffer */
pY = (float*)ptrsafearrayY->pvData; /* get a pointer to the buffer */
V_VT(&variantX) = VT_ARRAY | VT_R4;
V_VT(&variantY) = VT_ARRAY | VT_R4;
V_ARRAY(&variantX) = ptrsafearrayX;
V_ARRAY(&variantY) = ptrsafearrayY;
long hObj = m_Lead1.AnnCreateItem (m_Lead1.GetAnnContainer(), ANNOBJECT_PROTRACTOR, TRUE);
long hObj2 = m_Lead1.AnnCreateItem (m_Lead1.GetAnnContainer(), ANNOBJECT_POLYGON, TRUE);
pX[1] = 10; pY[1] = 20;
pX[2] = 100; pY[2] = 200;
pX[3] = 200; pY[3] = 100;
m_Lead1.AnnSetPoints (hObj, variantX, variantY, 3);
pX[0] = 50; pY[0] = 220; // SetPoints starts at 0 because No. of points set to 4;
m_Lead1.AnnSetPoints(hObj2, variantX, variantY, 4);
SafeArrayUnlock( ptrsafearrayX );
SafeArrayDestroy( ptrsafearrayX );
SafeArrayUnlock( ptrsafearrayY );
SafeArrayDestroy( ptrsafearrayY );
m_Lead1.AnnSetFillMode (hObj2, ANNFILLMODE_OPAQUE, FALSE);
CString msg;
m_Lead1.AnnBringToFront (hObj2);
msg.Format("Polygon Area:%d\nProtractor Angle:%f", m_Lead1.AnnGetArea (hObj2), (double)m_Lead1.AnnGetAngle (hObj));
::MessageBox(NULL, (LPCSTR)msg, "Brought Polygon to front", MB_OK);
m_Lead1.AnnSendToBack (hObj2);
msg.Format("Protractor Bounding Rectangle, Left:%f, Top:%f, Width:%f, Height:%f" ,
(double)m_Lead1.GetAnnBoundingRectLeft (hObj),
(double)m_Lead1.GetAnnBoundingRectTop (hObj),
(double)m_Lead1.GetAnnBoundingRectWidth (hObj),
(double)m_Lead1.GetAnnBoundingRectHeight (hObj));
::MessageBox(NULL, (LPCSTR)msg, "Sent Polygon to back", MB_OK);
m_Lead1.AnnCut (hObj2, ANNFMT_WMF, FALSE, TRUE);