HRESULT DeleteStrokes ( [in, optional, defaultvalue(0)] IInkStrokes* strokes );
[Microsoft® Visual Basic® 6.0]
Public Sub DeleteStrokes([strokes As InkStrokes])
[in] Specifies the collection of strokes to delete from the InkDisp object. The default value is
Nothing in Visual Basic 6.0, which must be specified if using latebinding).
|E_POINTER||A parameter contained an invalid pointer.|
|E_OUTOFMEMORY||Cannot allocate memory that is used to perform the operation.|
|E_FAIL||An unspecified error occurred.|
|E_INK_MISMATCHED_INK_OBJECT||The InkDisp object of the strokes must match the known InkDisp object.|
|E_INK_EXCEPTION||An exception occurred inside the method.|
|E_UNEXPECTED||Unexpected parameter or property type.|
DeleteStrokes can result in an error if called while the user is actively laying down ink.
[Visual Basic 6.0]
This Visual Basic 6.0 example uses a command button Command1 to invoke a function, DeleteStrokesOnLeft, that deletes all of the strokes in the InkDisp object, theInkCollector.Ink, that are to the left of the ptLeft parameter in ink space, and returns a count of the deleted strokes.
Dim theInkCollector As InkCollector Private Sub Command1_Click() ' On button press, delete all strokes with points ' to the left of a line at x=5000 in ink space DeleteStrokesOnLeft 5000 Form1.Refresh End Sub Private Sub Form_Load() Set theInkCollector = New InkCollector theInkCollector.hWnd = Me.hWnd theInkCollector.Enabled = True End Sub Public Function DeleteStrokesOnLeft( _ ByVal ptLeft As Long _ ) As Long Dim i As Integer Dim ptTest As Long Dim stroke As IInkStrokeDisp Dim strokesToDelete As InkStrokes Dim ptStrokePoints As Variant ' Create an object to hold strokes to be deleted Set strokesToDelete = theInkCollector.Ink.CreateStrokes For Each stroke In theInkCollector.Ink.Strokes ' The points are returned as an array of Long, ' in the form of x1, y1, x2, y2, ... ptStrokePoints = stroke.GetPoints ' Determine the final x,y pair starting at 0 Dim pointUBound As Long pointUBound = (UBound(ptStrokePoints) - 1) \ 2 For i = 0 To pointUBound ' Get the next point x value ptTest = ptStrokePoints(i * 2) ' If there is a point in this stroke left of the parameter, If ptTest < ptLeft Then ' add this stroke to the collection to delete strokesToDelete.Add stroke ' then exit, because we don't need to test further. Exit For End If Next Next If 0 < strokesToDelete.Count Then ' Delete the strokes we collected on the left theInkCollector.Ink.DeleteStrokes strokesToDelete End If DeleteStrokesOnLeft = strokesToDelete.Count End Function