(msctf.h) ITfCoNtext::TrackProperties 方法

取得可列舉多個範圍之多個屬性的特殊屬性。

語法

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

參數

[in] prgProp

包含屬性識別碼的陣列,指定要追蹤的屬性。

[in] cProp

包含 prgProp 陣列中的屬性識別碼數目。

[in] prgAppProp

包含應用程式屬性識別碼的陣列,指定要追蹤的應用程式屬性。

[in] cAppProp

包含 prgAppProp 陣列中的應用程式屬性識別碼數目。

[out] ppProperty

接收追蹤屬性之 ITfReadOnlyProperty 介面指標的指標。

傳回值

這個方法可以傳回下列其中一個值。

描述
S_OK
此方法成功。
TF_E_DISCONNECTED
內容物件不在檔堆疊上。
E_OUTOFMEMORY
發生記憶體配置失敗。
E_INVALIDARG
一或多個參數無效。

備註

這個方法可用來快速識別具有多個屬性之一致屬性值的範圍。 雖然此方法只能使用 ITfCoNtext::GetProperty 方法來複製,但 TSF 管理員可以更快速地完成這項工作。

這個方法取得的屬性是VT_UNKNOWN類型。 這個屬性可用來透過使用IID_IEnumTfPropertyValue 呼叫 QueryInterface方法來取得IEnumTfPropertyValue列舉值。 這個列舉值包含 prgPropprgAppProp所指定的屬性值。

範例


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();

需求

   
最低支援的用戶端 Windows 2000 專業版 [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows 2000 Server [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 msctf.h
Dll Msctf.dll
可轉散發套件 Windows 2000 專業版上的 TSF 1.0

另請參閱

IEnumTfPropertyValue

ITfCoNtext

ITfCoNtext::GetProperty

ITfReadOnlyProperty