本文整理汇总了C#中IContextMenu.InvokeCommand方法的典型用法代码示例。如果您正苦于以下问题:C# IContextMenu.InvokeCommand方法的具体用法?C# IContextMenu.InvokeCommand怎么用?C# IContextMenu.InvokeCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IContextMenu
的用法示例。
在下文中一共展示了IContextMenu.InvokeCommand方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeCommand
private void InvokeCommand(IContextMenu oContextMenu, uint nCmd, string strFolder, Point pointInvoke)
{
CMINVOKECOMMANDINFOEX invoke = new CMINVOKECOMMANDINFOEX();
invoke.cbSize = cbInvokeCommand;
invoke.lpVerb = (IntPtr)(nCmd - CMD_FIRST);
invoke.lpDirectory = strFolder;
invoke.lpVerbW = (IntPtr)(nCmd - CMD_FIRST);
invoke.lpDirectoryW = strFolder;
invoke.fMask = CMIC.UNICODE | CMIC.PTINVOKE |
((Control.ModifierKeys & Keys.Control) != 0 ? CMIC.CONTROL_DOWN : 0) |
((Control.ModifierKeys & Keys.Shift) != 0 ? CMIC.SHIFT_DOWN : 0);
invoke.ptInvoke = new POINT(pointInvoke.X, pointInvoke.Y);
invoke.nShow = SW.SHOWNORMAL;
oContextMenu.InvokeCommand(ref invoke);
}
示例2: InvokeCommand
/// <summary>
/// Invokes a specific command from an IContextMenu
/// </summary>
/// <param name="iContextMenu">the IContextMenu containing the item</param>
/// <param name="cmdA">the Ansi execute string to invoke</param>
/// <param name="cmdW">the Unicode execute string to invoke</param>
/// <param name="parentDir">the parent directory from where to invoke</param>
/// <param name="ptInvoke">the point (in screen coördinates) from which to invoke</param>
public static void InvokeCommand(IContextMenu iContextMenu, string cmd, string parentDir, Point ptInvoke)
{
ShellAPI.CMINVOKECOMMANDINFOEX invoke = new ShellAPI.CMINVOKECOMMANDINFOEX();
invoke.cbSize = ShellAPI.cbInvokeCommand;
invoke.lpVerb = Marshal.StringToHGlobalAnsi(cmd);
invoke.lpDirectory = parentDir;
invoke.lpVerbW = Marshal.StringToHGlobalUni(cmd);
invoke.lpDirectoryW = parentDir;
invoke.fMask = ShellAPI.CMIC.UNICODE | ShellAPI.CMIC.PTINVOKE |
((Control.ModifierKeys & Keys.Control) != 0 ? ShellAPI.CMIC.CONTROL_DOWN : 0) |
((Control.ModifierKeys & Keys.Shift) != 0 ? ShellAPI.CMIC.SHIFT_DOWN : 0);
invoke.ptInvoke = new ShellAPI.POINT(ptInvoke.X, ptInvoke.Y);
invoke.nShow = ShellAPI.SW.SHOWNORMAL;
iContextMenu.InvokeCommand(ref invoke);
}
示例3: InvokeCommand
/// <summary>
/// Invokes a specific command from an IContextMenu
/// </summary>
/// <param name="iContextMenu">the IContextMenu containing the item</param>
/// <param name="cmd">the execute string to invoke</param>
/// <param name="parentDir">the parent node from where to invoke</param>
/// <param name="ptInvoke">the point (in screen coцrdinates) from which to invoke</param>
public static void InvokeCommand(IContextMenu iContextMenu, string cmd, string parentDir, Point ptInvoke)
{
CMINVOKECOMMANDINFOEX invoke = new CMINVOKECOMMANDINFOEX();
invoke.Size = Marshal.SizeOf(typeof(CMINVOKECOMMANDINFOEX));
invoke.Verb = Marshal.StringToHGlobalAnsi(cmd);
invoke.Directory = parentDir;
invoke.VerbW = Marshal.StringToHGlobalUni(cmd);
invoke.DirectoryW = parentDir;
invoke.Mask = CMIC.Unicode | CMIC.PtInvoke |
((Control.ModifierKeys & Keys.Control) != 0 ? CMIC.ControlDown : 0) |
((Control.ModifierKeys & Keys.Shift) != 0 ? CMIC.ShiftDown : 0);
invoke.InvokePoint = new POINT(ptInvoke);
invoke.ShowType = SW.ShowNormal;
iContextMenu.InvokeCommand(ref invoke);
}
示例4: InvokeCommand
private static void InvokeCommand(IContextMenu oContextMenu, uint nCmd, string strFolder, Point pointInvoke)
{
var invoke = new Structs.Cminvokecommandinfoex
{
cbSize = CbInvokeCommand,
lpVerb = (IntPtr) (nCmd - CmdFirst),
lpDirectory = strFolder,
lpVerbW = (IntPtr) (nCmd - CmdFirst),
lpDirectoryW = strFolder,
fMask = Enums.Cmic.UNICODE | Enums.Cmic.PTINVOKE | ((Control.ModifierKeys & Keys.Control) != 0 ? Enums.Cmic.CONTROL_DOWN : 0) | ((Control.ModifierKeys & Keys.Shift) != 0 ? Enums.Cmic.SHIFT_DOWN : 0),
ptInvoke = new Structs.Point(pointInvoke.X, pointInvoke.Y),
nShow = Enums.Sw.SHOWNORMAL
};
oContextMenu.InvokeCommand(ref invoke);
}
示例5: ExecuteVerb
public static bool ExecuteVerb(IWin32Window owner, string verb, string parentName, IContextMenu contextMenu)
{
if (contextMenu == null)
{
return false;
}
CMINVOKECOMMANDINFOEX structure = new CMINVOKECOMMANDINFOEX();
try
{
structure.cbSize = Marshal.SizeOf(structure);
if (verb != null)
{
structure.lpVerb = Marshal.StringToHGlobalAnsi(verb);
structure.lpVerbW = Marshal.StringToHGlobalUni(verb);
}
if (!string.IsNullOrEmpty(parentName))
{
structure.lpDirectory = parentName;
structure.lpDirectoryW = parentName;
}
if (owner != null)
{
structure.hwnd = owner.Handle;
}
structure.fMask = (CMIC.UNICODE | (((Control.ModifierKeys & Keys.Control) > Keys.None) ? CMIC.CONTROL_DOWN : ((CMIC) 0))) | (((Control.ModifierKeys & Keys.Shift) > Keys.None) ? CMIC.SHIFT_DOWN : ((CMIC) 0));
structure.nShow = SW.SW_SHOWNORMAL;
contextMenu.InvokeCommand(ref structure);
Marshal.ReleaseComObject(contextMenu);
}
finally
{
Marshal.FreeHGlobal(structure.lpVerb);
Marshal.FreeHGlobal(structure.lpVerbW);
}
return true;
}
示例6: InvokeCommand
/// <summary>
/// Invokes a specific command from an IContextMenu
/// </summary>
/// <param name="iContextMenu">the IContextMenu containing the item</param>
/// <param name="cmd">the index of the command to invoke</param>
/// <param name="parentDir">the parent directory from where to invoke</param>
/// <param name="ptInvoke">the point (in screen coördinates) from which to invoke</param>
public static void InvokeCommand(IContextMenu iContextMenu, uint cmd, string parentDir, Point ptInvoke)
{
NativeShellAPI.CMINVOKECOMMANDINFOEX invoke = new NativeShellAPI.CMINVOKECOMMANDINFOEX();
invoke.cbSize = NativeShellAPI.cbInvokeCommand;
invoke.lpVerb = (IntPtr)cmd;
invoke.lpDirectory = parentDir;
invoke.lpVerbW = (IntPtr)cmd;
invoke.lpDirectoryW = parentDir;
invoke.fMask = NativeShellAPI.CMIC.UNICODE | NativeShellAPI.CMIC.PTINVOKE |
((Control.ModifierKeys & Keys.Control) != 0 ? NativeShellAPI.CMIC.CONTROL_DOWN : 0) |
((Control.ModifierKeys & Keys.Shift) != 0 ? NativeShellAPI.CMIC.SHIFT_DOWN : 0);
invoke.ptInvoke = new NativeShellAPI.POINT(ptInvoke.X, ptInvoke.Y);
invoke.nShow = NativeShellAPI.SW.SHOWNORMAL;
iContextMenu.InvokeCommand(ref invoke);
}