다음을 통해 공유


IVsUserContext.GetSubcontext(Int32, IVsUserContext) Method

Definition

Returns a specified subcontext bag from the parent context bag.

public:
 int GetSubcontext(int i, [Runtime::InteropServices::Out] Microsoft::VisualStudio::Shell::Interop::IVsUserContext ^ % ppSubCtx);
public:
 int GetSubcontext(int i, [Runtime::InteropServices::Out] Microsoft::VisualStudio::Shell::Interop::IVsUserContext ^ &  ppSubCtx);
int GetSubcontext(int i, [Runtime::InteropServices::Out] Microsoft::VisualStudio::Shell::Interop::IVsUserContext const & & ppSubCtx);
public int GetSubcontext (int i, out Microsoft.VisualStudio.Shell.Interop.IVsUserContext ppSubCtx);
abstract member GetSubcontext : int * IVsUserContext -> int
Public Function GetSubcontext (i As Integer, ByRef ppSubCtx As IVsUserContext) As Integer

Parameters

i
Int32

[in] Index position of the subcontext bag on the parent context bag. This index is zero based.

ppSubCtx
IVsUserContext

[out, retval] Pointer to the IVsUserContext interface, representing the subcontext bag.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From context.idl:

HRESULT IVsUserContext::GetSubcontext(  
   [in] int i,  
   [out, retval] IVsUserContext ** ppSubCtx  
);  

To add subcontext for a selection in a context provider, like a command in a tool window or a keyword in a language service, you need to create a subcontext bag. A subcontext bag is simply a context bag that the parent context bag points to and which holds context for the selection. By having the parent context bag point to the subcontext bag, the subcontext is also made available to the Help information provider.

Use the IVsUserContext.GetSubcontext method in conjunction with CountSubcontexts to iterate through the subcontext bags for the context provider.

Applies to