EndInkInput Method
EndInkInput Method |
Stops adding ink to the InkRecognizerContext object.
Declaration
[C++]
HRESULT EndInkInput ();
[Microsoft® Visual Basic® 6.0]
Public Sub EndInkInput()
Parameters
This method takes no parameters.
Return Value
HRESULT value | Description |
---|---|
S_OK | Success. |
E_OUTOFMEMORY | Cannot allocate memory to complete the operation. |
E_FAIL | An unspecified error occurred. |
E_INK_EXCEPTION | An exception occurred inside the method. |
Remarks
After you call this method, you cannot add strokes to the context.
This method deals with partial recognition. Partial recognition is the ability of the recognizer to return results even if the application has not called EndInkInput (which signals to the application that all the ink has been entered). Partial recognition occurs only if the recognizer can determine that ink has been entered before a call to EndInkInput, and not all recognizers support this feature. Recognizers that do not support partial recognition do not return any result until EndInkInput is called.
Incremental recognition is the ability of the recognizer to process only a small part of the ink that has been passed to it and return a result. For example, consider that an application contains five lines of ink and uses a recognizer of Latin script. The recognizer can process only one line at a time and return a result. This process is used in the idle loop of the background processing thread.
Example
[Visual Basic 6.0]
This Visual Basic 6.0 example shows a button handler that recognizes the ink in its InkRecognizerContext and displays it in a text box if no errors occur. This sample application began with a standard .exe application and added a text box named Text1 and a control button, Command1, as well as a reference to the Tablet PC Type Library. The results of the recognition appear in the text box.
Option Explicit
Dim WithEvents theInkCollector As InkCollector
Dim theRecognizerContext As InkRecognizerContext
Dim theRecognitionResult As IInkRecognitionResult
Dim theStrokes As InkStrokes
Private Sub Command1_Click()
theRecognizerContext.EndInkInput
Dim theRecognitionStatus As InkRecognitionStatus
Set theRecognitionResult = theRecognizerContext.Recognize(theRecognitionStatus)
If InkRecognitionStatus.IRS_NoError = theRecognitionStatus Then
Text1.Text = theRecognitionResult.TopString
Else
'Handle the error conditions here.
Text1.Text = "Error!"
End If
End Sub
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 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
End Sub