We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


Called by the framework in response to a container's IViewObjectEx::GetNaturalExtent request.

virtual BOOL OnGetNaturalExtent( 
   DWORD dwAspect,
   LONG lindex,
   HDC hicTargetDev,
   DVEXTENTINFO* pExtentInfo,
   LPSIZEL psizel  


Specifies how the object is to be represented. Representations include content, an icon, a thumbnail, or a printed document. Valid values are taken from the enumeration DVASPECT or DVASPECT2.


The portion of the object that is of interest. Currently only -1 is valid.


Points to the DVTARGETDEVICE structure defining the target device for which the object's size should be returned.


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.


Points to the DVEXTENTINFO structure that specifies sizing data. The DVEXTENTINFO structure is:

typedef struct tagExtentInfo


UINT cb;

DWORD dwExtentMode;

SIZEL sizelProposed;


The structure member dwExtentMode can take one of two values:

  • DVEXTENT_CONTENT   Inquire how big the control should be to exactly fit content (snap-to-size)

  • DVEXTENT_INTEGRAL   When resizing, pass proposed size to control


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

Nonzero if it successfully returns or adjusts the size; otherwise 0.

Override this function to return the object's display size closest to the proposed size and extent mode in the DVEXTENTINFO structure. The default implementation returns FALSE and makes no adjustments to the size.

Header: afxctl.h