ICoNtextNode::GetSubNodes 方法

取得 ICoNtextNode 物件的直接子節點。

語法

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

參數

ppSubCoNtextNodes [out]

屬於這個 ICoNtextNode 之直接子節點之 ICoNtextNode物件的集合。

傳回值

如需傳回值的描述,請參閱 類別和介面 - 筆跡分析

備註

警告

若要避免記憶體流失,當您不再需要使用子節點的集合時,請在 *ppSubCoNtextNodes上呼叫IUnknown::Release

這只會傳回直接子節點,而不是所有子系節點。

範例

這個範例示範會檢查ICoNtextNode的方法 ExploreContextNode 。 方法會執行下列動作:

  • 取得內容節點的類型。
  • 如果內容節點是未分類的筆跡、分析提示或自訂辨識器節點,則呼叫協助程式方法來檢查節點類型的特定屬性。
  • 如果節點有子節點,則呼叫本身來檢查每個子節點。
  • 如果節點是筆跡分葉節點,則呼叫協助程式方法來檢查節點的筆劃資料。
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 [僅限傳統型應用程式]
最低支援的伺服器
都不支援
標頭
IACom.h (也需要 IACom_i.c)
DLL
IACom.dll

另請參閱

ICoNtextNode

ICoNtextNode::GetParentNode

筆跡分析參考