Compartilhar via


HitTest Method [IInkStrokeDisp Interface]

HitTest Method [IInkStrokeDisp Interface]

Determines whether a stroke is either completely inside or intersected by a given circle.

Declaration

[C++]

HRESULT HitTestCircle (
    [in] long x,
    [in] long y,
    [in] single radius,
    [out, retval] VARIANT_BOOL *Intersects
);

[Microsoft® Visual Basic® 6.0]

Public Function HitTestCircle( _
    x As Long, _
    y As Long, _
    radius As Single _
) As Boolean

Parameters

radius

[in] The radius of the circle to use in the hit test.

x

[in] The x-position of the center of the hit-test circle in ink space coordinates.

y

[in] The y-position of the center of the hit-test circle in ink space coordinates.

Intersects

[out] Returns the Boolean value that indicates whether the stroke intersects the circle. The value is TRUE if the stroke intersects or is inside the circle.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_INK_EXCEPTION An exception occurred inside the method.
E_UNEXPECTED Unexpected parameter or property type.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example tests whether any part of the IInkStrokeDisp, Stroke, is within 500 ink space units of a point at (1000, 1000) in ink space.

Option Explicit
Dim WithEvents theInkCollector As InkCollector

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
    theInkCollector.SetEventInterest ICEI_Stroke, True
End Sub

Private Sub theInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    Dim IsAHit As Boolean
    IsAHit = Stroke.HitTestCircle(1000, 1000, 500!)
    If IsAHit Then
        Stroke.DrawingAttributes.Color = RGB(255, 0, 0)
    End If
    Form1.Refresh
End Sub

Applies To