Partager via


How to: Register for Text Buffer Events with the Legacy API

If you are accessing the text buffer by using the legacy API, you should register for text buffer events as shown in the following procedure.

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 interface ID of the events for which you want to register.

    For example, if you want to register for IVsTextLinesEvents, 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 for which you want to register, for example, the IVsTextLinesEvents interface.

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

See Also

Concepts

Text Buffer Events in the Legacy API