Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

IVsColorableItem Interface

Provides default font colors, font style, and item name information for a custom colorable item.

Namespace: Microsoft.VisualStudio.TextManager.Interop
Assembly: Microsoft.VisualStudio.TextManager.Interop (in microsoft.visualstudio.textmanager.interop.dll)

public interface IVsColorableItem
/** @attribute InterfaceTypeAttribute(1) */ 
/** @attribute GuidAttribute("56694A40-78D0-45DD-AB15-681BC207579C") */ 
public interface IVsColorableItem
public interface IVsColorableItem

The display name for the custom colorable item should be localized.

The color values returned from this interface are predefined colors. High color (24-bit) values can be returned through the IVsHiColorItem interface. See the IVsHiColorItem interface for an example.

How to implement custom colorable items is described in Custom Colorable Items.

Notes to Implementers Implement this interface to provide font and name information about a custom colorable item that is returned from a language service. If you want to support high color values, you must implement the IVsHiColorItem interface on the same object that implements the IVsColorableItem interface.

Notes to Callers An IVsColorableItem object can be obtained by calling the GetColorableItem method on the IVsProvideColorableItems interface.

This example is from a language service.

using Microsoft.VisualStudio.TextManager.Interop;

namespace MyNamespace
    internal class MyColorItem : IVsColorableItem
        // Private fields.
        private COLORINDEX foreColor;
        private COLORINDEX backColor;
        private FONTFLAGS fontFlags;
        private string name;
        private string displayName;

        // Public constructor.

        public MyColorItem(string name,
                           string displayName,
                           COLORINDEX foreColor,
                           COLORINDEX backColor,
                           FONTFLAGS fontFlags)
            this.name = name;
            this.displayName = displayName;
            this.foreColor = foreColor;
            this.backColor = backColor;
            this.fontFlags = fontFlags;

        // IVsColorableItem methods.
        #region IVsColorableItem Members

        int IVsColorableItem.GetDefaultColors(COLORINDEX[] piForeground,
                                              COLORINDEX[] piBackground)
            int retval = VSConstants.E_POINTER;
            if (piForeground != null)
                piForeground[0] = this.foreColor;
                retval = VSConstants.S_OK;
            if (piBackground != null)
                piBackground[0] = this.backColor;
            return retval;

        int IVsColorableItem.GetDefaultFontFlags(out uint pdwFontFlags)
            pdwFontFlags = (uint)this.fontFlags;
            return VSConstants.S_OK;

        int IVsColorableItem.GetDisplayName(out string pbstrName)
            pbstrName = this.displayName;
            return VSConstants.S_OK;


    // Example of how to instantiate the MyColorItem class.

    public class MyLanguageService
        private ColorableItem[] colorableItemsList;

        public MyLanguageService()
            colorableItemsList = {
                new MyColorableItem("MyLanguage- Text",
                                    "MyLanguage- Text",

                new MyColorableItem("MyLanguage- Keyword",
                                    "MyLanguage- Keyword",

                new MyColorableItem("MyLanguage- Operator",
                                    "MyLanguage- Operator",

Community Additions

© 2015 Microsoft