Udostępnij za pośrednictwem


How to: Open an Options Page

Visual Studio users typically view options pages by opening the Options dialog box. However, an options page can also be displayed programmatically. For example, if your package installs a feature that requires configuration by the user, you can display the appropriate options page to make it easier for the user to fulfill the requirements.

To display a custom options page

  1. Create an options page. For more information, see Creating Options Pages By Using Managed Package Framework Classes.

  2. Get the Type of the options page by applying the typeof keyword to the name of the class that defines the options page.

  3. Call the ShowOptionPage by using the Type of the options page as a parameter.

    The following example displays an options page named HelloWorldOptions:

    Type optionsPageType = typeof(HelloWorldOptions);
    ShowOptionPage(optionsPageType);
    

To display an options page that is defined by Visual Studio

  1. In the registry subkey HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\ToolsOptionsPages\, find the node for the options page you want to display and then note its GUID, which is the value of the Page key.

  2. Create a CommandID instance that has the constants GUID_VSStandardCommandSet97 and cmdidToolsOptions as parameters.

    This specifies the Options dialog box.

  3. Call the GlobalInvoke method by using the CommandID instance and the GUID string as parameters.

    The following example displays the General tab of the Text Editor options page:

    // GUID of Options>TextEditor>General 
    string targetGUID = "734A5DE2-DEBA-11d0-A6D0-00C04FB67F6A";
    var command = new CommandID(
        VSConstants.GUID_VSStandardCommandSet97, 
        VSConstants.cmdidToolsOptions);
    var mcs = GetService(typeof(IMenuCommandService)) 
        as MenuCommandService;
    mcs.GlobalInvoke(command, targetGUID);
    

See Also

Concepts

Creating Options Pages By Using Automation

Reference

Package

Other Resources

Options Pages

Change History

Date

History

Reason

July 2008

Added topic.

Information enhancement.