IInkAnalyzer::GetRootNode method

Gets the root IContextNode of the IInkAnalyzer object's context tree.

Syntax


HRESULT GetRootNode(
  [out] IContextNode **ppRootNode
);

Parameters

ppRootNode [out]

The root IContextNode of the IInkAnalyzer object's context tree.

Return value

For a description of the return values, see Classes and Interfaces - Ink Analysis.

Remarks

Caution  To avoid a memory leak, call IUnknown::Release on ppRootNode when you no longer need to use the root node.
 

The IInkAnalyzer maintains a tree of IContextNode objects. These objects contain both input for analysis and the results of analysis. When strokes are initially added to the IInkAnalyzer, the IInkAnalyzer assigns them to a IContextNode of type UnclassifiedInk (See IContextNode::GetType and Context Node Types). After the strokes are analyzed, the IInkAnalyzer assigns them to appropriate IContextNode objects in the tree. For more information about using the IInkAnalyzer to analyze ink, see Ink Analysis Overview.

Examples

The following example shows a method that walks the ink analyzer's IContextNode results tree. If the IInkAnlyzer is not currently performing ink analysis, the method does the following.

  • Gets the top recognition string.
  • Gets the ink analyzer's root node.
  • Calls a helper method, ExploreContextNode, to examine the root node and its child nodes.

// Helper method that explores the current analysis results of an ink analyzer.
HRESULT CMyClass::ExploreAnalysisResults(
    IInkAnalyzer *pInkAnalyzer)
{
    // Check that the ink analyzer is not currently analyzing ink.
    VARIANT_BOOL bIsAnalyzing;
    HRESULT hr = pInkAnalyzer->IsAnalyzing(&bIsAnalyzing);

    if (SUCCEEDED(hr))
    {
        if (bIsAnalyzing)
        {
            return E_PENDING;
        }

        // Get the ink analyzer's best-result string.
        BSTR recognizedString = NULL;
        hr = pInkAnalyzer->GetRecognizedString(&recognizedString);

        if (SUCCEEDED(hr))
        {
            // Insert code that records the ink analyzer's best-result string here.

            // Get the ink analyzer's root node.
            IContextNode *pRootNode = NULL;
            hr = pInkAnalyzer->GetRootNode(&pRootNode);

            if (SUCCEEDED(hr))
            {
                // Call a helper method that recursively explores context
                // nodes and their subnodes.
                hr = this->ExploreContextNode(pRootNode);
            }

            // Release this reference to the root node.
            if (pRootNode != NULL)
            {
                pRootNode->Release();
                pRootNode = NULL;
            }
        }

        // Free the system resources for the recognized string.
        SysFreeString(recognizedString);
    }

    return hr;
}


Requirements

Minimum supported client

Windows XP Tablet PC Edition [desktop apps only]

Minimum supported server

None supported

Header

IACom.h (also requires IACom_i.c)

DLL

IACom.dll

See also

IInkAnalyzer
IContextNode
Context Node Types
Ink Analysis Reference

 

 

Show: