Implementing Command Handling for Nested Projects

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The IDE can pass commands that are passed through the IVsUIHierarchy and the IOleCommandTarget interfaces to nested projects, or parent projects can filter or override the commands.

Note

Only commands ordinarily handled by the parent project can be filtered. Commands such as Build and Deploy that are handled by the IDE cannot be filtered.

The following steps describe the process for implementing command handling.

Procedures

To implement command handling

  1. When the user selects a nested project or a node in a nested project:

    1. The IDE calls the QueryStatus method.

      — or —

    2. If the command originated in a hierarchy window, such as a shortcut menu command in Solution Explorer, the IDE calls the QueryStatusCommand method on the project's parent.

  2. The parent project can examine parameters to be passed to QueryStatus, such as pguidCmdGroup and prgCmds, to determine whether the parent project should filter the commands. If the parent project is implemented to filter commands, it should set:

    prgCmds[0].cmdf = OLECMDF_SUPPORTED;
    // make sure it is disabled
    prgCmds[0].cmdf &= ~MSOCMDF_ENABLED;
    

    Then the parent project should return S_OK.

    If the parent project does not filter the command, it should just return S_OK. In this case, the IDE automatically routes the command to the child project.

    The parent project does not have to route the command to the child project. The IDE performs this task..

See also