Compartilhar via


HitTestSelection Method

HitTestSelection Method

Determines what portion of the selection was hit during a hit test.

Declaration

[C++]

SelectionHitResult HitTestSelection (
    [in] Long x,
    [in] Long y
);

[Microsoft® Visual Basic® 6.0]

Public Function HitTestSelection( _
    x As Long, _
    y As Long _
) As SelectionHitResult

Parameters

x

[in] The x-position in pixels of the hit test.

y

[in] The y-position in pixels of the hit test.

Return Value

Returns a value from the SelectionHitResult enumeration, which specifies which part of a selection, if any, was hit during a hit test.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example demonstrates use of the Selection property and using the HitTestSelection method. This application uses a check box, CheckSelectionMode to toggle an InkOverlay object between Inking and Selection modes, and uses the HitTestSelection results to change the color of the selection when one of the selection handles of the selection rectangle is clicked.

Option Explicit
Private WithEvents theInkOverlay As InkOverlay

Private Sub CheckSelectionMode_Click()
    'Toggle the EditingMode between Inking and Selection
    If theInkOverlay.EditingMode = IOEM_Ink Then
        theInkOverlay.EditingMode = IOEM_Select
    Else
        theInkOverlay.EditingMode = IOEM_Ink
    End If
End Sub

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    Set theInkOverlay = New InkOverlay
    theInkOverlay.hWnd = Me.hWnd
    theInkOverlay.Enabled = True
End Sub

Private Sub Form_MouseDown( _
Button As Integer, Shift As Integer, X As Single, Y As Single)
    If theInkOverlay.EditingMode = IOEM_Select Then
        Dim result As SelectionHitResult
        result = theInkOverlay.HitTestSelection(X, Y)
        Dim theDrawingAttributes As New InkDrawingAttributes
        If result = SHR_NW Then
            theDrawingAttributes.Color = vbGreen
        ElseIf result = SHR_NE Then
            theDrawingAttributes.Color = vbRed
        ElseIf result = SHR_SE Then
            theDrawingAttributes.Color = vbYellow
        ElseIf result = SHR_SW Then
            theDrawingAttributes.Color = vbBlue
        End If
        theInkOverlay.Selection.ModifyDrawingAttributes theDrawingAttributes
        Refresh
    End If
End Sub

Applies To