IContextNode::GetSubNodes メソッド

IContextNode オブジェクトの直接の子ノードを取得します。

構文

HRESULT GetSubNodes(
  [out] IContextNodes **ppSubContextNodes
);

パラメーター

ppSubContextNodes [out]

この IContextNode の直接子ノードである IContextNode オブジェクトのコレクション。

戻り値

戻り値の説明については、「 クラスとインターフェイス - インク分析」を参照してください。

解説

注意事項

メモリ リークを回避するには、サブノードのコレクションを使用する必要がなくなったときに、*ppSubContextNodesIUnknown::Release を呼び出します。

これにより、すべての子孫ノードではなく、直接の子ノードのみが返されます。

この例では、ExploreContextNodeIContextNode を調べる メソッド を示します。 メソッドは次の処理を行います。

  • コンテキスト ノードの型を取得します。
  • コンテキスト ノードが未分類のインク、分析ヒント、またはカスタム認識エンジン ノードである場合は、ヘルパー メソッドを呼び出して、ノードの種類の特定のプロパティを調べます。
  • ノードにサブノードがある場合は、それ自体を呼び出して各サブノードを調べます。
  • ノードがインク リーフ ノードの場合は、ヘルパー メソッドを呼び出してノードのストローク データを調べます。
HRESULT CMyClass::ExploreContextNode(
    IContextNode *pContextNode)
{
    // Check for certain types of context nodes.
    GUID ContextNodeType;
    HRESULT hr = pContextNode->GetType(&ContextNodeType);

    if (SUCCEEDED(hr))
    {
        if (IsEqualGUID(GUID_CNT_UNCLASSIFIEDINK, ContextNodeType))
        {
            // Call a helper method that explores unclassified ink nodes.
            hr = this->ExploreUnclassifiedInkNode(pContextNode);
        }
        else if (IsEqualGUID(GUID_CNT_ANALYSISHINT, ContextNodeType))
        {
            // Call a helper method that explores analysis hint nodes.
            hr = this->ExploreAnalysisHintNode(pContextNode);
        }
        else if (IsEqualGUID(GUID_CNT_CUSTOMRECOGNIZER, ContextNodeType))
        {
            // Call a helper method that explores custom recognizer nodes.
            hr = this->ExploreCustomRecognizerNode(pContextNode);
        }

        if (SUCCEEDED(hr))
        {
            // Check if this node is a branch or a leaf node.
            IContextNodes *pSubNodes = NULL;
            hr = pContextNode->GetSubNodes(&pSubNodes);

            if (SUCCEEDED(hr))
            {
                ULONG ulSubNodeCount;
                hr = pSubNodes->GetCount(&ulSubNodeCount);

                if (SUCCEEDED(hr))
                {
                    if (ulSubNodeCount > 0)
                    {
                        // This node has child nodes; explore each child node.
                        IContextNode *pSubNode = NULL;
                        for (ULONG index=0; index<ulSubNodeCount; index++)
                        {
                            hr = pSubNodes->GetContextNode(index, &pSubNode);

                            if (SUCCEEDED(hr))
                            {
                                // Recursive call to explore the child node of this
                                // context node.
                                hr = this->ExploreContextNode(pSubNode);
                            }

                            // Release this reference to the child context node.
                            if (pSubNode != NULL)
                            {
                                pSubNode->Release();
                                pSubNode = NULL;
                            }

                            if (FAILED(hr))
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        // This is a leaf node. Check if it contains stroke data.
                        ULONG ulStrokeCount;
                        hr = pContextNode->GetStrokeCount(&ulStrokeCount);

                        if (SUCCEEDED(hr))
                        {
                            if (ulStrokeCount > 0)
                            {
                                // This node is an ink leaf node; call helper
                                // method that explores available stroke data.
                                hr = this->ExploreNodeStrokeData(pContextNode);
                            }
                        }
                    }
                }
            }

            // Release this reference to the subnodes collection.
            if (pSubNodes != NULL)
            {
                pSubNodes->Release();
                pSubNodes = NULL;
            }
        }
    }

    return hr;
}

必要条件

要件
サポートされている最小のクライアント
Windows XP Tablet PC Edition [デスクトップ アプリのみ]
サポートされている最小のサーバー
サポートなし
Header
IACom.h (IACom_i.c も必要)
[DLL]
IACom.dll

関連項目

IContextNode

IContextNode::GetParentNode

インク分析リファレンス