Compartir a través de


Recognition Event

Recognition Event

Occurs when the InkRecognizerContext has generated results from the BackgroundRecognize method.

Declaration

[C++]

void Recognition(
    [in] BSTR RecognizedString,
    [in] VARIANT CustomData,
    [in] InkRecognitionStatus RecognitionStatus
);

[Microsoft® Visual Basic® 6.0]

Public Event Recognition( _
    RecognizedString As String, _
    CustomData, _
    RecognitionStatus As InkRecognitionStatus _
)

Parameters

RecognizedString

[in] The recognition result text with the highest confidence.

For more information about the BSTR data type, see Using the Automation Library.

CustomData

[in] The object that contains the custom data for the recognition result.

For more information about the VARIANT structure, see Using the Automation Library.

RecognitionStatus

[in] The recognition status as of the most recent recognition result.

Remarks

The behavior of the application programming interface (API) is unpredictable if you try to gain access to the original RecognizerContext object from the recognition event handler. Do not attempt to do this. Instead, if you need to do this, create a flag and set it in the Recognition event handler. Then you can poll that flag to determine when to change the RecognizerContext properties outside of the event handler.

This event method is defined in the _IInkRecognitionEvents interface. The _IInkRecognitionEvents interface implements the IDispatch Leave Site interface with an identifier of DISPID_IRERecognition.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example tracks each stroke that is made and calls the BackgroundRecognize method, which subsequently causes a recognition event to occur. This sample application began with a simple form and added a text box named TextBox1, as well as a reference to the Microsoft Tablet PC Type Library. The results of the recognition appear in the text box.

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
    '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 theRecognizerContext_Recognition( _
ByVal RecognizedString As String, _
ByVal CustomData As Variant, _
ByVal RecognitionStatus As MSINKAUTLib.InkRecognitionStatus)
    'Update the text box with the top result
    TextBox1.Text = RecognizedString
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
    'Tell the RecognizerContext to recognize
    theRecognizerContext.BackgroundRecognize
End Sub

Applies To