Referenced Document of a View

Top  Previous  Next

When you have a view you can get hold of the object the view is looking at. The object is called the referenced document, for example if it is a part:

 

ReferencedDocument

Getting the referenced document can be useful for getting retrieveable dimensions.

 

Here is an example code fragment (with no error checking):

 

   // Now find out the part which this is a view of...

   CComPtr<DocumentDescriptor> pDocDesc  ;

   pThisView->get_ReferencedDocumentDescriptor (&pDocDesc) ;

 

   // Still finding out the part which this is a view of...

   CComPtr<Document> pReffedDoc  ;

   pDocDesc->get_ReferencedDocument ((IDispatch**)&pReffedDoc) ;

 

   if (kPartDocumentObject != pReffedDoc->DocumentType) {

       WalertBoxW (L"The referenced document is not a part") ;

       return ;

   }

 

   // Convert the general referenced doc into a part doc...

   CComQIPtr<PartDocument> pPartDoc = pReffedDoc ;

 

So pPartDoc is the document which the view refers to.

 

 

 

 

 

 

Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)