Strokes Property [InkRecognizerContext Class]

Strokes Property [InkRecognizerContext Class]

Gets or sets the InkStrokes collection associated with the InkRecognizerContext object.

Declaration

[C++]

[C++]
[propputref] HRESULT putref_Strokes ([in] IInkStrokes* Strokes);
[propget] HRESULT get_Strokes ([out, retval] IInkStrokes** Strokes);

[Microsoft® Visual Basic® 6.0]

[Visual Basic]
Public Property Get Strokes() As InkStrokes
Public Property Let Strokes(ByVal theStrokes As InkStrokes)

Property Value

InkStrokes The InkStrokes collection associated with the InkRecognizerContext object.

This property is read/write.

Return Value

HRESULT value Description
S_OK Success.
E_FAIL An unspecified error occurred.
E_INK_INCOMPATIBLE_OBJECT The object is incompatible with the application programming interface (API).
E_OUTOFMEMORY Cannot allocate memory to complete the operation.
E_POINTER The parameter is an invalid pointer.

Remarks

You can set the InkStrokes collection more than once. Each time you set the InkStrokes collection, the InkRecognizerContext object is reset—any ink or results are removed and any prior calls to the EndInkInput method are disregarded—and then the new strokes are added.

The InkStrokes collection can also be set to NULL (Nothing in Visual Basic 6.0), which also resets the InkRecognizerContext object. When the InkRecognizerContext is reset, it keeps any guides, factoids, and other properties which previously had been set on it.

When the InkRecognizerContext object is reset, any recognition taking place on the background thread is cancelled.

To keep the Strokes property of the InkRecognizerContext object synchronized with an InkDisp object, use the InkAdded and InkDeleted events of the InkDisp object to listen for strokes that should be added or removed from the InkRecognizerContext object. This covers cases where strokes are added to, deleted from, clipped, or split within the InkDisp object.

Note: Moving, scaling, or other transformations on strokes in the InkDisp object do not generate InkAdded or InkDeleted events. Perform the same transformations on the strokes in the InkRecognizerContext object to keep the Strokes property of the InkRecognizerContext object synchronized.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example shows a button handler that recognizes the ink in its InkRecognizerContext, theRecognizerContext, and displays it in a text box, theTextBox, if no errors occurred.

[Visual Basic]
Option Explicit
Dim theInkCollector As InkCollector
Dim theRecognizerContext As New InkRecognizerContext

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

Private Sub Command1_Click()
    Set theRecognizerContext.Strokes = theInkCollector.Ink.Strokes
    theRecognizerContext.EndInkInput
    Dim theRecognitionStatus As InkRecognitionStatus
    Dim theRecognitionResult As IInkRecognitionResult
    On Error Resume Next
    Set theRecognitionResult = theRecognizerContext.Recognize(theRecognitionStatus)
    If InkRecognitionStatus.IRS_NoError = theRecognitionStatus Then
        theTextBox.Text = theRecognitionResult.TopString
    Else
        'Handle the error conditions here.
        theTextBox.Text = ""
    End If
End Sub

Applies To