IInkStrokeDisp::NearestPoint method (msinkaut.h)

Finds the location on the stroke nearest to a known point and returns the distance that point is from the stroke. Everything is in ink space coordinates.

Syntax

HRESULT NearestPoint(
  [in]                long  X,
  [in]                long  Y,
  [in, out, optional] float *Distance,
  [out, retval]       float *Point
);

Parameters

[in] X

The x-position in ink space of the point to test.

[in] Y

The y-position in ink space of the point to test.

[in, out, optional] Distance

Optional. The distance from the point to the stroke. This parameter can be NULL. The default value is 0.

[out, retval] Point

When this method returns, contains the floating point index value that represents the closest location on the stroke.

A floating point index is a float value that represents a location somewhere between two points in the stroke. As examples, if 0.0 is the first point in the stroke and 1.0 is the second point in the stroke, 0.5 is halfway between the first and second points. Similarly, a floating point index value of 37.25 represents a location that is 25 percent along the line between points 37 and 38 of the stroke.

Return value

This method can return one of these values.

Return code Description
S_OK
Success.
E_POINTER
A parameter contained an invalid pointer.
E_FAIL
An unspecified error occurred.
E_INK_EXCEPTION
An exception occurred inside the method.

Remarks

The distance parameter describes the distance from the point to the envelope of the stroke. This is the distance between the two points minus half the width of the stroke.

Requirements

Requirement Value
Minimum supported client Windows XP Tablet PC Edition [desktop apps only]
Minimum supported server None supported
Target Platform Windows
Header msinkaut.h
Library InkObj.dll

See also

GetRectangleIntersections Method

HitTest(Point, Single) Method

IInkStrokeDisp Interface

NearestPoint Method [InkDisp Class]