How to: Use Text Markers
Text markers can be applied to edit a IVsTextBuffer object.
Procedures
To apply text markers
Obtain an instance of the IVsTextManager class.
Note
The core editor automatically applies standard text markers to any document that it is editing, and it should not be necessary to apply standard text markers explicitly.
Obtain a marker type ID of the marker you are interested in by calling the GetRegisteredMarkerTypeID method with the GUID of the text marker you wish to work with.
Note
Do not use the GUID of the VSPackage or of the service that provides the text marker.
Use the marker type ID obtained by calling the GetRegisteredMarkerTypeID method as a parameter to call the CreateLineMarker method or the CreateStreamMarker method to apply a text marker to a given region of text.
To add features to text markers
It may be desirable to add additional features to a text marker, such as tool tips, a special context menu, or handler for special circumstances. To do so:
Create an object implementing the IVsTextMarkerClient interface.
If additional functionality is desired, implement the IVsTextMarkerClientEx, and the IVsTextMarkerClientAdvanced interfaces on the same object that implements the IVsTextMarkerClient interface.
Pass the IVsTextMarkerClient interface that you create, to the call to the CreateLineMarker method or the CreateStreamMarker method used to apply the text marker to a given region of text.
When adding context menu support to a text marker region it is necessary to create the menu.
For more information on how to create a context menu see, Context Menus.
The Visual Studio environment calls the methods of the supplied interfaces, such as the GetTipText method, or the ExecMarkerCommand method as needed.
See Also
Tasks
How to: Add Standard Text Markers
How to: Create Custom Text Markers
How to: Implement Error Markers