IViewObjectEx::GetNaturalExtent
Provides sizing hints from the container for the object to use as the user
resizes it.
HRESULT GetNaturalExtent(
DWORD dwAspect,
|
//Requested drawing aspect
|
LONG lindex,
|
//Portion of object for draw operation
|
DVTARGETDEVICE* ptd,
|
//Pointer to structure describing target device
|
HDC hicTargetDev,
|
//Information context for ptd
|
DVEXTENTINFO* pExtentInfo,
|
//Structure specifying sizing data
|
LPSIZEL* pSizel,
|
//Pointer to sizing data returned by object
|
);
|
|
Parameters
-
dwAspect
-
[in] Requested drawing aspect. It can be any of the values from the
DVASPECT enumeration.
-
lindex
-
[in] Indicates the 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 target device (typically the display). A value other than NULL is
interpreted in conjunction with hicTargetDev and hdcDraw. For
example, if hdcDraw specifies a printer as the device context, the ptd
parameter points to a structure describing that printer device. The data may
actually be printed if hicTargetDev is a valid value or it may be
displayed in print preview mode if hicTargetDev is NULL.
-
hicTargetDev
-
[in] Specifies the information context for the target 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 then the width was not adjusted, if cy is -1 then the height was not
adjusted. If E_FAIL is returned indicating no size was adjusted then psizel
may be NULL.
Return Values
-
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 was 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:
-
The object calls
IOleClientSite::RequestNewObjectLayout.
-
The container calls IOleObject::GetExtent
and retrieves the new extents
-
The container calls IOleObject::SetExtent
and adjusts the new extents.
If the object is active, the following occurs:
-
The object calls
IOleInPlaceSite::OnPosRectChange
to specify that it requires resizing.
-
The container calls
IOleInPlaceObject::SetObjectRects
and specifies the new size.
The values of the dwAspect parameter can be one of the following
DVASPECT enumeration values:
-
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 may 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.
See Also
DVASPECT, DVEXTENTINFO,
IOleClientSite::RequestNewObjectLayout,
IOleInPlaceObject::SetObjectRects,
IOleInPlaceSite::OnPosRectChange,
IOleObject::GetExtent,
IOleObject::SetExtent,