Hi,
DrawPolygon crash when i’m calling method with params below :
double x[5] = { rcExtent.get_xMin(), rcExtent.get_xMax(), rcExtent.get_xMax(), rcExtent.get_xMin(), rcExtent.get_xMin() };
double y[5] = { rcExtent.get_yMin(), rcExtent.get_yMin(), rcExtent.get_yMax(), rcExtent.get_yMax(), rcExtent.get_yMin() };
SAFEARRAYBOUND bound;
bound.lLbound = 0;
bound.cElements = 5;
SAFEARRAY* psaX = SafeArrayCreate(VT_R8, 1, &bound);
SAFEARRAY* psaY = SafeArrayCreate(VT_R8, 1, &bound);
SafeArrayAccessData(psaX, (void**)&x);
SafeArrayAccessData(psaY, (void**)&y);
for (int i = 0; i < 5; i++)
{
long ind = i;
SafeArrayPutElement(psaX, &ind, (void*)&x[i]);
SafeArrayPutElement(psaY, &ind, (void*)&y[i]);
}
SafeArrayUnaccessData(psaX);
SafeArrayUnaccessData(psaY);
VARIANT xx, yy;
VariantInit(&xx);
VariantInit(&yy);
xx.vt = VT_BYREF | VT_ARRAY | VT_R8;
yy.vt = VT_BYREF | VT_ARRAY | VT_R8;
xx.parray = psaX;
yy.parray = psaY;
pCartoView->GetMap()->DrawPolygon(&xx, &yy, 5, RGB(0, 255, 0), FALSE, 255);
// *****************************************************************
// DrawPolygon()
// *****************************************************************
void CMapView::DrawPolygon(VARIANT *xPoints,VARIANT *yPoints, long numPoints, OLE_COLOR color, BOOL fill, BYTE alpha)
{
USES_CONVERSION;
SAFEARRAY* sax = *xPoints->pparray;
SAFEARRAY *say = *yPoints->pparray;
double *xPts = (double *)sax->pvData;
double *yPts =(double*)say->pvData;
xPoints->pparay either that xPoints->parray are never set, but with this, it works.
SAFEARRAY* say = V_ARRAY(V_VARIANTREF(yPoints));
SAFEARRAY* sax = V_ARRAY(V_VARIANTREF(xPoints));