Udostępnij za pośrednictwem


CMDUSED_SECTION - CMDUSED_END

The CMDUSED_SECTION – CMDUSED_END section allows a VSPackage to implement its own version of functionality originally supported by other VSPackages. The CMDUSED_SECTION – CMDUSED_END section is optional.

By adding a command to the CMDUSED_SECTION – CMDUSED_END section, a VSPackage informs the Visual Studio environment that although a command is implemented by other code, when the current VSPackage is active, it provides the command implementation. In this the case, when any of the windows of the current VSPackage has focus, the current VSPackage's implementations of the QueryStatus and Exec methods take precedence over implementations defined elsewhere. For additional information about command routing see Command Routing in VSPackages.

For example, if a VSPackage provides its own support for the Cut, Copy, and Paste commands available on the system Edit menu, the commands must be added to the CMDUSED_SECTION - CMDUSED_END. When any of the windows of the current VSPackage has focus, and a user selects a Cut, Copy, and Paste command, the current VSPackage, and not the IDE¸ handles these operations.

The Command Used Entry

Each command owned by another VSPackage that is to be handled by the current VSPackage must be placed in the CMDUSED_SECTION – CMDUSED_END section. Each command used entry is a single field that ends with a semicolon. For example:

Command ID;

This field is described in the following table. See "The Command Used Entry Field" section later in this topic for more details.

Field

Description

Command ID

A GUID:ID pair identifying the command that is to be overridden by this VSPackage.

Example of Commands Used Entries

The entries in this example below are used to force the Visual Studio environment to call this VSPackage's implementation of Cut, Copy, and Paste when one of its windows is active and those commands were selected from the IDE's Edit menu. In an actual file, all fields for an entry would appear as shown below.

CMDUSED_SECTION
    guidVSStd97:cmdidCopy;  //Command ID of the Copy Command in IDE
    guidVSStd97:cmdidCut;   //Command ID of the Cut Command in IDE
    guidVSStd97:cmdidPaste;   //Command ID of the Paste Command in IDE
CMDUSED_END

The Command Used Entry

Each entry in the CMDUSED_SECTION – CMDUSED_END section contains one field, ending with a semicolon.

  • Command ID

    The Command ID field identifies the existing command the VSPackage is overriding.

See Also

Concepts

Command Table Format Reference

How VSPackages Add User Interface Elements to the IDE

BUTTONS_BEGIN – BUTTONS_END