共用方式為


IVsMonitorSelection.GetCmdUIContextCookie Method

Registers a command UI context GUID and returns cookie value.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Declaration
Function GetCmdUIContextCookie ( _
    ByRef rguidCmdUI As Guid, _
    <OutAttribute> ByRef pdwCmdUICookie As UInteger _
) As Integer
int GetCmdUIContextCookie(
    ref Guid rguidCmdUI,
    out uint pdwCmdUICookie
)
int GetCmdUIContextCookie(
    [InAttribute] Guid% rguidCmdUI, 
    [OutAttribute] unsigned int% pdwCmdUICookie
)
abstract GetCmdUIContextCookie : 
        rguidCmdUI:Guid byref * 
        pdwCmdUICookie:uint32 byref -> int
function GetCmdUIContextCookie(
    rguidCmdUI : Guid, 
    pdwCmdUICookie : uint
) : int

Parameters

  • rguidCmdUI
    Type: Guid%

    [in] GUID representing a specific command UI context. Command UI context GUID values are defined by the environment and by VSPackages to meet specific needs. See the Remarks section below for a list of command UI GUIDs defined by the environment.

  • pdwCmdUICookie
    Type: UInt32%

    [out] Pointer to a DWORD representing the GUID value in rguidCmdUI.

Return Value

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

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsMonitorSelection::GetCmdUIContextCookie(
   [in]  REFGUID   rguidCmdUI,
   [out] VSCOOKIE *pdwCmdUICookie
);

This method registers the specified GUID and returns a cookie to represent that GUID. The active state of the GUID can be changed by calls to the SetCmdUIContext method and can be read by calls to the IsCmdUIContextActive method.

Note   Once a GUID is registered through this method, the GUID remains registered until the IDE exits.

Command UI contexts involve associating a GUID to an action or a change in the UI. They are used in a variety of situations. VSPackages often define command UI contexts to associate a GUID to the activation of a toolbar or to the availability of a command. The environment defines the following command UI contexts. VSPackages are free to define additional context GUIDs but a VSPackage must change only the context GUIDs it registers.

Command UI Context

Description

UICONTEXT_SolutionBuilding

Build solution or build project mode is in effect.

UICONTEXT_Debugging

Debug mode is in effect. This includes running and break mode.

UICONTEXT_Dragging

Drag/drop operation is taking place. The environment turns this UI context on when a drag operation begins and turns it off when the drop occurs.

UICONTEXT_FullScreenMode

Full Screen command from the View menu has been selected.

UICONTEXT_DesignMode

Design mode is in effect.

UICONTEXT_NoSolution

There is no current solution.

UICONTEXT_EmptySolution

There are no current projects. The user has created a blank solution.

UICONTEXT_SolutionHasSingleProject

The current solution has one project.

UICONTEXT_SolutionHasMultipleProjects

The current solution has more than one project.

.NET Framework Security

See Also

Reference

IVsMonitorSelection Interface

Microsoft.VisualStudio.Shell.Interop Namespace