The container must be able to query the server for the size of the item. The COleServerItem::OnGetExtent() method is called when the container requests the size of the item. The size of the item is always expressed in MM_HIMETRIC units (0.01 millimeters per logic unit). The viewport contains a method to return its bounds in MM_HIMETRIC units. All you need to do is get the viewport, make sure it is sized to display the entire model, and then retrieve the size.
BOOL CMyAppSrvrItem::OnGetExtent(DVASPECT dwDrawAspect, CSize& rSize) { // Most applications, like this one, only handle drawing the // content aspect of the item. If you wish to support other // aspects, such as DVASPECT_THUMBNAIL (by overriding OnDrawEx), // then this implementation of OnGetExtent should be modified // to handle the additional aspect(s). if (dwDrawAspect != DVASPECT_CONTENT) return COleServerItem::OnGetExtent(dwDrawAspect, rSize); // // This function is called to get the extent in HIMETRIC units of // the entire item. // CMyAppViewport* pViewport = GetViewport(); if (pViewport != NULL) { // Set the viewport size pViewport->SizeToModel(); CRect rcBounds = pViewport->GetHiMetricBounds(); rSize.cx = rcBounds.Width(); rSize.cy = rcBounds.Height(); return TRUE; } return FALSE; } |
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.