IDWriteTextLayout::HitTestTextPosition method

The application calls this function to get the pixel location relative to the top-left of the layout box given the text position and the logical side of the position. This function is normally used as part of caret positioning of text where the caret is drawn at the location corresponding to the current text editing position. It may also be used as a way to programmatically obtain the geometry of a particular text position in UI automation.

Syntax

HRESULT HitTestTextPosition(
  UINT32                  textPosition,
  BOOL                    isTrailingHit,
  FLOAT                   *pointX,
  FLOAT                   *pointY,
  DWRITE_HIT_TEST_METRICS *hitTestMetrics
);

Parameters

textPosition

Type: UINT32

The text position used to get the pixel location.

isTrailingHit

Type: BOOL

A Boolean flag that indicates whether the pixel location is of the leading or the trailing side of the specified text position.

pointX

Type: FLOAT*

When this method returns, contains the output pixel location X, relative to the top-left location of the layout box.

pointY

Type: FLOAT*

When this method returns, contains the output pixel location Y, relative to the top-left location of the layout box.

hitTestMetrics

Type: DWRITE_HIT_TEST_METRICS*

When this method returns, contains the output geometry fully enclosing the specified text position.

Return Value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Requirements

   
Minimum supported client Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header dwrite.h
Library Dwrite.lib
DLL Dwrite.dll

See Also

IDWriteTextLayout