To render the information in the model, the server item needs a viewport. The CView derived class in your application either mixes in a viewport class, or it contains a viewport as a member. It is possible to have your COleServerItem derived class either mix in or aggregate a viewport. However, it is easier to use the viewport that is already available from the active CView object attached to the document. When the document template is used to create the server document, it also creates a view. By retrieving the first view attached to the document, we can get a viewport to use for rendering the server item.
CMyAppViewport* CMyAppSrvrItem::GetViewport() { // // Find the first view attached to the document, and // use it to render the server item. // CMyAppDoc* pDoc = GetDocument(); if (pDoc != NULL) { POSITION pos = pDoc->GetFirstViewPosition(); CMyAppView* pFirstView = (CMyAppView*) pDoc->GetNextView(pos); if (pFirstView != NULL) { return pFirstView->GetViewport(); } } return NULL; } |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.