How to: Advise Text Buffer Events

Use the following procedure to advise text buffer events.

To advise text buffer events

  1. From a pointer to one of the interfaces on VsTextBuffer, call QueryInterface for a pointer to IConnectionPointContainer.

  2. Call the FindConnectionPoint method, and pass in the name of the connection point you want advise text buffer events on.

    For example, if you want to advise for IVsTextLinesEvents events, then pass in an interface ID of IID_IVsTextLinesEvents.

    The text buffer returns a pointer to the IConnectionPoint interface for the appropriate connection point object.

  3. Using this pointer, call the Advise method, passing in a pointer to your implementation of the events interface you want to advise on the text buffer, for example, the IVsTextLinesEvents interface.

    The environment returns a cookie that you can then use to unadvise events by calling the Unadvise method.

See Also

Concepts

Text Buffer Events