Share via


IsStringSupported Method

IsStringSupported Method

Indicates whether the system dictionary, user dictionary, or word list contain a specified string.

Declaration

[C++]

HRESULT IsStringSupported (
    [in] BSTR s,
    [out, retval] VARIANT_BOOL *Supported
);

[Microsoft® Visual Basic® 6.0]

Public Function IsStringSupported( _
    s As String _
) As Boolean

Parameters

s

[in] The string to look up in the dictionaries and word list.

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

Supported

[out] Returns TRUE if the string is in the dictionary or word list; otherwise FALSE.

Return Value

HRESULT value Description
S_OK One of the dictionaries contains the string.
E_POINTER A parameter contained an invalid pointer.
E_INVALIDARG Invalid input string.
E_INK_EXCEPTION An exception occurred while processing.
E_OUTOFMEMORY Cannot allocate memory operation.
E_UNEXPECTED Unexpected parameter or property type.

Remarks

This method considers all flags and factoids, among other things, that give context to the string that is being tested.

This method does not search the user dictionary if you specify a word list for the context. The recognizer uses the speech dictionary in Microsoft Office XP.

Use the Factoid property to limit the search to the system dictionary or the word list that is associated with the context. For example, to limit the search to the system dictionary, specify the SystemDictionary factoid. To improve the results, you may also need to set the RecognitionFlags property.

Example

[Visual Basic 6.0]

This Visual Basic 6.0 example adds a string to the InkWordList that is used by the InkRecognizerContext object. It uses a command button, Command1, and a text box, Text1, on a standard Windows Forms application which has the Microsoft Tablet PC Type Library added as a reference. When the command button is pressed, the ink on the form is recognized, and IsStringSupported is called to report if the top result string is supported by the recognizer context.

Option Explicit
Dim theInkCollector As InkCollector
Dim theRecognizerContext As New InkRecognizerContext
Dim theWordlist As New InkWordList

Private Sub Form_Load()
    Set theInkCollector = New InkCollector
    theInkCollector.hWnd = Me.hWnd
    theInkCollector.Enabled = True
    theWordlist.AddWord "XYZZY"
    Set theRecognizerContext.WordList = theWordlist
End Sub

Private Sub Command1_Click()
    Set theRecognizerContext.Strokes = theInkCollector.Ink.Strokes
    Dim theRecognitionStatus As InkRecognitionStatus
    Dim theRecognitionResult As IInkRecognitionResult
    On Error Resume Next
    Set theRecognitionResult = theRecognizerContext.Recognize(theRecognitionStatus)

    If InkRecognitionStatus.IRS_NoError = theRecognitionStatus Then
        If theRecognizerContext.IsStringSupported(theRecognitionResult.TopString) Then
            Text1.Text = theRecognitionResult.TopString & " is supported."
        Else
            Text1.Text = theRecognitionResult.TopString & " is not supported."
        End If
    Else
        'Handle the error conditions here.
        Text1.Text = ""
    End If
End Sub

Applies To