programming: Referencing Shapes inside a Group

N

nyar

I am trying to figure out a way to iterate through all the shapes within a group. Does anybody know how to reference a shapes inside of a group programmatically using C?

I currently use the following code to iterate through the shapes, but I can't figure out how to iterate through the subshapes.

// temp vars
long nShapeCount = 0;
long nShapeIndex = 0;

// get shape count
hr = pShapes->Count(&nShapeCount);

// index is 1 to ShapeCount in Visio
for(nShapeIndex = 1; nShapeIndex <= nShapeCount; nShapeIndex++)
{
// get shape
hr = pShapes->Item(VVariant(nShapeIndex), vsCurrentShape);

//I WANT TO ITERATE THROUGH THE GROUP SHAPES HERE!
}

Any information is appreciated.
 
N

nyar

I found it! For future reference for anybody who gets lost in the visio web of documentation....

Each shape has a Shapes(CVisioShapes) method that will return by reference a reference to a list of shapes. So intuitively each shape has a list of shapes that can then be iterated through. Here is the code to do so....

// get shape
hr = pShapes->Item(VVariant(nShapeIndex), vsCurrentShape);

// let's see how many
CVisioShapes vsShapeCollection;
hr = vsCurrentShape.Shapes(vsShapeCollection);
if ( hr==S_OK )
{
long ChildCount;
vsShapeCollection.Count(&ChildCount);
for ( long i=0; i,ChildCount; i++ )
{
// Iterate through your child shapes here
}
}
 

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