GetRootNode Method
Collapse the table of content
Expand the table of content

IInkAnalyzer::GetRootNode method

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


HRESULT GetRootNode(
  [out] IContextNode **ppRootNode


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.


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.


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 = NULL;

        // Free the system resources for the recognized string.

    return hr;


Minimum supported client

Windows XP Tablet PC Edition [desktop apps only]

Minimum supported server

None supported


IACom.h (also requires IACom_i.c)



See also

Context Node Types
Ink Analysis Reference



Community Additions

© 2015 Microsoft