Compartilhar via


Accessing Stored Font and Color Settings

The Visual Studio integrated development environment (IDE) stores modified settings for fonts and colors in the registry. You can use the IVsFontAndColorStorage interface to access these settings.

To Initiate State Persistence of Fonts and Colors

Font and color information is stored by category in the following registry location: [HKCU\SOFTWARE\Microsoft \Visual Studio\<Visual Studio version>\FontAndColors\<CategoryGUID>], where <CategoryGUID> is the category GUID.

Therefore, to initiate persistence, a VSPackage must:

  • Obtain an IVsFontAndColorStorage interface by calling QueryService against the global service provider.

    QueryService must be called by using a service ID argument of SID_SVsFontAndColorStorage and an interface ID argument of IID_IVsFontAndColorStorage.

  • Use the OpenCategory method to open a category to be persisted by using the category's GUID and a mode flag as arguments.

    The mode, specified by the fFlags argument, is constructed from values in the __FCSTORAGEFLAGS enumeration. This mode controls:

    • The settings that can be accessed through the IVsFontAndColorStorage interface.

    • Either all settings or only those that users modify and that are retrievable through the IVsFontAndColorStorage interface.

    • The manner of propagating the changes to user settings.

    • The format of color values that are used.

To Use State Persistence of Fonts and Colors

Persisting fonts and colors involves:

  • Synchronizing the IDE settings with settings stored in the registry.

  • Propagating registry modification information.

  • Setting and retrieving settings stored in the registry.

Synchronizing the storage setting with the IDE settings is largely transparent. The underlying IDE automatically writes updated settings for Display Items to the registry entries of categories.

If multiple VSPackages share a particular category, a VSPackage should require that events are generated when methods of the IVsFontAndColorStorage interface are used to modify stored registry settings.

By default, event generation is not enabled. To enable event generation, a category must be opened by using FCSF_PROPAGATECHANGES. This causes the IDE to call the appropriate IVsFontAndColorEvents method that a VSPackage implements.

Note

Modifications through the Font and Color property page generate events independent of IVsFontAndColorStorage. You can use the IVsFontAndColorCacheManager interface to determine whether an update of cached font and color settings is needed before calling the methods of the IVsFontAndColorStorage class.

Bb166382.collapse_all(pt-br,VS.110).gifStoring and Retrieving Information

To obtain or configure information that a user can modify for a named display item in an open category, VSPackages call the GetItem and SetItem methods.

Information about font attributes for a particular category is obtained by using the GetFont and SetFont methods.

Note

The fFlags argument that is passed to the OpenCategory method when that category was opened defines the behavior of the GetItem and the GetFont methods. By default, these methods only return information aboutdisplay itemsthat have changed. However, if a category is opened by using the FCSF_LOADDEFAULTS flag, both updated and unchanged display items can be accessed by GetItem and GetFont.

By default, only changed Display Items information is kept in the registry. The IVsFontAndColorStorage interface cannot be used to retrieve all settings for fonts and colors.

Note

The GetItem and the GetFont methods return REGDB_E_KEYMISSING, (0x80040152L) when you use them to retrieve information about unchanged Display Items.

The settings of all Display Items in a particular Category can be obtained by using the methods of the T:Microsoft.VisualStudio.Shell.Interop.IVsFontAndColorDefaults interface.

See Also

Reference

IVsFontAndColorStorage

__FCSTORAGEFLAGS

Concepts

Implementing Custom Categories and Display Items