IContextNode::GetStrokeCount 方法

获取与 IContextNode 对象关联的笔划数。

语法

HRESULT GetStrokeCount(
  [out] ULONG *pulStrokeCount
);

parameters

pulStrokeCount [out]

IContextNode 对象关联的笔划数。

返回值

有关返回值的说明,请参阅 类和接口 - 墨迹分析

备注

只有墨迹叶上下文节点具有关联的笔划数据 (请参阅 IContextNode::GetType) 。

示例

此示例演示了一个方法, ExploreContextNode该方法检查 IContextNode。 该方法将执行以下操作:

  • 获取上下文节点的类型。
  • 如果上下文节点是未分类的墨迹、分析提示或自定义识别器节点,则通过调用帮助程序方法检查节点类型的特定属性。
  • 如果节点具有子节点,则通过调用自身来检查每个子节点。
  • 如果节点是墨迹叶节点,则通过调用帮助程序方法检查节点的笔划数据。
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::GetStrokeIds

IContextNode::GetStrokeId

墨迹分析参考