Bagikan melalui


Metode IContextNodes::GetContextNode

Mengambil objek IContextNode pada indeks yang ditentukan dalam koleksi ini.

Sintaks

HRESULT GetContextNode(
  [in]  ULONG        ulIndex,
  [out] IContextNode **ppContextNode
);

Parameter

ulIndex [in]

Indeks berbasis nol dari objek IContextNode yang akan didapatkan.

ppContextNode [out]

Penunjuk ke IContextNode yang dirujuk pada indeks yang ditentukan.

Menampilkan nilai

Untuk deskripsi nilai yang dikembalikan, lihat Kelas dan Antarmuka - Analisis Tinta.

Keterangan

Perhatian

Untuk menghindari kebocoran memori, panggil IUnknown::Release di *ppContextNode saat Anda tidak perlu lagi menggunakan node konteks.

Contoh

Contoh ini menunjukkan metode, ExploreContextNode, yang memeriksa IContextNode. Metode melakukan hal berikut:

  • Mendapatkan jenis simpul konteks.
  • Memeriksa properti tertentu dari jenis node dengan memanggil metode pembantu, jika simpul konteks adalah tinta yang tidak diklasifikasikan, petunjuk analisis, atau simpul pengenal kustom.
  • Memeriksa setiap subnode dengan memanggil dirinya sendiri, jika simpul memiliki subnode.
  • Memeriksa data stroke untuk simpul dengan memanggil metode pembantu, jika simpul adalah simpul daun tinta.
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;
}

Persyaratan

Persyaratan Nilai
Klien minimum yang didukung
Windows XP Tablet PC Edition [hanya aplikasi desktop]
Server minimum yang didukung
Tidak ada yang didukung
Header
IACom.h (juga memerlukan IACom_i.c)
DLL
IACom.dll

Lihat juga

IContextNodes

Referensi Analisis Tinta