共用方式為


RemoveRecognitionResult Method

RemoveRecognitionResult Method

Removes the RecognitionResult that is associated with the InkStrokes collection.

Declaration

[C++]

HRESULT RemoveRecognitionResult ();

[Microsoft® Visual Basic® 6.0]

Public Sub RemoveRecognitionResult()

Parameters

This method takes no parameters.

Return Value

HRESULT value Description
S_OK Success.
E_INK_EXCEPTION An exception occurred inside the method.

Remarks

To set a recognition result on an InkStrokes collection, use the SetResultOnStrokes method.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example shows using a list box to store the IInkRecognitionResult and its alternates, clearing the previous results with RemoveRecognitionResult and saving the new results with the strokes that have been recognized using the SetResultOnStrokes method, and selecting another alternate as the TopAlternate of the result based on user input.

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
    'Create new RecognizerContext
    Dim theRecognizers As New InkRecognizers
    Dim theRecognizer As IInkRecognizer
    Set theRecognizer = theRecognizers.GetDefaultRecognizer
    Set theRecognizerContext = theRecognizer.CreateRecognizerContext
    'Initialize the recognizer's strokes
    'and assign them to the RecognizerContext
    Set theStrokes = theInkCollector.Ink.Strokes
    Set theRecognizerContext.Strokes = theStrokes
End Sub

Private Sub List1_DblClick()
    Dim theRecognitionAlternates As IInkRecognitionAlternates
    Set theRecognitionAlternates = _
    theStrokes.RecognitionResult.AlternatesFromSelection(0, -1, 5)
    theStrokes.RecognitionResult.ModifyTopAlternate _
        theRecognitionAlternates(List1.ListIndex)
End Sub

Private Sub theRecognizerContext_RecognitionWithAlternates( _
ByVal RecognitionResult As MSINKAUTLib.IInkRecognitionResult, _
ByVal CustomData As Variant, _
ByVal RecognitionStatus As MSINKAUTLib.InkRecognitionStatus)
    'Clear the list box
    List1.Clear
    'Get the set of alternates from the entire
    'result selection.
    Dim theRecognitionAlternates As IInkRecognitionAlternates
    Set theRecognitionAlternates = RecognitionResult.AlternatesFromSelection(0, -1, 5)
    'Update the list box with the alternates
    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)
    'When a new stroke is collected, add it to
    'the RecognizerContext's strokes collection
    theStrokes.Add Stroke
    'Remove the previous recognition result
    theInkCollector.Ink.Strokes.RemoveRecognitionResult
    'Tell the RecognizerContext to recognize
    theRecognizerContext.BackgroundRecognizeWithAlternates
End Sub

Applies To