mirror of https://github.com/dahall/Vanara.git
Added IOleCommandTarget, IInputObject and IStartMenuPinnedList interfaces and supporting code
parent
19e4cd0699
commit
d64d154c08
|
@ -0,0 +1,265 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vanara.PInvoke
|
||||
{
|
||||
public static partial class Shell32
|
||||
{
|
||||
/// <summary>Specifies command execution options.</summary>
|
||||
[PInvokeData("docobj.h")]
|
||||
public enum OLECMDEXECOPT
|
||||
{
|
||||
/// <summary>Prompt the user for input or not, whichever is the default behavior.</summary>
|
||||
OLECMDEXECOPT_DODEFAULT = 0,
|
||||
/// <summary>Execute the command after obtaining user input.</summary>
|
||||
OLECMDEXECOPT_PROMPTUSER = 1,
|
||||
/// <summary>
|
||||
/// Execute the command without prompting the user. For example, clicking the Print toolbar button causes a document to be
|
||||
/// immediately printed without user input.
|
||||
/// </summary>
|
||||
OLECMDEXECOPT_DONTPROMPTUSER = 2,
|
||||
/// <summary>Show help for the corresponding command, but do not execute.</summary>
|
||||
OLECMDEXECOPT_SHOWHELP = 3
|
||||
}
|
||||
|
||||
/// <summary>Specifies the type of support provided by an object for the command specified in an OLECMD structure.</summary>
|
||||
[PInvokeData("docobj.h")]
|
||||
public enum OLECMDF
|
||||
{
|
||||
/// <summary>The command is supported by this object.</summary>
|
||||
OLECMDF_SUPPORTED = 0x00000001,
|
||||
/// <summary>The command is available and enabled.</summary>
|
||||
OLECMDF_ENABLED = 0x00000002,
|
||||
/// <summary>The command is an on-off toggle and is currently on.</summary>
|
||||
OLECMDF_LATCHED = 0x00000004,
|
||||
/// <summary>Reserved for future use.</summary>
|
||||
OLECMDF_NINCHED = 0x00000008,
|
||||
/// <summary>The command is hidden.</summary>
|
||||
OLECMDF_INVISIBLE = 0x00000010,
|
||||
/// <summary>The command is hidden on the context menu.</summary>
|
||||
OLECMDF_DEFHIDEONCTXTMENU = 0x00000020,
|
||||
}
|
||||
|
||||
public enum OLECMDID
|
||||
{
|
||||
OLECMDID_OPEN = 1,
|
||||
OLECMDID_NEW = 2,
|
||||
OLECMDID_SAVE = 3,
|
||||
OLECMDID_SAVEAS = 4,
|
||||
OLECMDID_SAVECOPYAS = 5,
|
||||
OLECMDID_PRINT = 6,
|
||||
OLECMDID_PRINTPREVIEW = 7,
|
||||
OLECMDID_PAGESETUP = 8,
|
||||
OLECMDID_SPELL = 9,
|
||||
OLECMDID_PROPERTIES = 10,
|
||||
OLECMDID_CUT = 11,
|
||||
OLECMDID_COPY = 12,
|
||||
OLECMDID_PASTE = 13,
|
||||
OLECMDID_PASTESPECIAL = 14,
|
||||
OLECMDID_UNDO = 15,
|
||||
OLECMDID_REDO = 16,
|
||||
OLECMDID_SELECTALL = 17,
|
||||
OLECMDID_CLEARSELECTION = 18,
|
||||
OLECMDID_ZOOM = 19,
|
||||
OLECMDID_GETZOOMRANGE = 20,
|
||||
OLECMDID_UPDATECOMMANDS = 21,
|
||||
OLECMDID_REFRESH = 22,
|
||||
OLECMDID_STOP = 23,
|
||||
OLECMDID_HIDETOOLBARS = 24,
|
||||
OLECMDID_SETPROGRESSMAX = 25,
|
||||
OLECMDID_SETPROGRESSPOS = 26,
|
||||
OLECMDID_SETPROGRESSTEXT = 27,
|
||||
OLECMDID_SETTITLE = 28,
|
||||
OLECMDID_SETDOWNLOADSTATE = 29,
|
||||
OLECMDID_STOPDOWNLOAD = 30,
|
||||
OLECMDID_ONTOOLBARACTIVATED = 31,
|
||||
OLECMDID_FIND = 32,
|
||||
OLECMDID_DELETE = 33,
|
||||
OLECMDID_HTTPEQUIV = 34,
|
||||
OLECMDID_HTTPEQUIV_DONE = 35,
|
||||
OLECMDID_ENABLE_INTERACTION = 36,
|
||||
OLECMDID_ONUNLOAD = 37,
|
||||
OLECMDID_PROPERTYBAG2 = 38,
|
||||
OLECMDID_PREREFRESH = 39,
|
||||
OLECMDID_SHOWSCRIPTERROR = 40,
|
||||
OLECMDID_SHOWMESSAGE = 41,
|
||||
OLECMDID_SHOWFIND = 42,
|
||||
OLECMDID_SHOWPAGESETUP = 43,
|
||||
OLECMDID_SHOWPRINT = 44,
|
||||
OLECMDID_CLOSE = 45,
|
||||
OLECMDID_ALLOWUILESSSAVEAS = 46,
|
||||
OLECMDID_DONTDOWNLOADCSS = 47,
|
||||
OLECMDID_UPDATEPAGESTATUS = 48,
|
||||
OLECMDID_PRINT2 = 49,
|
||||
OLECMDID_PRINTPREVIEW2 = 50,
|
||||
OLECMDID_SETPRINTTEMPLATE = 51,
|
||||
OLECMDID_GETPRINTTEMPLATE = 52,
|
||||
OLECMDID_PAGEACTIONBLOCKED = 55,
|
||||
OLECMDID_PAGEACTIONUIQUERY = 56,
|
||||
OLECMDID_FOCUSVIEWCONTROLS = 57,
|
||||
OLECMDID_FOCUSVIEWCONTROLSQUERY = 58,
|
||||
OLECMDID_SHOWPAGEACTIONMENU = 59,
|
||||
OLECMDID_ADDTRAVELENTRY = 60,
|
||||
OLECMDID_UPDATETRAVELENTRY = 61,
|
||||
OLECMDID_UPDATEBACKFORWARDSTATE = 62,
|
||||
OLECMDID_OPTICAL_ZOOM = 63,
|
||||
OLECMDID_OPTICAL_GETZOOMRANGE = 64,
|
||||
OLECMDID_WINDOWSTATECHANGED = 65,
|
||||
OLECMDID_ACTIVEXINSTALLSCOPE = 66,
|
||||
OLECMDID_UPDATETRAVELENTRY_DATARECOVERY = 67,
|
||||
OLECMDID_SHOWTASKDLG = 68,
|
||||
OLECMDID_POPSTATEEVENT = 69,
|
||||
OLECMDID_VIEWPORT_MODE = 70,
|
||||
OLECMDID_LAYOUT_VIEWPORT_WIDTH = 71,
|
||||
OLECMDID_VISUAL_VIEWPORT_EXCLUDE_BOTTOM = 72,
|
||||
OLECMDID_USER_OPTICAL_ZOOM = 73,
|
||||
OLECMDID_PAGEAVAILABLE = 74,
|
||||
OLECMDID_GETUSERSCALABLE = 75,
|
||||
OLECMDID_UPDATE_CARET = 76,
|
||||
OLECMDID_ENABLE_VISIBILITY = 77,
|
||||
OLECMDID_MEDIA_PLAYBACK = 78,
|
||||
OLECMDID_SETFAVICON = 79,
|
||||
OLECMDID_SET_HOST_FULLSCREENMODE = 80,
|
||||
OLECMDID_EXITFULLSCREEN = 81,
|
||||
OLECMDID_SCROLLCOMPLETE = 82,
|
||||
OLECMDID_ONBEFOREUNLOAD = 83,
|
||||
OLECMDID_SHOWMESSAGE_BLOCKABLE = 84,
|
||||
OLECMDID_SHOWTASKDLG_BLOCKABLE = 85,
|
||||
}
|
||||
|
||||
/// <summary>Specifies the window state.</summary>
|
||||
[PInvokeData("docobj.h")]
|
||||
[Flags]
|
||||
public enum OLECMDID_WINDOWSTATE_FLAG
|
||||
{
|
||||
/// <summary>The window is visible.</summary>
|
||||
OLECMDIDF_WINDOWSTATE_USERVISIBLE = 0x01,
|
||||
/// <summary>The window has focus.</summary>
|
||||
OLECMDIDF_WINDOWSTATE_ENABLED = 0x02,
|
||||
/// <summary>The window is visible and valid.</summary>
|
||||
OLECMDIDF_WINDOWSTATE_USERVISIBLE_VALID = 0x00010000,
|
||||
/// <summary>The window has focus and is valid.</summary>
|
||||
OLECMDIDF_WINDOWSTATE_ENABLED_VALID = 0x00020000
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the type of information that an object should store in the OLECMDTEXT structure passed in
|
||||
/// IOleCommandTarget::QueryStatus. One value from this enumeration is stored the cmdtextf member of the OLECMDTEXT structure to
|
||||
/// indicate the desired information.
|
||||
/// </summary>
|
||||
[PInvokeData("docobj.h")]
|
||||
public enum OLECMDTEXTF
|
||||
{
|
||||
/// <summary>No extra information is requested.</summary>
|
||||
OLECMDTEXTF_NONE = 0,
|
||||
/// <summary>The object should provide the localized name of the command.</summary>
|
||||
OLECMDTEXTF_NAME = 1,
|
||||
/// <summary>The object should provide a localized status string for the command.</summary>
|
||||
OLECMDTEXTF_STATUS = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables objects and their containers to dispatch commands to each other. For example, an object's toolbars may contain buttons
|
||||
/// for commands such as Print, Print Preview, Save, New, and Zoom.
|
||||
/// <para>
|
||||
/// Normal in-place activation guidelines recommend that you remove or disable such buttons because no efficient, standard mechanism
|
||||
/// has been available to dispatch them to the container.Similarly, a container has heretofore had no efficient means to send
|
||||
/// commands such as Print, Page Setup, and Properties to an in-place active object. Such simple command routing could have been
|
||||
/// handled through existing OLE Automation standards and the IDispatch interface, but the overhead with IDispatch is more than is
|
||||
/// required in the case of document objects.The IOleCommandTarget interface provides a simpler means to achieve the same ends.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Available commands are defined by integer identifiers in a group. The group itself is identified with a GUID. The interface
|
||||
/// allows a caller both to query for support of one or more commands within a group and to issue a supported command to the object.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[ComImport, Guid("B722BCCB-4E68-101B-A2BC-00AA00404770"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[PInvokeData("docobj.h")]
|
||||
public interface IOleCommandTarget
|
||||
{
|
||||
/// <summary>Queries the object for the status of one or more commands generated by user interface events.</summary>
|
||||
/// <param name="pguidCmdGroup">
|
||||
/// The unique identifier of the command group; can be NULL to specify the standard group. All the commands that are passed in
|
||||
/// the prgCmds array must belong to the group specified by pguidCmdGroup.
|
||||
/// </param>
|
||||
/// <param name="cCmds">The number of commands in the prgCmds array.</param>
|
||||
/// <param name="prgCmds">
|
||||
/// A caller-allocated array of OLECMD structures that indicate the commands for which the caller needs status information. This
|
||||
/// method fills the cmdf member of each structure with values taken from the OLECMDF enumeration.
|
||||
/// </param>
|
||||
/// <param name="pCmdText">
|
||||
/// A pointer to an OLECMDTEXT structure in which to return name and/or status information of a single command. This parameter
|
||||
/// can be NULL to indicate that the caller does not need this information.
|
||||
/// </param>
|
||||
/// <returns>This method returns S_OK on success.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT QueryStatus([In, MarshalAs(UnmanagedType.LPStruct)] Guid pguidCmdGroup, uint cCmds, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] OLECMD[] prgCmds, OLECMDTEXT pCmdText);
|
||||
|
||||
/// <summary>Executes the specified command or displays help for the command.</summary>
|
||||
/// <param name="pguidCmdGroup">The unique identifier of the command group; can be NULL to specify the standard group.</param>
|
||||
/// <param name="nCmdID">The command to be executed. This command must belong to the group specified with pguidCmdGroup.</param>
|
||||
/// <param name="nCmdexecopt">
|
||||
/// Specifies how the object should execute the command. Possible values are taken from the OLECMDEXECOPT and
|
||||
/// OLECMDID_WINDOWSTATE_FLAG enumerations.
|
||||
/// </param>
|
||||
/// <param name="pvaIn">A pointer to a VARIANTARG structure containing input arguments. This parameter can be NULL.</param>
|
||||
/// <param name="pvaOut">Pointer to a VARIANTARG structure to receive command output. This parameter can be NULL.</param>
|
||||
/// <returns>This method returns S_OK on success.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT Exec([In, MarshalAs(UnmanagedType.LPStruct)] Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, [In, MarshalAs(UnmanagedType.LPArray)] object[] pvaIn, IntPtr pvaOut);
|
||||
}
|
||||
|
||||
/// <summary>Associates command flags from the OLECMDF enumeration with a command identifier through a call to IOleCommandTarget::QueryStatus.</summary>
|
||||
[PInvokeData("docobj.h")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct OLECMD
|
||||
{
|
||||
/// <summary>A command identifier; taken from the OLECMDID enumeration.</summary>
|
||||
public OLECMDID cmdID;
|
||||
|
||||
/// <summary>Flags associated with cmdID; taken from the OLECMDF enumeration.</summary>
|
||||
public OLECMDF cmdf;
|
||||
}
|
||||
|
||||
/// <summary>Specifies a text name or status string for a single command identifier.</summary>
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public class OLECMDTEXT : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// A value from the OLECMDTEXTF enumeration describing whether the rgwz member contains a command name or status text.
|
||||
/// </summary>
|
||||
public OLECMDTEXTF cmdtextf;
|
||||
|
||||
/// <summary>The number of characters actually written into the rgwz buffer before IOleCommandTarget::QueryStatus returns.</summary>
|
||||
public uint cwActual;
|
||||
|
||||
/// <summary>The number of elements in the rgwz array.</summary>
|
||||
public uint cwBuf;
|
||||
|
||||
private InteropServices.StrPtrUni _rgwz;
|
||||
|
||||
public OLECMDTEXT(OLECMDTEXTF cmdtextf, string nameOrStatus)
|
||||
{
|
||||
this.cmdtextf = cmdtextf;
|
||||
if (nameOrStatus != null)
|
||||
rgwz = nameOrStatus;
|
||||
}
|
||||
|
||||
/// <summary>The command name or status text.</summary>
|
||||
public string rgwz
|
||||
{
|
||||
get => _rgwz;
|
||||
set { if (value == null) _rgwz.Free(); else _rgwz.Assign(value, out cwActual); }
|
||||
}
|
||||
|
||||
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
|
||||
/// <returns>A <see cref="string"/> that represents this instance.</returns>
|
||||
public override string ToString() => rgwz;
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
_rgwz.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vanara.PInvoke
|
||||
{
|
||||
public static partial class Shell32
|
||||
{
|
||||
/// <summary>Exposes methods that change UI activation and process accelerators for a user input object contained in the Shell.</summary>
|
||||
[ComImport, Guid("68284fAA-6A48-11D0-8c78-00C04fd918b4"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[PInvokeData("ShObjIdl_core.h")]
|
||||
public interface IInputObject
|
||||
{
|
||||
/// <summary>UI-activates or deactivates the object.</summary>
|
||||
/// <param name="fActivate">
|
||||
/// Indicates if the object is being activated or deactivated. If this value is nonzero, the object is being activated. If this
|
||||
/// value is zero, the object is being deactivated.
|
||||
/// </param>
|
||||
/// <param name="pMsg">
|
||||
/// A pointer to an MSG structure that contains the message that caused the activation change. This value may be NULL.
|
||||
/// </param>
|
||||
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT UIActivateIO([In, MarshalAs(UnmanagedType.Bool)] bool fActivate, [In, MarshalAs(UnmanagedType.LPStruct)] MSG pMsg);
|
||||
|
||||
/// <summary>Determines if one of the object's windows has the keyboard focus.</summary>
|
||||
/// <returns>Returns S_OK if one of the object's windows has the keyboard focus, or S_FALSE otherwise.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT HasFocusIO();
|
||||
|
||||
/// <summary>Enables the object to process keyboard accelerators.</summary>
|
||||
/// <param name="pMsg">The address of an MSG structure that contains the keyboard message that is being translated.</param>
|
||||
/// <returns>Returns S_OK if the accelerator was translated, or S_FALSE otherwise.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT TranslateAcceleratorIO([In, MarshalAs(UnmanagedType.LPStruct)] MSG pMsg);
|
||||
}
|
||||
|
||||
/// <summary>Exposes a method that extends IInputObject by handling global accelerators.</summary>
|
||||
[ComImport, Guid("6915C085-510B-44cd-94AF-28DFA56CF92B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[PInvokeData("ShObjIdl_core.h")]
|
||||
public interface IInputObject2 : IInputObject
|
||||
{
|
||||
/// <summary>UI-activates or deactivates the object.</summary>
|
||||
/// <param name="fActivate">
|
||||
/// Indicates if the object is being activated or deactivated. If this value is nonzero, the object is being activated. If this
|
||||
/// value is zero, the object is being deactivated.
|
||||
/// </param>
|
||||
/// <param name="pMsg">
|
||||
/// A pointer to an MSG structure that contains the message that caused the activation change. This value may be NULL.
|
||||
/// </param>
|
||||
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
||||
[PreserveSig]
|
||||
new HRESULT UIActivateIO([In, MarshalAs(UnmanagedType.Bool)] bool fActivate, [In, MarshalAs(UnmanagedType.LPStruct)] MSG pMsg);
|
||||
|
||||
/// <summary>Determines if one of the object's windows has the keyboard focus.</summary>
|
||||
/// <returns>Returns S_OK if one of the object's windows has the keyboard focus, or S_FALSE otherwise.</returns>
|
||||
[PreserveSig]
|
||||
new HRESULT HasFocusIO();
|
||||
|
||||
/// <summary>Enables the object to process keyboard accelerators.</summary>
|
||||
/// <param name="pMsg">The address of an MSG structure that contains the keyboard message that is being translated.</param>
|
||||
/// <returns>Returns S_OK if the accelerator was translated, or S_FALSE otherwise.</returns>
|
||||
[PreserveSig]
|
||||
new HRESULT TranslateAcceleratorIO([In, MarshalAs(UnmanagedType.LPStruct)] MSG pMsg);
|
||||
|
||||
/// <summary>
|
||||
/// Handles global accelerators so that input objects can respond to the keyboard even when they are not active in the UI.
|
||||
/// </summary>
|
||||
/// <param name="pMsg">A pointer to an MSG structure that contains a keyboard message.</param>
|
||||
/// <returns>If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.</returns>
|
||||
[PreserveSig]
|
||||
HRESULT TranslateAcceleratorGlobal([In, MarshalAs(UnmanagedType.LPStruct)] MSG pMsg);
|
||||
}
|
||||
|
||||
/// <summary>Exposes a method that is used to communicate focus changes for a user input object contained in the Shell.</summary>
|
||||
[ComImport, Guid("F1DB8392-7331-11D0-8C99-00A0C92DBFE8"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
[PInvokeData("ShObjIdl_core.h")]
|
||||
public interface IInputObjectSite
|
||||
{
|
||||
/// <summary>Informs the browser that the focus has changed.</summary>
|
||||
/// <param name="punkObj">The address of the IUnknown interface of the object gaining or losing the focus.</param>
|
||||
/// <param name="fSetFocus">
|
||||
/// Indicates if the object has gained or lost the focus. If this value is nonzero, the object has gained the focus. If this
|
||||
/// value is zero, the object has lost the focus.
|
||||
/// </param>
|
||||
void OnFocusChangeIS([In, MarshalAs(UnmanagedType.IUnknown)] object punkObj, [In, MarshalAs(UnmanagedType.Bool)] bool fSetFocus);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Vanara.PInvoke
|
||||
{
|
||||
public static partial class Shell32
|
||||
{
|
||||
/// <summary>Exposes a method that unpins an application shortcut from the Start menu or the taskbar.</summary>
|
||||
[ComImport, Guid("4CD19ADA-25A5-4A32-B3B7-347BEE5BE36B"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(StartMenuPin))]
|
||||
[PInvokeData("shobjidl.h")]
|
||||
public interface IStartMenuPinnedList
|
||||
{
|
||||
/// <summary>
|
||||
/// <c>Windows Vista:</c> Removes an item from the Start menu pinned list, which is the list in the upper left position of the Start menu.
|
||||
/// <para><c>Windows 7:</c> Removes an item from the Start menu pinned list and unpins the item from the taskbar.</para>
|
||||
/// <para><c>Windows 8:</c> Unpins the item from the taskbar but does not remove the item from the Start screen. Items cannot be programmatically removed from Start; they can only be unpinned by the user or removed as part of a program's uninstallation.</para></summary>
|
||||
/// <param name="pitem">A pointer to an IShellItem object that represents the item to unpin.</param>
|
||||
/// <returns>
|
||||
/// <list type="bullet">
|
||||
/// <item><term>Returns S_OK if the item was successfully removed from the list of pinned items and/or the taskbar.</term></item>
|
||||
/// <item><term>Returns S_OK if the item was not pinned at all.</term></item>
|
||||
/// <item><term>Returns a standard error code otherwise.</term></item>
|
||||
/// </list>
|
||||
/// </returns>
|
||||
[PreserveSig]
|
||||
HRESULT RemoveFromList([In] IShellItem pitem);
|
||||
}
|
||||
|
||||
/// <summary>CoClass for IStartMenuPinnedList (CLSID_StartMenuPin).</summary>
|
||||
[PInvokeData("shobjidl.h")]
|
||||
[ComImport, Guid("a2a9545d-a0c2-42b4-9708-a0b2badd77c8"), ClassInterface(ClassInterfaceType.None)]
|
||||
public class StartMenuPin { }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue