S
Scott Metzger
Hi,
How would I take a shape from one document or a stencil and add that
shape to a new page for my current drawing?
This is an MFC C++ .exe using the drawing control and I have imported
the Visio 2003 Type Library.
I have attempted to load the shape from a stencil by doing the following:
1) Open the stencil
2) Loop through the Masters in the Stencil to find the one I want.
3) Get the Shapes object from the Master object
4) In my solution there will be a single Shape object in the collection,
so I get the first one.
5) Add a new page to the drawing document
6) Add a new Layer to the new page.
7) Add the Shape from step 4 to the Layer.
I get an unhandled exception on step 7.
Here is some code...
CVPages vPages = MyDocument->get_Pages();
CVPage vPage = vPages.Add();
CVLayers vLayers = vPage.get_Layers();
CVLayer vLayer = vLayers.Add("Top");
vShapes = vMaster.get_Shapes();
junkVar.iVal = 1;
CVShape docShape = vShapes.get_Item(junkVar);
CString docShapeName = docShape.get_Name();
vLayer.Add((LPDISPATCH)&docShape, 1); // unhandled exception here
Any ideas?
Thanks,
Scott Metzger
How would I take a shape from one document or a stencil and add that
shape to a new page for my current drawing?
This is an MFC C++ .exe using the drawing control and I have imported
the Visio 2003 Type Library.
I have attempted to load the shape from a stencil by doing the following:
1) Open the stencil
2) Loop through the Masters in the Stencil to find the one I want.
3) Get the Shapes object from the Master object
4) In my solution there will be a single Shape object in the collection,
so I get the first one.
5) Add a new page to the drawing document
6) Add a new Layer to the new page.
7) Add the Shape from step 4 to the Layer.
I get an unhandled exception on step 7.
Here is some code...
CVPages vPages = MyDocument->get_Pages();
CVPage vPage = vPages.Add();
CVLayers vLayers = vPage.get_Layers();
CVLayer vLayer = vLayers.Add("Top");
vShapes = vMaster.get_Shapes();
junkVar.iVal = 1;
CVShape docShape = vShapes.get_Item(junkVar);
CString docShapeName = docShape.get_Name();
vLayer.Add((LPDISPATCH)&docShape, 1); // unhandled exception here
Any ideas?
Thanks,
Scott Metzger