ISpRecoGrammar::SetGrammarState (Windows CE 5.0)
This method sets the grammar state. See also ISpRecoGrammar::GetGrammarState.
An application can use the grammar state of a grammar object to control receipt of recognitions for rules. For example, an application might create a new object implementing ISpRecoGrammar, set the grammar state to SPGS_DISABLED, dynamically generate the rules, and finally reset the grammar state to SPGS_ENABLED when grammar construction is completed.
HRESULT SetGrammarState(SPGRAMMARSTATE eGrammarState);
Parameters
- eGrammarState
[in] Value indicating the state of the grammar. Possible values are defined for the SPGRAMMARSTATE enumeration. The default grammar state is SPGS_ENABLED.
Return Values
The following table shows the possible return values.
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_INVALIDARG | eGrammarState is not a valid state. |
FAILED(hr) | Appropriate error message. |
Example
The following code snippet illustrates the use of this method to set the state of a grammar.
HRESULT hr = S_OK;
// create a new grammar object
hr = cpRecoContext->CreateGrammar(GRAM_ID, &cpRecoGrammar);
// Check hr
// disable the grammar, so that recognitions are not received
hr = cpRecoGrammar->SetGrammarState(SPGS_DISABLED);
// Check hr
// ... build the grammar ...
// activate the grammar, so applications start receiving recognitions
hr = cpRecoGrammar->SetGrammarState(SPGS_ENABLED);
// Check hr
Requirements
OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.
See Also
ISpRecoGrammar | SAPI Interfaces
Send Feedback on this topic to the authors