다음을 통해 공유


LineAlternates Property

LineAlternates Property

Gets the IInkRecognitionAlternates collection in which each alternate in the collection is on a separate line.

Declaration

[C++]

[C++]
[propget] HRESULT get_LineAlternates (
    [out, retval] IInkRecognitionAlternates** RecognitionAlternates
);

[Microsoft® Visual Basic® 6.0]

[Visual Basic]
Public Property Get LineAlternates() As IInkRecognitionAlternates

Property Value

IInkRecognitionAlternates The IInkRecognitionAlternates collection in which each alternate in the collection is on a separate line.

This property is read-only.

Return Value

HRESULT value Description
S_OK Success.
E_POINTER The parameter is an invalid pointer.
E_INVALIDARG The recognition range is invalid.
E_INK_EXCEPTION An exception occurred while processing.
E_OUTOFMEMORY Out of memory.

Remarks

If you have a recognition alternate for a paragraph of ink, you can use the LineAlternates property to get a collection of recognition alternates in which each alternate represents a separate line of the paragraph.

This property is an alternative to calling the AlternatesWithConstantPropertyValues method with the propertyType parameter set to the LineNumber value of the RecognitionProperty constants. For more information about properties of alternates see the RecognitionProperty constants.

Note: The IInkRecognizer object automatically determines the line metrics when drawing ink.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example uses the LineAlternates property to display the alternates within the top alternate divided by line number boundaries for the recognized ink.

[Visual Basic]
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_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 which are divided by
    'line number boundaries
    Dim theTopRecognitionAlternate As IInkRecognitionAlternate
    Set theTopRecognitionAlternate = RecognitionResult.TopAlternate
    Dim recoConstAlts As IInkRecognitionAlternates
    On Error Goto Next
    Set recoConstAlts = _
        theTopRecognitionAlternate.LineAlternates
    'Update the list box with the alternates
    Dim theRecognitionAlternate As IInkRecognitionAlternate
    For Each theRecognitionAlternate In recoConstAlts
        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
    'Tell the RecognizerContext to recognize
    theRecognizerContext.BackgroundRecognizeWithAlternates
End Sub

Applies To