# IViewObject2::GetExtent

Returns the size that the specified view object will be drawn on the specified target device.

HRESULT GetExtent(

DWORD dwAspect, | //View object for which the size is being requested
DWORD lindex, | //Part of the object to draw
DVTARGETDEVICE ptd, | //Pointer to the target device in a structure
LPSIZEL lpsizel | //Pointer to size of object
); |

Parameters

dwAspect
  [in] Requested view of the object whose size is of interest. Valid values are taken from the enumerations DVASPECT and from DVASPECT2. Note that newer objects and containers that support optimized drawing interfaces support the DVASPECT2 enumeration values. Older objects and containers that do not support optimized drawing interfaces may not support DVASPECT2.
lindex
  [in] Portion of the object that is of interest. Currently only -1 is valid.
ptd
  [in] Pointer to the DVTARGETDEVICE structure defining the target device for which the object’s size should be returned.
lpsizel
  [out] Pointer to where the object’s size is returned.

Return Values

This method supports the standard return value E_OUTOFMEMORY, as well as the following:

S_OK
  The object’s extent was successfully returned.
OLE_E_BLANK
  An appropriate cache is not available.

Remarks

The OLE-provided implementation of IViewObject2::GetExtent searches the cache for the size of the view object.

The GetExtent method in the IOleObject interface provides some of the same information as IViewObject2::GetExtent.

Note This method must return the same size as DVASPECT_CONTENT for all the new aspects in DVASPECT2. IOleObject::GetExtent must do the same thing.

If one of the new aspects is requested in dwAspect, this method can either fail or return the same rectangle as for the DVASPECT_CONTENT aspect.

#### Note to Callers

To prevent the object from being run if it isn’t already running, you can call IViewObject2::GetExtent rather than IOleObject::GetExtent to determine the size of the presentation to be drawn.

See Also

DVASPECT, DVASPECT2, IOleObject::GetExtent, IViewObject