Bagikan melalui


Selection Property

Selection Property

Gets or sets the InkStrokes collection that is currently selected inside the InkOverlay object or the InkPicture control.

Declaration

[C++]

[C++]
[propput] HRESULT put_Selection ([in] IInkStrokes* Selection);
[propget] HRESULT get_Selection ([out, retval] IInkStrokes** Selection);

[Microsoft® Visual Basic® 6.0]

[Visual Basic]
Public Property Get Selection() As InkStrokes
Public Property Let Selection(ByVal theSelection As InkStrokes)

Property Value

InkStrokes The InkStrokes collection that is currently selected inside the InkOverlay object or the InkPicture control.

This property is read/write.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER The Selection parameter is an invalid pointer.
E_INK_EXCEPTION An exception occurred while processing.

Remarks

To get the bounding rectangle of the InkStrokes collection after it has been moved or resized, call the GetBoundingBox method of the InkStrokes collection returned by this property.

To get the bounding rectangle of the InkStrokes collection before it was moved, handle the InkOverlay.SelectionMoved or the InkPicture.SelectionMoved event and get the OldSelectionBoundingRect property of the InkOverlaySelectionMovedEventArgs object.

To get the bounding rectangle of the InkStrokes collection before it was resized, handle the InkOverlay.SelectionResized or the InkPicture.SelectionResized event and get the OldSelectionBoundingRect property of the InkOverlaySelectionResizedEventArgs object.

Example

[Visual Basic 6.0]

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

[Visual Basic]
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