IVsUserContext.AddSubcontext Method
Links a subcontext bag to a parent context bag.
Namespace: Microsoft.VisualStudio.Shell.Interop
Assembly: Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)
Syntax
'Declaration
Function AddSubcontext ( _
pSubCtx As IVsUserContext, _
lPriority As Integer, _
<OutAttribute> ByRef pdwCookie As UInteger _
) As Integer
int AddSubcontext(
IVsUserContext pSubCtx,
int lPriority,
out uint pdwCookie
)
int AddSubcontext(
[InAttribute] IVsUserContext^ pSubCtx,
[InAttribute] int lPriority,
[OutAttribute] unsigned int% pdwCookie
)
abstract AddSubcontext :
pSubCtx:IVsUserContext *
lPriority:int *
pdwCookie:uint32 byref -> int
function AddSubcontext(
pSubCtx : IVsUserContext,
lPriority : int,
pdwCookie : uint
) : int
Parameters
pSubCtx
Type: Microsoft.VisualStudio.Shell.Interop.IVsUserContext[in] Pointer to the IVsUserContext interface (the subcontext bag).
lPriority
Type: Int32[in] Priority of the subcontext. For a list of lPriority values, see VSUSERCONTEXTPRIORITY.
pdwCookie
Type: UInt32%[out, retval] Pointer to a unique identifier for the subcontext.
Return Value
Type: Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.
Remarks
COM Signature
From context.idl:
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 Creating a Context or Subcontext Bag. Once the subcontext bag is created, call AddAttribute 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 VSUC_Priority_ToolWndSel. 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 the RemoveSubcontext method to delete the subcontext.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.