Partager via


SetResultOnStrokes Method

SetResultOnStrokes Method

Assigns the recognition results to the strokes that were used to create the results.

Declaration

[C++]

HRESULT SetResultOnStrokes ();
      

[Microsoft® Visual Basic® 6.0]

Public Sub SetResultOnStrokes()
      

Parameters

This method takes no parameters.

Return Value

HRESULT value Description
S_OK Success.
E_UNEXPECTED Unexpected parameter or property type.
E_INK_EXCEPTION An exception occurred while processing.

Remarks

System performance suffers if recognition results are automatically assigned to every InkStrokes collection. Therefore results are not attached to an InkStrokes collection by default. To assign results to an InkStrokes collection, you must call SetResultOnStrokes. To return the recognition results for a InkStrokes collection, use the IInkRecognitionResult property of the InkStrokes collection. After you assign results to a InkStrokes collection, you can then store the strokes in a IInkCustomStrokes collection. These custom strokes, as well as the IInkRecognitionResult, can be persisted and retrieved for later use.

To return the recognition results of a collection of strokes, use the RecognitionResult property.

After you assign results to a collection of strokes, you can then store the strokes in a IInkCustomStrokes collection. These custom strokes, as well as the IInkRecognitionResult, can be persisted and retrieved for later use.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example recognizes strokes as they are made and uses a list box to report the first five alternates of the IInkRecognitionResult, and allows the user to select another alternate as the TopAlternate by double-clicking that alternates string in the list box, using ModifyTopAlternateMethod, which changes the order of the alternates. The example calls SetResultOnStrokes to save the recognition result between the recognition event and a double-click event. This example was created as a standard .exe application with a reference added to the Microsoft Tablet PC Type Library and a list box, List1, added to the form.

Option Explicit
Dim WithEvents theInkCollector As InkCollector
Dim WithEvents theRecognizerContext As InkRecognizerContext
Dim theStrokes As InkStrokes

Private Sub Form_Load()
    'Initialize the InkCollector
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
    'Initialize the recognizer's strokes
    'and assign them to the new RecognizerContext
    Set theRecognizerContext = New InkRecognizerContext
    Set theStrokes = theInkCollector.Ink.Strokes
    Set theRecognizerContext.Strokes = theStrokes
End Sub

Private Sub List1_DblClick()
    'Modify the top alternate to be the one double-clicked
    Dim theRecognitionAlternates As IInkRecognitionAlternates
    Dim theRecognitionResult As IInkRecognitionResult
    Set theRecognitionAlternates = theStrokes.RecognitionResult. _
        AlternatesFromSelection(0, -1, 5)
    Set theRecognitionResult = theStrokes.RecognitionResult
    theRecognitionResult.ModifyTopAlternate theRecognitionAlternates(List1.ListIndex)
    theRecognitionResult.SetResultOnStrokes
    'Update the list box with the new order of alternates
    List1.Clear
    Set theRecognitionAlternates = theStrokes.RecognitionResult. _
        AlternatesFromSelection(0, -1, 5)
    Dim theRecognitionAlternate As IInkRecognitionAlternate
    For Each theRecognitionAlternate In theRecognitionAlternates
        List1.AddItem (theRecognitionAlternate.String)
    Next
End Sub

Private Sub theRecognizerContext_RecognitionWithAlternates( _
ByVal RecognitionResult As MSINKAUTLib.IInkRecognitionResult, _
ByVal CustomData As Variant, _
ByVal RecognitionStatus As MSINKAUTLib.InkRecognitionStatus)
    'Update the list box with the alternates
    List1.Clear
    Dim theRecognitionAlternates As IInkRecognitionAlternates
    Set theRecognitionAlternates = RecognitionResult.AlternatesFromSelection(0, -1, 5)
    Dim theRecognitionAlternate As IInkRecognitionAlternate
    For Each theRecognitionAlternate In theRecognitionAlternates
        List1.AddItem (theRecognitionAlternate.String)
    Next
    'Save the recognition results with the strokes
    RecognitionResult.SetResultOnStrokes
End Sub

Private Sub theInkCollector_Stroke( _
ByVal Cursor As MSINKAUTLib.IInkCursor, _
ByVal Stroke As MSINKAUTLib.IInkStrokeDisp, _
Cancel As Boolean)
    'Tell the RecognizerContext to recognize the strokes
    theStrokes.Add Stroke
    theRecognizerContext.BackgroundRecognizeWithAlternates
End Sub
      

Applies To