Bagikan melalui


Metode ITfContext::TrackProperties (msctf.h)

Mendapatkan properti khusus yang dapat menghitung beberapa properti melalui beberapa rentang.

Sintaks

HRESULT TrackProperties(
  [in]  const GUID          **prgProp,
  [in]  ULONG               cProp,
  [in]  const GUID          **prgAppProp,
  [in]  ULONG               cAppProp,
  [out] ITfReadOnlyProperty **ppProperty
);

Parameter

[in] prgProp

Berisi array pengidentifikasi properti yang menentukan properti yang akan dilacak.

[in] cProp

Berisi jumlah pengidentifikasi properti dalam array prgProp .

[in] prgAppProp

Berisi array pengidentifikasi properti aplikasi yang menentukan properti aplikasi yang akan dilacak.

[in] cAppProp

Berisi jumlah pengidentifikasi properti aplikasi dalam array prgAppProp .

[out] ppProperty

Penunjuk ke penunjuk antarmuka ITfReadOnlyProperty yang menerima properti pelacakan.

Nilai kembali

Metode ini dapat mengembalikan salah satu nilai ini.

Nilai Deskripsi
S_OK
Metode berhasil.
TF_E_DISCONNECTED
Objek konteks tidak ada di tumpukan dokumen.
E_OUTOFMEMORY
Terjadi kegagalan alokasi memori.
E_INVALIDARG
Satu atau beberapa parameter tidak valid.

Keterangan

Metode ini digunakan untuk mengidentifikasi rentang dengan cepat dengan nilai properti yang konsisten untuk beberapa properti. Meskipun metode ini dapat diduplikasi hanya menggunakan metode ITfContext::GetProperty , manajer TSF dapat menyelesaikan tugas ini dengan lebih cepat.

Properti yang diperoleh dengan metode ini adalah jenis VT_UNKNOWN. Properti ini dapat digunakan untuk mendapatkan enumerator IEnumTfPropertyValue dengan memanggil metode QueryInterface dengan IID_IEnumTfPropertyValue. Enumerator ini berisi nilai properti yang ditentukan oleh prgProp dan prgAppProp.

Contoh


const GUID *rgGuids[2] = {  &GUID_PROP_COMPOSING,
                            &GUID_PROP_ATTRIBUTE };
HRESULT hr;
ITfReadOnlyProperty *pTrackProperty;
TF_SELECTION sel;
IEnumTfRanges *pEnumRanges;
ITfRange *pRangeValue;

// Get the tracking property. 
hr = pContext->TrackProperties(NULL, 0, rgGuids, 2, &pTrackProperty);

// Get the selection range. 
hr = pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &sel, &cFetched);

// Use the property from TrackProperties to get an enumeration of the ranges  
// within the selection range that have the same property values. 
hr = pTrackProperty->EnumRanges(ec, &pEnumRanges, sel.range);

// Enumerate the ranges of text. 
while(pEnumRanges->Next(1, &pRangeValue, NULL) == S_OK)
{
    VARIANT varTrackerValue;
    TF_PROPERTYVAL tfPropertyVal;
    IEnumTfPropertyValue *pEnumPropVal;

    // Get the values for this range of text. 
    hr = pTrackProperty->GetValue(ec, pRangeValue, &varTrackerValue);

    // Because pTrackProperties originates from TrackProperties, 
    // varTrackerValue can be identified as a VT_UNKNOWN/IEnumTfPropertyValue. 
    varTrackerValue.punkVal->QueryInterface(    IID_IEnumTfPropertyValue,
                                                (void **)&pEnumPropVal);

    while(pEnumPropVal->Next(1, &tfPropertyVal, NULL) == S_OK)
    {
        BOOL fComposingValue;
        TfGuidAtom gaDispAttrValue;
        
        // Is this the composition property? 
        if (IsEqualGUID(tfPropertyVal.guidId, GUID_PROP_COMPOSING))
        {
            fComposingValue = (BOOL)tfPropertyVal.varValue.lVal;
        }
        // Or is this the attribute property? 
        else if (IsEqualGUID(tfPropertyVal.guidId, GUID_PROP_ATTRIBUTE))
        {
            gaDispAttrValue = (TfGuidAtom)tfPropertyVal.varValue.lVal;
        }
        
        // Clear the property. 
        VariantClear(&tfPropertyVal.varValue);
    }

    // Clear the tracker property. 
    VariantClear(&varTrackerValue);

    // Release the property enumerator. 
    pEnumPropVal->Release();

    // Release the range. 
    pRangeValue->Release();
}

// Release the selection range. 
sel.range->Release();

Persyaratan

   
Klien minimum yang didukung Windows 2000 Professional [aplikasi desktop | Aplikasi UWP]
Server minimum yang didukung Windows 2000 Server [aplikasi desktop | Aplikasi UWP]
Target Platform Windows
Header msctf.h
DLL Msctf.dll
Redistribusi TSF 1.0 di Windows 2000 Professional

Lihat juga

IEnumTfPropertyValue

ITfContext

ITfContext::GetProperty

ITfReadOnlyProperty