Share via


Metodo ITextStoreACP::AdviseSink (textstor.h)

Il metodo ITextStoreACP::AdviseSink installa un nuovo sink di avviso dall'interfaccia ITextStoreACPSink o modifica un sink consigliato esistente. L'interfaccia sink è specificata dal parametro punk .

Sintassi

HRESULT AdviseSink(
  [in] REFIID   riid,
  [in] IUnknown *punk,
  [in] DWORD    dwMask
);

Parametri

[in] riid

Specifica l'interfaccia sink.

[in] punk

Puntatore all'interfaccia sink. Non può essere NULL.

[in] dwMask

Specifica gli eventi che notificano al sink di avviso. Per altre informazioni sui possibili valori dei parametri, vedere costanti TS_AS_*.

Valore restituito

Questo metodo può restituire uno di questi valori.

Valore Descrizione
S_OK
Il metodo è stato eseguito correttamente.
CONNECT_E_ADVISELIMIT
Non è stato possibile ottenere un puntatore all'interfaccia sink.
E_INVALIDARG
L'interfaccia sink specificata non è supportata.
E_UNEXPECTED
Impossibile ottenere l'oggetto sink specificato.

Commenti

Le chiamate successive con la stessa interfaccia, rappresentata dal parametro punk , vengono gestite come richieste di aggiornamento del parametro dwMask . I server non devono chiamare il metodo AddRef nel sink in risposta a tale richiesta.

I server mantengono solo un singolo punto di connessione. I tentativi di consigliare un secondo oggetto sink hanno esito negativo fino a quando non viene rimosso l'oggetto sink originale. Le applicazioni devono usare il metodo ITextStoreACP::UnadviseSink per annullare la registrazione dell'oggetto sink quando le notifiche non sono necessarie.

Usare questo metodo per ottenere l'interfaccia ITextStoreACPServices .

Esempio

CMyTextEditor ITextStoreACP


STDMETHODIMP CMyTextEditor::AdviseSink(REFIID riid, IUnknown *punk, DWORD dwMask)
{
        HRESULT         hr;
        IUnknown                *punkID;
        typedef struct
        {
        IUnknown                *punkID;
        ITextStoreACPSink       *pTextStoreACPSink;
        DWORD                   dwMask;
        }ADVISE_SINK, *PADVISE_SINK;    
        
        // Determine if the sink interface exists. 
        // Get the pointer to the IUnknown interface and check if the IUnknown 
        // pointer is the same as a pointer to an existing sink. 
        // If the sink exists, update the existing sink with the  
        // dwMask parameters passed to this method.      
        hr = QueryInterface(IID_IUnknown, (LPVOID*)&punkID);

        if(FAILED(hr))
        {
                hr = E_INVALIDARG;
        }       

        if(punkID == m_AdviseSink.punkID)
        {
                m_AdviseSink.dwMask = dwMask;
                hr = S_OK;
        }

        // If the sink does not exist, do the following: 
        // 1. Install a new sink. 
        // 2. Keep the pointer to the IUnknown interface to uniquely 
        //        identify this advise sink. 
        // 3. Set the dwMask parameter of this new sink to the dwMask  
        //    parameters passed to this method. 
        // 4. Increment the reference count. 
        // 5. Release the IUnknown pointer, since this pointer is no 
        //        longer required. 

        if(IsEqualIID(riid, IID_ITextStoreACPSink))
        {
                punk->QueryInterface(IID_ITextStoreACPSink,
                         (LPVOID*)&m_AdviseSink.pTextStoreACPSink);
                m_AdviseSink.punkID = punkID;
                m_AdviseSink.dwMask = dwMask;
                punkID->AddRef();
                punkID->Release();

                hr = S_OK;
        }
        return hr;
        
}

Requisiti

Requisito Valore
Client minimo supportato Windows 2000 Professional [solo app desktop]
Server minimo supportato Windows 2000 Server [solo app desktop]
Piattaforma di destinazione Windows
Intestazione textstor.h
DLL Msctf.dll
Componente ridistribuibile TSF 1.0 in Windows 2000 Professional

Vedi anche

ITextStoreACP

ITextStoreACP::UnadviseSink

ITextStoreACPServices

Costanti TS_AS_*