Share via


IViewObjectEx::GetNaturalExtent (Compact 2013)

3/26/2014

This method provides sizing hints from the container for the object to use as the user resizes it.

Syntax

HRESULT GetNaturalExtent(
  DWORD dwAspect,
  LONG lindex,
  DVTARGETDEVICE* ptd,
  HDC hicTargetDev,
  DVEXTENTINFO* pExtentInfo,
  LPSIZEL pSizel
);

Parameters

  • dwAspect
    [in] Requested drawing aspect. It can be any of the values from the DVASPECT enumeration.
  • lindex
    [in] Portion of the object that is of interest for the draw operation. Its interpretation varies depending on the value in the dwAspect parameter. See the DVASPECT enumeration for more information.
  • ptd
    [in] Pointer to the target device structure that describes the device for which the object is to be rendered.

    If NULL, the view should be rendered for the default device (typically the display).

    A value other than NULL is interpreted in conjunction with the hicTargetDev and hdcDraw parameters.

    For example, if hdcDraw specifies a printer as the device context, the ptd parameter points to a structure describing that printer device. The data can actually be printed if hicTargetDev is a valid value or it can be displayed in print preview mode if hicTargetDev is NULL.

  • hicTargetDev
    [in] Information context for the device indicated by the ptd parameter from which the object can extract device metrics and test the device's capabilities. If ptd is NULL, the object should ignore the value in the hicTargetDev parameter.
  • pExtentInfo
    [in] Pointer to DVEXTENTINFO structure that specifies the sizing data.
  • pSizel
    [out] Pointer to sizing data returned by the object.

    The returned sizing data is set to -1 for any dimension that was not adjusted.

    That is, if cx is -1, the width was not adjusted; if cy is -1, the height was not adjusted.

    If E_FAIL is returned indicating no size was adjusted, pSizel may be NULL.

Return Value

The following table shows the return values for this method.

Value

Description

S_OK

The sizing hints were successfully returned.

E_FAIL

This method is not implemented for the specified dwAspect, or the size was not adjusted.

E_NOTIMPL

This method is not implemented.

Remarks

There are two general approaches to sizing a control.

The first approach gives the control responsibility for sizing itself; the second approach gives the container responsibility for sizing the control. The first approach is called autosizing.

There are two alternatives involved in the second approach: content sizing and integral sizing.

The IViewObjectEx::GetNaturalExtent method supports both content and integral sizing.

In content sizing, the container passes the DVEXTENTINFO structure to the object into which the object returns a suggested size.

In integral sizing, the container passes a preferred size to the object in DVEXTENTINFO and the object actually adjusts its height. Integral sizing is used when the user rubberbands a new size in design mode.

Autosizing typically occurs with objects such as the Label control, which resizes if the autosize property was enabled and the associated text changed. Autosizing is handled differently depending on the state of the object.

If the object is inactive, the following occurs:

  1. The object calls the IOleClientSite::RequestNewObjectLayout method.
  2. The container calls the IOleObject::GetExtent method and retrieves the new extents.
  3. The container calls the IOleObject::SetExtent method and adjusts the new extents.

If the object is active, the following occurs:

  1. The object calls the IOleInPlaceSite::OnPosRectChange method to specify that it requires resizing.
  2. The container calls the IOleInPlaceObject::SetObjectRects method and specifies the new size.

The following table shows the possible values for the dwAspect parameter.

Value

Description

DVASPECT_CONTENT

Provide a representation of the control so it can be displayed as an embedded object inside of a container.

This value is typically specified for compound document objects.

The presentation can be provided for the screen or printer.

DVASPECT_DOCPRINT

Provide a representation of the control on the screen as though it were printed to a printer using the Print command from the File menu.

The described data can represent a sequence of pages.

DVASPECT_ICON

Provide an iconic representation of the control.

DVASPECT_THUMBNAIL

Provide a thumbnail representation of an object so it can be displayed in a browsing tool.

The thumbnail is approximately a 120 by 120 pixel, 16-color (recommended) device-independent bitmap potentially wrapped in a metafile.

To determine whether the platform supports this interface, see Determining Supported COM APIs.

Requirements

Header

ocidl.h,
ocidl.idl

Library

ole32.lib,
uuid.lib

See Also

Reference

IViewObjectEx
IOleClientSite::RequestNewObjectLayout
IOleObject::GetExtent
IOleObject::SetExtent
DVASPECT
DVEXTENTINFO