Skip to content

Latest commit

 

History

History
276 lines (209 loc) · 8.87 KB

nf-textserv-itextservices2-txgetnaturalsize2.md

File metadata and controls

276 lines (209 loc) · 8.87 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:textserv.ITextServices2.TxGetNaturalSize2
ITextServices2::TxGetNaturalSize2 (textserv.h)
Resizes a control so it fits its content appropriately. This method is similar to TxGetNaturalSize, but also retrieves the ascent of the top line of text.
ITextServices2 interface [Windows Controls]
TxGetNaturalSize2 method
ITextServices2.TxGetNaturalSize2
ITextServices2::TxGetNaturalSize2
TXTNS_EMU
TXTNS_FITTOCONTENT
TXTNS_FITTOCONTENT2
TXTNS_FITTOCONTENT3
TXTNS_FITTOCONTENTWSP
TXTNS_INCLUDELASTLINE
TXTNS_ROUNDTOLINE
TxGetNaturalSize2
TxGetNaturalSize2 method [Windows Controls]
TxGetNaturalSize2 method [Windows Controls]
ITextServices2 interface
controls.itextservices2_txgetnaturalsize2
textserv/ITextServices2::TxGetNaturalSize2
controls\itextservices2_txgetnaturalsize2.htm
Controls
9D9A3D06-5C1F-4D50-B7B7-E6CA2BFDB89C
12/05/2018
ITextServices2 interface [Windows Controls],TxGetNaturalSize2 method, ITextServices2.TxGetNaturalSize2, ITextServices2::TxGetNaturalSize2, TXTNS_EMU, TXTNS_FITTOCONTENT, TXTNS_FITTOCONTENT2, TXTNS_FITTOCONTENT3, TXTNS_FITTOCONTENTWSP, TXTNS_INCLUDELASTLINE, TXTNS_ROUNDTOLINE, TxGetNaturalSize2, TxGetNaturalSize2 method [Windows Controls], TxGetNaturalSize2 method [Windows Controls],ITextServices2 interface, controls.itextservices2_txgetnaturalsize2, textserv/ITextServices2::TxGetNaturalSize2
textserv.h
Windows
Windows 8 [desktop apps only]
Windows Server 2012 [desktop apps only]
Msftedit.dll
Windows
19H1
ITextServices2::TxGetNaturalSize2
textserv/ITextServices2::TxGetNaturalSize2
c++
APIRef
kbSyntax
COM
Msftedit.dll
ITextServices2.TxGetNaturalSize2

ITextServices2::TxGetNaturalSize2

-description

Resizes a control so it fits its content appropriately. This method is similar to TxGetNaturalSize, but also retrieves the ascent of the top line of text.

-parameters

-param dwAspect

Type: DWORD

The aspect for the drawing. It can be any of the values from the DVASPECT enumeration.

-param hdcDraw

Type: HDC

The device context into which drawing occurs.

-param hicTargetDev

Type: HDC

The device context for which text should be formatted (that is, for WYSIWYG).

-param ptd

Type: DVTARGETDEVICE*

More information on the target device.

-param dwMode

Type: DWORD

The type of fitting requested. It can be one of the following.

Value Meaning
TXTNS_EMU
Use English Metric Units (EMUs) instead of pixels as the measuring units (both ways) for this method's parameters.
TXTNS_FITTOCONTENT
Resize the control to fit the entire text by formatting the text to the width that is passed in. The text services object returns the height of the entire text and the width of the widest line.

For example, this should be done when the user double-clicks one of the control's handles.

TXTNS_FITTOCONTENT2
Resize the control so that it fits indented content.
TXTNS_FITTOCONTENT3
Resize the control so that it fits indented content and trailing white space.
TXTNS_FITTOCONTENTWSP
Resize the control so that it fits unindented content and trailing white space.
TXTNS_INCLUDELASTLINE
For a plain-text control, include the height of the final carriage return when calculating the size.
TXTNS_ROUNDTOLINE
Resize the control to show an integral number of lines (no line is clipped). Format enough text to fill the width and height that is passed in, and then return a height that is rounded to the nearest line boundary.
Note  The passed and returned width and height correspond to the view rectangle. The host should adjust back to the client rectangle as needed. Because these values represent the extent of the text object, they are input and output in HIMETRIC coordinates (each HIMETRIC unit is 0.01 millimeter), and measuring does not include any zoom factor. For a discussion of the zoom factor, see TxGetExtent.
 

-param psizelExtent

Type: const SIZEL*

Sizes of extents (in HIMETRIC units) to use for zooming.

-param pwidth

Type: LONG*

The width for the fitting defined by dwMode.

-param pheight

Type: LONG*

The height for the fitting defined by dwMode.

-param pascent

Type: LONG*

For single-line controls, receives the ascent (units above the baseline) of characters in the top line of text.

-returns

Type: HRESULT

If the method succeeds, the return value is S_OK.

If text services could not activate the object, the return value is one of the following HRESULT codes. For more information on COM error codes, see Error Handling in COM.

Return code Description
E_FAIL
Unable to determine correct size.
E_INVALIDARG
One or more arguments are not valid.
E_OUTOFMEMORY
Insufficient memory.

-remarks

The first four parameters are similar to equivalent parameters in ITextServices::TxDraw and give the same information. In the case where the lines must be recalculated, TxGetNaturalSize2 uses these values in the same ways as in ITextServices::TxDraw.

The pwidth and pheight parameters are in/out parameters. The host passes in the tentative width and height of the natural extent of the text object. The text services object compares these values against its current cached state, and if different, recalculates lines. Then, it computes and returns the natural size, as specified by dwMode.

Examples

The following example shows how to initialize the psizelExtent parameter for to a zoom factor of 1:1. The ellipses indicate code that you need to provide.

LONG dxpi = GetDeviceCaps(hdc, LOGPIXELSX);
LONG dypi = GetDeviceCaps(hdc, LOGPIXELSY);
LONG dyAscent = 0;
LONG dx = ... ;  // Text image width, in pixels 
LONG dy = ... ;  // Text image height, in pixels 
SIZEL sizel;     // dx and dy, in HIMETRIC

ITextServices2 *pserv = ... ; // Interface for single-line control

sizel.cx = MulDiv(dx, HIMETRIC_PER_INCH, dxpi); 
sizel.cy = MulDiv(dy, HIMETRIC_PER_INCH, dypi);

pserv->TxGetNaturalSize2(DVASPECT_DOCPRINT, hdc, hdcNil, pNil,
    TXTNS_FITTOCONTENT, &sizel, &dx, &dy, &dyAscent))) 

-see-also

ITextServices2