Metodo ITfContext::TrackProperties (msctf.h)

Ottiene una proprietà speciale che può enumerare più proprietà su più intervalli.

Sintassi

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

Parametri

[in] prgProp

Contiene una matrice di identificatori di proprietà che specificano le proprietà da tenere traccia.

[in] cProp

Contiene il numero di identificatori di proprietà nella matrice prgProp .

[in] prgAppProp

Contiene una matrice di identificatori di proprietà dell'applicazione che specificano le proprietà dell'applicazione da tenere traccia.

[in] cAppProp

Contiene il numero di identificatori di proprietà dell'applicazione nella matrice prgAppProp .

[out] ppProperty

Puntatore a un puntatore dell'interfaccia ITfReadOnlyProperty che riceve la proprietà di rilevamento.

Valore restituito

Questo metodo può restituire uno di questi valori.

Valore Descrizione
S_OK
Il metodo è stato eseguito correttamente.
TF_E_DISCONNECTED
L'oggetto context non è in uno stack di documenti.
E_OUTOFMEMORY
Si è verificato un errore di allocazione della memoria.
E_INVALIDARG
Uno o più parametri non sono validi.

Commenti

Questo metodo viene usato per identificare rapidamente gli intervalli con valori di proprietà coerenti per più proprietà. Sebbene questo metodo possa essere duplicato usando solo il metodo ITfContext::GetProperty , il manager TSF può eseguire questa attività più rapidamente.

La proprietà ottenuta da questo metodo è un tipo di VT_UNKNOWN. Questa proprietà può essere usata per ottenere un enumeratore IEnumTfPropertyValue chiamando il metodo QueryInterface con IID_IEnumTfPropertyValue. Questo enumeratore contiene valori di proprietà specificati da prgProp e prgAppProp.

Esempio


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

Requisiti

   
Client minimo supportato Windows 2000 Professional [app desktop | App UWP]
Server minimo supportato Windows 2000 Server [app desktop | App UWP]
Piattaforma di destinazione Windows
Intestazione msctf.h
DLL Msctf.dll
Componente ridistribuibile TSF 1.0 in Windows 2000 Professional

Vedi anche

IEnumTfPropertyValue

ITfContext

ITfContext::GetProperty

ITfReadOnlyProperty