using safearray to addpolyline

P

pho

I have an automation powerpoint object and I tried to add a polyline
(with three points) to the shapes object with following code:

COleSafeArray saArray;
int val;
long index[2];
VARIANT v;
SAFEARRAYBOUND sabounds[] = { {3, 0}, {2,0} };
saArray.Create(VT_VARIANT, 2, sabounds);
ASSERT(saArray.GetDim() == 2);

index[0] = 0;
index[1] = 0;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 10;
saArray.PutElement(index, &v);
VariantClear(&v);

index[0] = 0;
index[1] = 1;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 10;
saArray.PutElement(index, &v);
VariantClear(&v);

index[0] = 1;
index[1] = 0;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 50;
saArray.PutElement(index, &v);
VariantClear(&v);

index[0] = 1;
index[1] = 1;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 50;
saArray.PutElement(index, &v);
VariantClear(&v);

index[0] = 2;
index[1] = 0;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 50;
saArray.PutElement(index, &v);
VariantClear(&v);

index[0] = 2;
index[1] = 1;
VariantInit(&v);
v.vt = VT_R4;
v.fltVal = 0;
saArray.PutElement(index, &v);
VariantClear(&v);
shapes.AddPolyline(saArray);

I get a error message "memory is locked" and do not know what I did
wrong or maybe there are other better ways to do this ?

Thanks for the help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top