HitTestPenData 

2.0     

Determines if a given point lies on or near the pen-down strokes contained in an HPENDATA object.

int HitTestPenData( HPENDATA hpndt, LPPOINT lppt, UINT dThresh, UINT FAR* lpiStrk, UINT FAR* lpiPnt )

Parameters

hpndt

Handle to the HPENDATA object. HitTestPenData does not alter the data in the HPENDATA object.

lppt

Address of a POINT44VP0_ structure containing the point to test.

dThresh

Threshold around the point given in lppt. The point lies at the center of a square with sides of length dThresh. If HitTestPenData finds a point in the HPENDATA object that lies in the square, it indicates a  hit.  dThresh must have the same scaling units as the points in the HPENDATA or the result will not be correct. If dThresh is 0, HitTestPenData assumes a default threshold value of 3.

lpiStrk

Stroke index from which to begin testing. After HitTestPenData returns from a successful test, the variable that lpiStrk points to contains the index of the hit stroke.

lpiPnt

Point index from which to begin testing. After HitTestPenData returns from a successful test, the variable that lpiPnt points to contains the index of the hit point in the stroke indicated by lpiStrk.

Return Value

Returns one of the following if successful:

Constant

Description

PDR_HIT

The point hits (intersects) the pen data or falls within the provided threshold around a particular point in the pen data as specified by the stroke and the point indices. The stroke and point values are returned in lpiStrk and lpiPnt, respectively.

PDR_NOHIT

The point does not hit (intersect) the pen data nor does it fall within the provided threshold around a particular point in the pen data as specified by the stroke and the point indices.

 

Otherwise, the function returns one of the following negative values:

Constant

Description

PDR_COMPRESSED

Pen data is compressed.

PDR_ERROR

Parameter or other unspecified error.

PDR_MEMERR

Memory error.

PDR_PNDTERR

Invalid pen data.

PDR_PNTINDEXERR

Invalid point index.

PDR_STRKINDEXERR

Invalid stroke index.

PDR_VERSIONERR

Could not convert old pen data.

 

Comments

HitTestPenData checks whether the point specified by lppt falls within the threshold specified by dThresh around a point in the pen data, depending on the zero-based starting stroke and point indices specified by lpiStrk and lpiPnt. This function tests only down strokes in the pen data. If lpiStrk is greater than the number of strokes in the pen data, testing starts from the first stroke.

Similarly, if lpiPnt is greater than the number of points in the stroke, testing starts from the first point in that stroke. The first point in the first stroke (from the specified indices) that meets the test condition is returned via lpiPnt and lpiStrk, respectively.

In any case, HitTestPenData accounts for the width of the ink trail. If the value given in dThresh is less than the ink width, HitTestPenData ignores the specified value of dThresh and instead uses the ink width as the threshold.

HitTestPenData does not consider pen-up strokes.