Assembly: Microsoft.VisualStudio.Shell.Interop (in microsoft.visualstudio.shell.interop.dll)
int AddSubcontext ( [InAttribute] IVsUserContext pSubCtx, [InAttribute] int lPriority, out uint pdwCookie )
int AddSubcontext ( /** @attribute InAttribute() */ IVsUserContext pSubCtx, /** @attribute InAttribute() */ int lPriority, /** @attribute OutAttribute() */ /** @ref */ UInt32 pdwCookie )
[in] Pointer to theinterface (the subcontext bag).
[in] Priority of the subcontext. For a list of lPriority values, see .
[out, retval] Pointer to a unique identifier for the subcontext.
Return ValueIf the method succeeds, it returns . If it fails, it returns an error code.
HRESULT IVsUserContext::AddSubcontext( [in] IVsUserContext * pSubCtx, [in] int lPriority, [out, retval] VSCOOKIE * pdwCookie );
A context provider can contain an item for which a specific subcontext is required at run time. For example, command windows can require both context for the command window and subcontext for a selection within the command window. To add subcontext for a selection within a context provider, you need to first create a subcontext bag to hold the subcontext. For more information, see. Once the subcontext bag is created, call to add attributes, lookup keywords, or F1 keywords to the subcontext bag. You can then call IVsUserContext.AddSubcontext to link the subcontext bag to the parent context bag.
For context bags, the priority of the context is automatically assigned by the environment based on what the context bag is hooked up to, such as the editor window, tool window, and so on. However, for subcontext, you need to set the priority yourself. In the case of a selection within a command window (tool window), the new subcontext is given an lPriority value of . When the commands change in the command window, the command name is then placed in the subcontext bag.
The IVsUserContext.AddSubcontext method returns a pointer to a unique identifier for the subcontext bag in terms of the context bag. Save this pointer and use it with themethod to delete the subcontext.