共用方式為


Remove Method [InkStrokes Collection]

Remove Method [InkStrokes Collection]

Removes a IInkStrokeDisp object from a InkStrokes collection.

Declaration

[C++]

HRESULT Remove (
    [in] IInkStrokeDisp* stroke
);

[Microsoft® Visual Basic® 6.0]

Public Sub Remove( _
    stroke As IInkStrokeDisp _
)

Parameters

stroke

[in] The IInkStrokeDisp to remove.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER A parameter contained an invalid pointer.
E_OUTOFMEMORY Cannot allocate IInkStrokeDisp handler helper object.
E_INK_EXCEPTION An exception occurred inside the method.
E_INK_INCOMPATIBLE_OBJECT IInkStroke* does not point to a valid InkDisp object.
E_INK_MISMATCHED_INK_OBJECT The InkDisp object of the InkStrokes collection and this IInkStrokeDisp object do not match.
E_UNEXPECTED Unexpected parameter or property type.

Remarks

InkStrokes collections are sets of references to ink data and are not the actual data itself. This method removes only the collection of strokes from a snapshot of, or reference to, the data and does not remove the actual ink data. To delete the collection from the actual ink data, call the DeleteStrokes method.

After calling the Remove method, the strokes in the collection are reordered. For example, after calling Strokes.Remove(Strokes.Item(0)), what used to be Strokes.Item(1) is now Strokes.Item(0), what was strokes.Item(2) is now strokes.Item(1), and so forth.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example removes strokes from a collection, theLeftToRightStokes, if the first point in the stroke is not to the left of the last point in the stroke. The original strokes in the InkDisp object are unaffected.

'...
    Dim testStroke As IInkStrokeDisp
    Dim ptStrokePoints As Variant
    For Each testStroke In theLeftToRightStrokes
        Dim ptStartX As Long
        ptStrokePoints = testStroke.GetPoints()
        If UBound(ptStrokePoints) > 0 Then
            ptStartX = ptStrokePoints(0)
            Dim ptEndX As Long
            ptEndX = ptStrokePoints(UBound(ptStrokePoints) - 1)
            If ptStartX > ptEndX Then
                theLeftToRightStrokes.Remove testStroke
            End If
        End If
    Next

Applies To