IDWriteTextLayout::HitTestPoint method (dwrite.h)

The application calls this function passing in a specific pixel location relative to the top-left location of the layout box and obtains the information about the correspondent hit-test metrics of the text string where the hit-test has occurred. When the specified pixel location is outside the text string, the function sets the output value *isInside to FALSE.

Syntax

HRESULT HitTestPoint(
        FLOAT                   pointX,
        FLOAT                   pointY,
  [out] BOOL                    *isTrailingHit,
  [out] BOOL                    *isInside,
  [out] DWRITE_HIT_TEST_METRICS *hitTestMetrics
);

Parameters

pointX

Type: FLOAT

The pixel location X to hit-test, relative to the top-left location of the layout box.

pointY

Type: FLOAT

The pixel location Y to hit-test, relative to the top-left location of the layout box.

[out] isTrailingHit

Type: BOOL*

An output flag that indicates whether the hit-test location is at the leading or the trailing side of the character. When the output *isInside value is set to FALSE, this value is set according to the output hitTestMetrics->textPosition value to represent the edge closest to the hit-test location.

[out] isInside

Type: BOOL*

An output flag that indicates whether the hit-test location is inside the text string. When FALSE, the position nearest the text's edge is returned.

[out] hitTestMetrics

Type: DWRITE_HIT_TEST_METRICS*

The output geometry fully enclosing the hit-test location. When the output *isInside value is set to FALSE, this structure represents the geometry enclosing the edge closest to the hit-test location.

Return value

Type: HRESULT

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

Requirements

Requirement Value
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