Implementing Command Handling for Nested Projects
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Implementing Command Handling for Nested Projects.
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.
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.
To implement command handling
When the user selects a nested project or a node in a nested project:
- The IDE calls the QueryStatus method.
— or —
- 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.
The parent project can examine parameters to be passed to
QueryStatus, such aspguidCmdGroupandprgCmds, 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..