ISpGrammarBuilder::CreateNewState
ISpGrammarBuilder::CreateNewState creates a new state in the same grammar rule as hState.
HRESULT CreateNewState(
SPSTATEHANDLE hState,
SPSTATEHANDLE *phState
);
Parameters
- hState
- [in] Handle to any existing state in the grammar rule.
- phState
- [out] Address of the state handle for a new state in the same grammar rule.
Return values
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_INVALIDARG | The hState is not a valid state handle. |
E_POINTER | The phState pointer is invalid. |
E_OUTOFMEMORY | Exceeded available memory. |
Example
The following code snippet illustrates the use of CreateNewState.
// Declare local identifiers:
HRESULT hr = S_OK;
CComPtr<ISpGrammarBuilder> cpGrammarBuilder;
SPSTATEHANDLE hInit;
SPSTATEHANDLE hState;
SPSTATEHANDLE hState2;
hr = cpGrammarBuilder->GetRule(L"rule1", 1, 0, TRUE, &hInit;);
if (SUCCEEDED (hr))
{
// Call CreateNewState using the initial state.
hr = cpGrammarBuilder->CreateNewState(hInit, &hState;);
}
if (SUCCEEDED (hr))
{
// Call CreateNewState using hState != hInit.
hr = cpGrammarBuilder->CreateNewState(hState, &hState2;);
}
if (SUCCEEDED(hr))
{
// Do something here.
}